QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

PSP PGE Lua Player Tutorials by FaT3oYCG.

This is a discussion on PSP PGE Lua Player Tutorials by FaT3oYCG. within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Contents: Introduction – A short introduction. Lesson 1 – The fundamental loop. Lesson 2 – Loading and printing text to ...

Reply
 
LinkBack Thread Tools
Old 09-24-2009, 12:51 PM   #1
Developer and Tutor.
 
FaT3oYCG's Avatar
 
My Mood: Happy
Join Date: Jul 2007
Real First Name: Craig
Location: Widnes, England
Just Played: Life.
Posts: 1,646
Trader Feedback: 0
Lightbulb PSP PGE Lua Player Tutorials by FaT3oYCG.

Contents:
Introduction – A short introduction.
Lesson 1 – The fundamental loop.
Lesson 2 – Loading and printing text to the screen.
Lesson 3 – Loading and displaying images on the screen.
Lesson 4 – Detecting and acting upon button changes.
Lesson 5 – Adding sound to you game.
Lesson 6 – Manipulating data from a file (Reading and Writing).
Lesson 7 – Directory management and manipulation.
Lesson 8 – Using networking in your game.

Introduction:
In the following tutorials I will be teaching you how to code in Lua using the PGE Candidate of Lua Player for the PSP. I will not however be teaching you the basics of the Lua programming language. Some things you should know before starting to follow these tutorials are methods such as “if condition then end”, “while condition do end”, “local” and comments.

If you would like to request a tutorial that is not already planned then please feel free to post a reply suggesting that I cover that topic.

Please note that I am creating these tutorials in my free time which I do not have enormous amounts of and the tutorials planned do not have set deadlines to be created by so please bare with me.

Also if you find anything that I post in these tutorials to be wrong, hard to read or inaccurate then please point them out.
__________________
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: is down for a while ... I'll bring a new one back soon.

Currently working on:
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? - A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

Last edited by FaT3oYCG; 09-25-2009 at 10:23 AM..
FaT3oYCG is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-24-2009, 12:51 PM   #2
Developer and Tutor.
 
FaT3oYCG's Avatar
 
My Mood: Happy
Join Date: Jul 2007
Real First Name: Craig
Location: Widnes, England
Just Played: Life.
Posts: 1,646
Trader Feedback: 0
Default Lesson 1 – The fundamental loop.

Lesson 1 – The fundamental loop.

The most basic loop that you should use should look something like the following.

Code:
-- local variableName = value

while pge.running() do
	pge.controls.update()
	pge.gfx.startdrawing()
	pge.gfx.clearscreen()

	-- Events

	pge.gfx.enddrawing()
	pge.gfx.swapbuffers()
end
Following the loop from start to finish here is what is happening.
  • Any variables that you want to define are defined.
  • The loop initialises and you check if PGE is running as there is a command to stop PGE running which will exit your game.
  • The controls get updated so that if you check to see if a button has been pressed or held then it registers that loop.
  • The next line starts the PGE drawing functions so that you can draw images etc. to the screen.
  • The screen then gets cleared so that you can draw your new most up to date text and images on a clear screen otherwise old data would still be shown.
  • You then do whatever you want to do in your game.
  • The next command stops the drawing.
  • And the command after that flips the screen so any data that has been displayed on the screen can be seen.
  • The while loop is then ended.
That wraps up the end of the first tutorial, in the next tutorial I will be explaining how you load and print text to the screen using the loop as a base.
__________________
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: is down for a while ... I'll bring a new one back soon.

Currently working on:
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? - A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
FaT3oYCG is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-24-2009, 01:13 PM   #3

Developer
 
seanpaul223's Avatar
 
My Mood: Psychedelic
Join Date: Dec 2007
Location: B.F.
Posts: 308
Trader Feedback: 0
Default

Guess that Lesson 6 will not cover only basics about reading data from files ? Cause I'd rather prefer Reading/Writing data from files.

