| View previous topic :: View next topic |
| Author |
Message |
link
Joined: 19 Oct 2005 Posts: 61
|
Posted: Wed Oct 19, 2005 7:05 am Post subject: how do you change screens |
|
|
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? |
|
| Back to top |
|
 |
KawaGeo
Joined: 27 Aug 2005 Posts: 191 Location: Calif Mountains
|
Posted: Wed Oct 19, 2005 7:36 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
link
Joined: 19 Oct 2005 Posts: 61
|
Posted: Wed Oct 19, 2005 7:50 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
haust
Joined: 01 Oct 2005 Posts: 25 Location: France
|
Posted: Wed Oct 19, 2005 10:19 am Post subject: |
|
|
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 :) |
|
| Back to top |
|
 |
link
Joined: 19 Oct 2005 Posts: 61
|
Posted: Wed Oct 19, 2005 12:15 pm Post subject: |
|
|
| 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? |
|
| Back to top |
|
 |
haust
Joined: 01 Oct 2005 Posts: 25 Location: France
|
Posted: Wed Oct 19, 2005 2:27 pm Post subject: |
|
|
| Code: | 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 :) |
|
| Back to top |
|
 |
|