The Basics Part 2

From PSP Developer wiki
Revision as of 19:11, 2 March 2019 by GregoryRasputin (talk | contribs) (Created page with "Lesson 02 The Basics Lua Programming Techniques This is part two of Whitehawk's second intoductory Lua tutorial. If you haven't already read the first part, go back now. Now...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Lesson 02 The Basics Lua Programming Techniques This is part two of Whitehawk's second intoductory Lua tutorial. If you haven't already read the first part, go back now.

Now that we have loaded the background, we want to update our loading status text. screen:clear() screen:print(194, 136, "Loading: 20%", pink) screen.flip() This should all be familiar to you by now. All, that is, except for the "screen:clear()." What do you suppose this does? No, it doesn't initiate the hyper flux capacitor. Nope, sorry, it doesn't make your PSP transparent. What's that? Yes, you in the back. Correct! It erases everything we have on the screen up to this point. It lets us start over with a clean slate.

Now we'll do the same process over again, but loading different images (and loading one sound):

circle = Image.load("images/buttons/circle_button.png") down = Image.load("images/buttons/down_arrow.png")

screen:clear() screen:print(194, 136, "Loading: 40%", pink) screen.flip()

l = Image.load("images/buttons/left_trigger.png") left = Image.load("images/buttons/left_arrow.png")

screen:clear() screen:print(194, 136, "Loading: 60%", pink) screen.flip()

r = Image.load("images/buttons/right_trigger.png") right = Image.load("images/buttons/right_arrow.png") boltsnd = Sound.load("music/comp.wav")

screen:clear() screen:print(194, 136, "Loading: 80%", pink) screen.flip()

square = Image.load("images/buttons/square_button.png") triangle = Image.load("images/buttons/triangle_button.png")

screen:clear() screen:print(194, 136, "Loading: 90%", pink) screen.flip()

up = Image.load("images/buttons/up_arrow.png") x = Image.load("images/buttons/cross_button.png") splash = Image.load("images/lua.png")

screen:clear() screen:print(194, 136, "Loading: 100%", pink) screen.flip() The one thing in this block of code that does need to be explained is the loading of the sound. The line 'boltsnd = Sound.load("music/comp.wav")' is what loads our sound file. Symantically, it is identical to the image loading code. The only real difference is that the "Sound.load()" method is defined in the "Sound" class rather than the "Image" class. You needent worry about this just yet, it may come up in some advanced programming later, or you may never have to deal with it (unless you learn Java, then you most definitely will).

After all of our stuff is loaded, we are just going to quickly pause at the "Loading 100%" so our user gets a chance to see it. To do this, we'll use the "waitVblankStart" function that we talked about at the end of Lesson 01. screen.waitVblankStart(60) This time we have passed a parameter to the function. This just tells it to pause for a certain amount of time. There are sixty Vblanks in a second, so this pauses our program at this point for exactly one second.

We've finished our loading screen (and our loading). Now it's time for the intro screen, thanks go to indianajonesilm, the author of PSP Air Hockey.

So go on to part three and make an intro screen.