Anyway,awesome.Thanks for the good work you're doing.
__________________
00:00: Windows is loading...Come back tomorrow.
01:00 : Booting done.Not yet errors encountered...
01:10: Fatal error.Windows has been detected on logical drive
01:22: Keyboard Locked, try everything.
01:42 : Mouse Device Pilot not found, or uninstalled.Press Left-Bouton to continue.
01:50 : Ending User session.Do you want to play another game ?
01:59: Not enough memory.Only 508'312'583 bytes available.
02:00 : System is shutting Down.
seanpaul223 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-24-2009, 01:47 PM   #4
Developer and Tutor.
 
FaT3oYCG's Avatar
 
My Mood: Happy
Join Date: Jul 2007
Real First Name: Craig
Location: Widnes, England
Just Played: Life.
Posts: 1,646
Trader Feedback: 0
Default

Thanks for pointing that out I will cover reading and writing to files completely.
__________________
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: is down for a while ... I'll bring a new one back soon.

Currently working on:
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? - A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
FaT3oYCG is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-25-2009, 10:21 AM   #5
Developer and Tutor.
 
FaT3oYCG's Avatar
 
My Mood: Happy
Join Date: Jul 2007
Real First Name: Craig
Location: Widnes, England
Just Played: Life.
Posts: 1,646
Trader Feedback: 0
Default Lesson 2 – Loading and printing text to the screen.

O.K. Lesson 2 is covering loading a font and then printing some text to the screen.

So to begin with we need to know some of the most basic commands for loading, activating and displaying a font on the screen and I will also add in the function for crating colours into the mix so we will be able to see what we have done. The function to load a font in PGE is pge.font.load() which is simple enough. Before we use the font we need to something called activating it, we need to do this so that the current texture that PGE will use will be the font and not any previous image or anything else that would cause it not to display right the function to do this is pge.font.activate() or fontName:activate(). The final functions that we need to know about are the pge.font.print() and pge.font.printcenter() these can also be used as fontName:print() and fontName:printcenter() which do what they say print text to the screen. The function to create a colour is pge.gfx.createcolor() which does what it says aswell.

Now that you know about the functions and what they do we will get on with some code. I will explain what the code does at the end of the tutorial like usual and then you can play around with it and try changing things if you want.

Code:
local verdana12 = pge.font.load(“./verdana.ttf”, 12)

local green = pge.gfx.createcolor(0, 255, 0)

while pge.running() do
	pge.controls.update()
	pge.gfx.startdrawing()
	pge.gfx.clearscreen()

	verdana12:activate()
	verdana12:printcenter(136, green, “Hello World :P”)

	pge.gfx.enddrawing()
	pge.gfx.swapbuffers()
end
I’m not going to explain the loop again but here is what is happening with the functions now.
  • First of all the pge.font.load() function is called this lads the font called verdana.ttf in the same directory as the script into the variable name verdana12 as we set the font to display in font size 12.
  • The next new thing that we did was create a colour the function pge.gfx.createcolour() takes 3 arguments minimally which are three colour values red, green, and blue values ranging from 0 to 255.
  • The next new function which was shortened to verdana12:activate() takes no arguments and simply activates the font ready for use, you do not need to do this multiple times for multiple lines unless you activate something different in-between.
  • The final new function which I chose over the normal printing method is verdana12:printcenter() which takes three arguments which are the Y position, the colour of the text and the actual text itself. – The normal print variation takes four arguments which are the X position, the Y position, the colour, and the text.
That just about wraps up tutorial two, I won’t attach the verdana.ttf font file as it is included with the PGE Lua Player download.
__________________
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: is down for a while ... I'll bring a new one back soon.

Currently working on:
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? - A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

Last edited by FaT3oYCG; 09-28-2009 at 01:22 PM..
FaT3oYCG is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
fat3oycg , lua , pge , player , psp , tutorials

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 05:54 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us