Skip to main content
Known Participant
December 12, 2009
Question

How can I create a simple platformer game?

  • December 12, 2009
  • 1 reply
  • 1529 views

I want to create a platformer game, but there is no tutorials that actually tell you how.

What I dont understand is:


- How the level changes when you get to a certain point

- How to do collision with walls

- How to make the player move

I want to write this in AS3.

This topic has been closed for replies.

1 reply

December 12, 2009

The difficulty of these questions is that there are many ways to do any of these, so without more information the answers will be vague.

Starting with this.  if a score is higher than a specific amount you can increase the difficulty or increase the game play speed, adjusting a level does not just mean it has to state level 2 or stop the whole game and go into another world.

How can this be achieved?  to answer keep track of what the goal of the game is to be.  is it a fps?  is it a strategy.  Hold onto this value in your class and wait for this to have been fulfilled as a requirement.

Bouncing off walls.  there are many many ways to achieve this.  Some are for optimal purposes to choose one method over another while some are simple and just right for the amount of calculations your program requires.  The easiest is to figure out where the x and y of a clip is, and check to see if its where another clip is.  the secondary clip might be a wall or another collision point like another ship.

if ship 1 was a rectangle and its registration point was in its center, then ship1.x+ship1.width*.5 will inform me where the front of his ship is.the same will go for height.  if this value will be greater than another point i consider to be a wall, then a collision will be detected. 

the best built in flash method is hitTest.  but this is very weak for intense games and is processor intensive.

To make a player move,.. well this can be done mose easily with the arrow keys and an enterFrame or timer.

and add to its x and y a specific amount that is a constant for each key.  Key.UP_ARROW  == -.5  Key.DOWN_ARROW = .5   etc,,  and keep adding these to your player.

These are the rough basics when attempting for the first time.  when you get comfortable you may wish to seek out physics and more mathmatical solutions to make these more realistic.  addition of matrices or vectors will be helpful.  Trig will be great for bouncing off walls, and geometry and trig will both supply proper ways for collision detection.  but dont feel overwhelmed.  Get started the same way everyone else did.

Cheers

Known Participant
December 12, 2009

Okay that helped alot, thanks.

But I have another question, how can I make the stage follow the player? Like in every platformer game when the player goes on the left or right side, the stage keeps following it. (Parallax scrolling)

December 12, 2009

well for parallax scrolling we can do 1 of 2 things.

do you want me to give you the answer or do you think you are good enough at percentages in math that if i guide you , you might be able to figure it out?