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.


#ActualStoneMask

Posted 07 May 2013 - 03:28 PM

So I have a fairly simple game that runs with a constant framerate, and I have objects that all do their thing in the game loop.

 

My first question involves things like projectiles and like objects that are spawned by other objects. Should calling the projectile's functions be the job of the object that it belongs to? The way I have it, my player object has a projectile object called, let's say, "ball", as a member object, and the player receiving input calls the function that causes the ball to move. The ball is initialized with a constant pointer to the player's position so it knows where to spawn. I then call its move() function from the player object, so each time the player object iterates through the game loop, the ball also moves. I also have to have the player call the ball's die() function for when the player leaves a room, because otherwise the ball hangs in limbo until the next time I enter a similar room, where it continues where it left off.

 

The second question is about programming the objects' behaviors. When I want my objects to do specific actions for a set amount of time, such as traveling a set distance, or flashing for a set amount of time, I've utilized a timer variable that is exclusive to that object that counts up to a point and then calls all the functions it needs to based on what position in the timer it's in.

 

So should my game loop handle spawning objects that are dependent on other objects, or should the objects that use them? And is using timer variables clunky/is there a better way?

 

Also, how big should my game loop be before it gets ugly? Say, if I have an adventure RPG going on with the complexity of the original Legend of Zelda. Most of my questions here are about conventions, lol. What do you guys do/recommend I do, based on personal experience?


#5StoneMask

Posted 07 May 2013 - 03:28 PM

So I have a fairly simple game that runs with a constant framerate, and I have objects that all do their thing in the game loop.

 

My first question involves things like projectiles and like objects that are spawned by other objects. Should calling the projectile's functions be the job of the object that it belongs to? The way I have it, my player object has a projectile object called, let's say, "ball", as a member object, and the player receiving input calls the function that causes the ball to move. The ball is initialized with a constant pointer to the player's position so it knows where to spawn. I then call its move() function from the player object, so each time the player object iterates through the game loop, the ball also moves. I also have to have the player call the ball's die() function for when the player leaves a room, because otherwise the ball hangs in limbo until the next time I enter a similar room, where it continues where it left off.

 

The second question is about programming the objects' behaviors. When I want my objects to do specific actions for a set amount of time, such as traveling a set distance, or flashing for a set amount of time, I've utilized a timer variable that is exclusive to that object that counts up to a point and then calls all the functions it needs to based on what position in the timer it's in.

 

So should my game loop handle spawning objects that are dependent on other objects, or should the objects that use them? And is using timer variables clunky/is there a better way?

 

Also, how big should my game loop be? Say, if I have an adventure RPG going on with the complexity of the original Legend of Zelda. Most of my questions here are about conventions, lol. What do you guys do/recommend I do, based on personal experience?


#4StoneMask

Posted 07 May 2013 - 03:26 PM

So I have a fairly simple game that runs with a constant framerate, and I have objects that all do their thing in the game loop.

 

My first question involves things like projectiles and like objects that are spawned by other objects. Should calling the projectile's functions be the job of the object that it belongs to? The way I have it, my player object has a projectile object called, let's say, "ball", as a member object, and the player receiving input calls the function that causes the ball to move. The ball is initialized with a constant pointer to the player's position so it knows where to spawn. I then call its move() function from the player object, so each time the player object iterates through the game loop, the ball also moves. I also have to have the player call the ball's die() function for when the player leaves a room, because otherwise the ball hangs in limbo until the next time I enter a similar room, where it continues where it left off.

 

The second question is about programming the objects' behaviors. When I want my objects to do specific actions for a set amount of time, such as traveling a set distance, or flashing for a set amount of time, I've utilized a timer variable that is exclusive to that object that counts up to a point and then calls all the functions it needs to based on what position in the timer it's in.

 

So should my game loop handle spawning objects that are dependent on other objects, or should the objects that use them? And is using timer variables clunky/is there a better way?

 

Also, how big should my game loop be? Say, if I have a an adventure RPG going on with the complexity of the original Legend of Zelda. Most of my questions here are about conventions, lol. What do you guys do/recommend I do, based on personal experience?


#3StoneMask

Posted 07 May 2013 - 03:03 PM

So I have a fairly simple game that runs with a constant framerate, and I have objects that all do their thing in the game loop.

 

My first question involves things like projectiles and like objects that are spawned by other objects. Should calling the projectile's functions be the job of the object that it belongs to? The way I have it, my player object has a projectile object called, let's say, "ball", as a member object, and the player receiving input calls the function that causes the ball to move. The ball is initialized with a constant pointer to the player's position so it knows where to spawn. I then call its move() function from the player object, so each time the player object iterates through the game loop, the ball also moves. I also have to have the player call the ball's die() function for when the player leaves a room, because otherwise the ball hangs in limbo until the next time I enter a similar room, where it continues where it left off.

 

The second question is about programming the objects' behaviors. When I want my objects to do specific actions for a set amount of time, such as traveling a set distance, or flashing for a set amount of time, I've utilized a timer variable that is exclusive to that object that counts up to a point and then calls all the functions it needs to based on what position in the timer it's in.

 

So should my game loop handle spawning objects that are dependent on other objects, or should the objects that use them? And is using timer variables clunky/is there a better way?

 

Also, how big should my game loop be? Say, if I have a full-on adventure RPG going on with the complexity of say, the original Legend of Zelda. Most of my questions here are about conventions, lol. What do you guys do/recommend I do, based on personal experience?


#2StoneMask

Posted 07 May 2013 - 03:03 PM

So I have a fairly simple game that runs with a constant framerate, and I have objects that all do their thing in the game loop.

 

My first question involves things like projectiles and like objects that are spawned by other objects. Should calling the projectile's functions be the job of the object that it belongs to? The way I have it, my player object has a projectile object called, let's say, "ball", as a member object, and the player receiving input calls the function that causes the ball to move. The ball is initialized with a constant pointer to the player's position so it knows where to spawn. I then call its move() function from the player object, so each time the player object iterates through the game loop, the ball also moves. I also have to have the player call the ball's die() function for when the player leaves a room, because otherwise the ball hangs in limbo until the next time I enter a similar room, where it continues where it left off.

 

The second question is about programming the objects' behaviors. When I want my objects to do specific actions for a set amount of time, such as traveling a set distance, or flashing for a set amount of time, I've utilized a timer variable that is exclusive to that object that counts up to a point and then calls all the functions it needs to based on what position in the timer it's in.

 

So should my game loop handle spawning objects that are dependent on other objects, or should the objects that use them? And is using timer variables clunky/is there a better way?

 

Also, how big should my game loop be? Say, if I have a full-on adventure RPG going on with the complexity of say, the original Legend of Zelda. Most of my questions here are about conventions, lol. What do you guys do/recommend I do?


#1StoneMask

Posted 07 May 2013 - 03:00 PM

So I have a fairly simple game that runs with a constant framerate, and I have objects that all do their thing in the game loop.

 

My first question involves things like projectiles and like objects that are spawned by other objects. Should calling the projectile's functions be the job of the object that it belongs to? The way I have it, my player object has a projectile object called, let's say, "ball", as a member object, and the player receiving input calls the function that causes the ball to move. The ball is initialized with a constant pointer to the player's position so it knows where to spawn. I then call its move() function from the player object, so each time the player object iterates through the game loop, the ball also moves. I also have to have the player call the ball's die() function for when the player leaves a room, because otherwise the ball hangs in limbo until the next time I enter a similar room, where it continues where it left off.

 

The second question is about programming the objects' behaviors. When I want my objects to do specific actions for a set amount of time, such as traveling a set distance, or flashing for a set amount of time, I've utilized a timer variable that is exclusive to that object that counts up to a point and then calls all the functions it needs to based on what position in the timer it's in.

 

So should my game loop handle spawning objects that are dependent on other objects, or should the objects that use them? And is using timer variables clunky/is there a better way?

 

Also, how big should my game loop be? Say, if I have a full-on adventure RPG going on with the complexity of say, the original Legend of Zelda.


PARTNERS