|
Auto Scrolling like gradius or raden trad |
Rich Romer
Member #6,734
December 2005
|
I'm making a game thats like has auto scrolling like gradius or raden trad. The background updates constantly and makes it look like your moving. I dont know how to do this though since I'm new to game programming. So far i built something that scrolls the level but when i add in the ship and movement controlls it doesn't work. I know alot of people have done this before but i cant find code or a tutorial that makes sense. ---- code ------------------------------ int map_x = 0; int main(int argc, char *argv[]) |
BAF
Member #2,981
December 2002
|
Wait, what do you want? A parallaxed background? |
Rich Romer
Member #6,734
December 2005
|
i dont know what a parralex background is. what i want to do is have the map auto scroll like in games like gradius, r-type, radien trad. |
tapir
Member #6,629
November 2005
|
I never heard of these games |
count
Member #5,401
January 2005
|
Onewing
Member #6,152
August 2005
|
[EDIT] OOps, guess I should learn how to read. Quote: should that not be something like: blit(buffer, screen, map_x,map_y,0,0,640,480); I think he's trying to scroll vertically. [EDIT2] Quote: So far i built something that scrolls the level but when i add in the ship and movement controlls it doesn't work. What exactly isn't working? ------------ |
count
Member #5,401
January 2005
|
but in his blitt the blitted image is BIGGER than the screen. this makes no sense. And the map_x var is not used in his blit. Quote: BITMAP* buffer = create_bitmap(640,1919); But as the buffer is the same size as the screen this should be no problem. Hmm. Sorry. Just had a quick look at the code.
|
Onewing
Member #6,152
August 2005
|
Quote: but in his blitt the blitted image is BIGGER than the screen. this makes no sense. It's bigger in the y direction, not the x direction. Quote: And the map_x var is not used in his blit. He's keeping the x-cood of the map stationary, like one of those arcade top-down view plane games that scroll up. Perhaps he's planning on having map_x elsewhere... ------------ |
count
Member #5,401
January 2005
|
i Would do it like this: BITMAP* buffer = create_bitmap(640,1919); BITMAP* temp = create_bitmap(640,480); blit(buffer, temp, camera_x, camera_y, 0, 0, 640, 480); draw_sprite(temp, player, player_x, player_y); blit(temp, screen, 0,0,0,0,640,480);
Everytime the player/ship moves change the player_x, player_y vars. To scroll the background change the camera_x or camera_y vars. Only a small part of the code. Hope this makes things clearer. If not please ask. EDIT Quote: It's bigger in the y direction, not the x direction. yea. Thats why I changed this part of the blit. Makes no sense to blit a 1000+ image to a screen which is only 480 in size. The most parts of the images would not be visable. Quote: He's keeping the x-cood of the map stationary, like one of those arcade top-down view plane games that scroll up. Perhaps he's planning on having map_x elsewhere... Yes, I did oversee this at the first quick look. Sorry.
|
Onewing
Member #6,152
August 2005
|
Quote: i Would do it like this: So would I, moreorless, except I'd switch the buffer and temp names (personal preference, just like the buffer to mimic what's going on the screen). Quote: I'm tired and to foul to write more That's okay, you can't strike out with just fouls. ------------ |
Rich Romer
Member #6,734
December 2005
|
Christopher, could you go more into what you where talking about in terms of using the camera_x and camera_y method. |
count
Member #5,401
January 2005
|
Try this code and see if it does what you want. It's very simple code. You can fly with your ship out of the screen.
If something is unclear feel free to ask.
|
Rich Romer
Member #6,734
December 2005
|
ok i thought about what chris said for a while now and i think i understand the whole idea. I put it into a sample program and it seems to work. Thank you very much for posting that code snippet. ill try out that new code you put up just now and see how that goes. |
count
Member #5,401
January 2005
|
No problem. I hope it helped you.
|
|