Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Moving object on a path


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 Tonious   Members   -  Reputation: 104

Like
0Likes
Like

Posted 01 August 2012 - 01:48 PM

I want my objects to move along a path, reach a coord then move back again. 3D.
Posted Image

I have the objects (balls in my case) in its own class, rendering the movement happens in the renderscene method in the main.cpp.

I want each ball I create to be able to set up its own path in the game.

At the moment I created a method that allows all balls to move, but I need a method for each ball to have its own path.

void Balls::Move() {
if(end){
position.x += 2;
if(position.x > 2400) {
reversed = false;
}
}

if(!end){
position.x -= 2;
if(position.x < -2400) {
reversed = true;
}
}
}

My code is in the pastebin link - http://pastebin.com/wVVy7fgw
The DrawBalls() method is called in the renderscene method.

Edited by Tonious, 01 August 2012 - 02:06 PM.


Sponsor:

#2 dpadam450   Members   -  Reputation: 934

Like
1Likes
Like

Posted 01 August 2012 - 03:13 PM

position.x += direction.x;

if(direction > value)
{
direction.x *= -1;
}

?




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