how do you change screens

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

how do you change screens

Post by link »

how do you change screens like if you were making a zelda rip0-off (which im not) how do you change the screen from one room to the next?
like if you were to walk through the door, how do you load the next room?
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Use blit function to change rooms. Each call will overwrite old image with a new one.

If not much help, please clarify your need.
Geo Massar
Retired Engineer
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

for an example in the tutorial they made a pac-man type of a game. how would you change screens in that game? I am a noob.....sorry.
haust
Posts: 25
Joined: Sat Oct 01, 2005 12:37 am
Location: France

Post by haust »

Well, one technic would be to have one offscreen image for each room. Now when your character is in room one just blit the first image on screen.
If you want to go to room two then slide/scroll both images, say from right to left. When the slide effect ends room one is off screen (no need to blit it) and room two becomes your new current room....

hope it helps :)
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

incredibly sorry, but how do do the side scroll or blit the image? PLEASE can you show me in the same game code as the tutorial listed on this web site so i can have some point of reference?
haust
Posts: 25
Joined: Sat Oct 01, 2005 12:37 am
Location: France

Post by haust »

Code: Select all

function main()
	local Rooms = {};
	local SlideX = 0;
	local SlideXSpeed = -1;

	Rooms[1] = Image.load("Room1.png");	-- 480x272
	Rooms[2] = Image.load("Room2.png");	-- 480x272

	while (false == Controls.read():start()) do
		SlideX = SlideX + SlideXSpeed;

		if (((-1 == SlideXSpeed) and (-480 == SlideX))
			or ((1 == SlideXSpeed) and (480 == SlideX))) then
			SlideXSpeed = -SlideXSpeed;
		end

		screen:clear();

		screen:blit(SlideX, 0, Rooms[1], 0, 0, 480, 272, false);
		screen:blit(SlideX + 480, 0, Rooms[2], 0, 0, 480, 272, false);

		screen.waitVblankStart()
		screen.flip()
	end
end

main();
The code provided above is very basic but it should give you an idea of the slide process.
First, two images are loaded, one for room one and the second for room two. Then, until start is pressed, both images are scrolled from rigth to left then from left to right.
Again, the code is very basic and a better blit strategy should/must be used. Now it's up to you to test and tweak this piece of code to better understand how it works :)
Post Reply