Jump to content

  • Log In with Google      Sign In   
  • Create Account


Mario style Side scroller in allegro


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Aneesh   Members   -  Reputation: 116

Like
0Likes
Like

Posted 17 January 2013 - 08:54 AM

Hi all ,

Im new to game programming and just finished my first side shooter using Allegro . 

Now i want to goto something more complex like a mario style side scroller . 

How do I actually go about it   ? In the game I implemented , all the characters and sprites were in one fixed window which didnt move . How do I do a dynammically moving screen in which sprites come as the player moves forward. Do I simply check the x-axis value and spawn characters based on it or is there some other more elegant method ? 

Any help would be appreciated 

 



Sponsor:

#2 DekuTree64   Members   -  Reputation: 984

Like
0Likes
Like

Posted 17 January 2013 - 12:13 PM

You need to add a camera position. Just an x/y position, which you subtract from the position of sprites and backgrounds before drawing them.

 

In your current game, if you have a sprite at position (50, 100), it will be drawn right there on the screen. But if the camera position is, say, (30, 0), then you subtract it from the sprite position before drawing, thus drawing the sprite at position (20, 100). That is, moved left on the screen, because the camera is moved right in the world. Then you can place enemies anywhere you want in the world, far away from position 0, and the player can walk out there and find them.

 

Normally you want the camera to follow the player, with the player centered on the screen, so set it to (playerX - halfScreenWidth, playerY - halfScreenY). Although you might check if the results are negative, and if so, set to 0. Depends on whether your background drawing code can deal with negative positions.

 

Are you currently using a tile based background system, or just blitting a bitmap to the screen before drawing sprites?

 

Oh, and here's a little Mario style game I whipped up in a 2 day coding frenzy for a little competition a few years ago. It uses Allegro, but I wrote my own drawing code just cause I like to do that instead of using library blit functions. But the usage of them should be pretty much the same.

http://deku.rydia.net/program/oiram.zip

http://deku.rydia.net/program/oiram-source.zip


Edited by DekuTree64, 17 January 2013 - 12:16 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS