Hi Thomas, just a quick one for now as I'm super sleepy.

Yes, this is essentially correct but way over simplified.

What I mean is this:

        while (running)
        {

                // Update player movement and position
                UpdatePosition();

// Get input

getPlayerInput();

// process physics

processPhysics();

                // Update collision detection
                UpdateCollision();

                // Sleep for x MS
                Sleep(time);
        }
If you notice, the first time through the loop, the entities are being rendered 
immediately. Every time after that they are actually being rendered after the 
collision detection is processed. So the input is taken into account and the 
physics are processed, then the collision detection. After that is done then 
the entities are rendered in their new positions. So you can keep the movement 
methods separate and still have the benefit of collision detection preventing 
you from going into walls and such.

Hope this makes sense and have a great night! Yawn!… :)

Smiles,

Cara :)
---
View my Online Portfolio at:

http://www.onemodelplace.com/CaraQuinn

Follow me on Twitter!

https://twitter.com/ModelCara

On Aug 18, 2013, at 7:03 PM, Thomas Ward <[email protected]> wrote:

Hi Cara,

Interesting. I guess this is up to personal style, but as I understand
it you would separate the movement functions from the collision
detection function like this.

        while (running)
        {

                // Update player movement and position
                UpdatePosition();

                // Update collision detection
                UpdateCollision();

                // Sleep for x MS
                Sleep(time);
        }

Is this an accurate assessment of how you would write your main loop
and separate collision detection and movement?

Cheers!


On 8/18/13, Cara Quinn <[email protected]> wrote:
> Hi again John,
> 
> Just as a follow-up to my own note here, I thought I'd add that I personally
> prefer not to have collision detection called from within any movement
> code.
> 
> I think it's good practice to have your methods only doing what they say
> they will. I.E. movement only moves. Collision detection only detects
> collisions.
> 
> this way if you want to move your player for some other reason than a
> traditional game movement, you can always call your player's movement
> methods and not need to worry about some other method getting called
> somewhere to get in the way of what you'd like to do. Does this make sense?
> 
> Your collision detection method can either report back which objects
> collided, or simply call the appropriate methods on those objects that
> collided with each other.
> 
> For example, if two objects collide, then call the touch methods on each of
> those objects. That way each object will do what it is supposed to when it
> is touched by another object.
> 
> Hope this helps!
> 
> Have a great day!
> 
> Cara :)---
> View my Online Portfolio at:
> 
> http://www.onemodelplace.com/CaraQuinn
> 
> Follow me on Twitter!
> 
> https://twitter.com/ModelCara
> 

---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to [email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the list,
please send E-mail to [email protected].


---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to [email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the list,
please send E-mail to [email protected].

Reply via email to