Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How can I create a simple platformer game?

New Here ,
Dec 12, 2009 Dec 12, 2009

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.

TOPICS
ActionScript
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 12, 2009 Dec 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 12, 2009 Dec 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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 12, 2009 Dec 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 12, 2009 Dec 12, 2009

Umm.. give me the answer.. im not the best with math

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 12, 2009 Dec 12, 2009
LATEST

ok ill break it does as simple as possible so you can still use this.

[history]

parallaxing is a method used to refer to the calculation of the stars.  the view of the closest stars would move the fastest and those farther in the distance moved slower.  they were all moving at the same rate but it was the reference point the mattered.

The reference point is crucial for parallaxing.

In this case your stage is the reference point .  if we said your center stage was ref that would be stageWidth*.5 and stageHeight*.5

now we have 2 stars that we want to parallax form left to right.

consider that i need my stars to move the total width of the monitor i need to calculate a percentage.

star1.x=percentage*howFarStarMustMove+startingPoint

star2.x=percentage*howFarStarMustMove+startingPoint

percentage is the mathmatical representation of how much time has lapsed.  we can fill this in with any way to represent the time.

in our case its where our mouse is.  now

0-stage.stageWidth= 100 %

so when im at 0x that is 0percent and when i am at 1000 pixels of a 1000 pixel stageWidth that is 100%.

that means if i pick a starting point for each of my stars, and they are to move a distance of 1000 pixels as well i can get them to move the proper percentage of where my mouse is. as a representation of time.

now that is moving the stars in the distance but to achieve parallaxing i need to slow them down .  so based on a value  tha tyou choose to pull for now at random to represent the distance of the stars you will modify the howFarStarMustMove by that value.

which adjusts the distance of the same exact time.  remember its not time that changes in the history story its how much it moves from the startingpoint.

so for giggles,

create star 1 and have it move 200 pixels in the same time star 2 will move 800 and you will see how 1 travels faster and 1 slower beause of the distance.  but both are relative to the same time.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines