2 objects moving independently at the same time
Author |
Message |
Voltron
|
Posted: Wed Jan 09, 2008 9:27 pm Post subject: 2 objects moving independently at the same time |
|
|
So, i'm making a game and having trouble with computer-controlled characters and the user controlled character moving at the same time.
Here is some pseudo-code of basically what I do:
draw a stationary character
update character position
draw the background
draw the character taking a step
update character position
draw the background
draw the character in mid step
update character position
draw the background
draw the character conpleting a step
update character position
So I have one of these for each way my character can walk (up,down,left,right), and one for each way the computer-controlled character can walk. They are all in separate procedures.
My problems are:
-only draws 1 character at a time (i tried redrawing each character with the background, but it didn't work because I have about 5 different pictures for each character)
-can only move 1 character at a time
In short, I'm having trouble moving 2 objects independently from each other and at the same time. Anyone have any advice to help me?
Extra Info:
This is a capture-the-flag type game, with 3 characters on each side. User controls 1 character, other characters will be contolled by computer. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Saad

|
Posted: Wed Jan 09, 2008 9:33 pm Post subject: RE:2 objects moving independently at the same time |
|
|
Well think about what your doing right now, I think you may be updating each character in separate loops. Have a main loop in which you update each of the players position and draw them all together. |
|
|
|
|
 |
Voltron
|
Posted: Wed Jan 09, 2008 10:13 pm Post subject: Re: 2 objects moving independently at the same time |
|
|
Well i have those procedures, and then those procedures are put into the main loop (However the procedures for the computer-controlled character will eventually be put into another procedure that oulines the AI I need to program). And I can't find a good way to update and draw them all together, because I have many pictures for each character in a series for a walking animation. Seems to me that the only way I could draw them at the same time would be to have to characters sliding instead of walking. |
|
|
|
|
 |
|
|