Jump to content

Incremental Increase in Velocity


jw405
 Share

Recommended Posts

Hi everyone,

 

I'm developing a side scrolling mobile game for fun in my spare time. The objective is to direct a flying bee, who moves continuously to the right, between sets of honeycombs. If the player touches the honeycombs, they lose. 

 

It's effectively a replica of flappy bird. 

 

I'm trying to implement an incremental increase in velocity so the game gets harder the longer you play.

 

- I've created a group (honeycombs) and added physics to the group

- Created 20 honeycombs

- Got the first dead honeycomb of our group

- Set the new position of the honeycomb

- Added velocity to the honeycombs to make it move left (creates the illusion of the bee flying):

 

pipe.body.velocity.x = -200;

 

- Kill the honeycombs when they're no longer visible

- Picked where the hole will be

- Added six honeycombs

- Run function to add honeycombs every 1.5 seconds

 

I'm aware I could have two different game states (easy and hard) with different velocities but I'd rather have it increase over time.

 

Any help would be hugely appreciated!

 

Thanks!

Link to comment
Share on other sites

I think you've included too much unrelated information (stuff not necessary for understanding your issue), may I suggest you describe what you tried (eg. have you tried varying the velocity you set on the barriers) and the issues you encountered and/or why you weren't happy with the results?

 

- Added velocity to the honeycombs to make it move left (creates the illusion of the bee flying):

Real world physics has no privileged reference frame. Moving all the obstacles is equivalent to moving the player the other direction (comment is a reaction to your use of the word "illusion", applying velocity to the non-player objects is not an really an illusion at all)

 

- Run function to add honeycombs every 1.5 seconds

Why not add (or even recycle) obstacles when you kill one for being offscreen? I have a hunch this will ultimately be easier (but I could be wrong)
Link to comment
Share on other sites

I think you've included too much superfluous information, may I suggest you describe what you tried (eg. have you tried varying the velocity you set on the barriers) and the issues you encountered or why you weren't happy with the results?

 

Real world physics has no privileged reference frame. Moving obstacles is equivalent to moving the player the other direction (comment is a reaction to your use of the word "illusion", applying velocity to the non-player objects is not an really an illusion at all)

 

Why not add (or even recycle) obstacles when you kill one for being offscreen?

 

Hi chg,

 

I thought I'd given too much unnecessary information. I have a working game and everything is functional. I just wanted to outline how everything was working.

 

I want to implement a loop that increases the velocity of the honeycombs over time.

 

This is how the movement of the honeycombs is currently set up:

 

honeycomb.body.velocity.= -200;

 

Here's the code if I'm still not making any sense:

 

http://pastebin.com/GzNYmX0j

Link to comment
Share on other sites

Have you tried varying the what you set for each "honeycomb.body.velocity.x" using an equation involving time? If you want the individual objects to change speed as well (as if the player is accelerating) you can also try tweaking "honeycomb.body.acceleration.x" to have some small negative value.

If using the latter, you will possibly want to remember the equation from highschool physics equation (from Newton's equations of motion): v = u + a*t which gives the current velocity (v) of a body from it's starting velocity (u) given some constant acceleration (a) and the time elapsed (t)

Link to comment
Share on other sites

Thanks chg

 

Have you tried varying the what you set for each "honeycomb.body.velocity.x" using an equation involving time? If you want the individual objects to change speed as well (as if the player is accelerating) you can also try tweaking "honeycomb.body.acceleration.x" to have some small negative value.

If using the latter, you will possibly want to remember the equation from highschool physics equation (from Newton's equations of motion): v = u + a*t which gives the current velocity (v) of a body from it's starting velocity (u) given some constant acceleration (a) and the time elapsed (t)

 

I hadn't thought about setting a negative acceleration on the player, I'll give it a go and see if I can get it working.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...