Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Old Position

Author
Message
BeastDeath
13
Years of Service
User Offline
Joined: 7th Jul 2011
Location:
Posted: 1st Nov 2011 00:52
Hello everyone (sorry for such a soon post) I'm struggling to get my head around how I would get the old positions in this code, how would I do it? My player never moves everything else does, so I need to get all the previous positions of everything else before they moved exactly before, not between each pressed on the keyboard

Here is example code:

Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 1st Nov 2011 02:02 Edited at: 1st Nov 2011 02:03
use sprite x(sprite number) and sprite y(sprite number) after changing the .x and .y data of the object.

EG.


Also, render can go straight in at the end of update world, it will work the same.

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 1st Nov 2011 02:06 Edited at: 1st Nov 2011 02:10
This would be all about where in your code you store the x and y values. Take this code for instance:

This stores the old x value so it's really up to you to decide when and how often you want to store that old x value.

Hope this helps

Edit: Forgot to mention that it does depend on when you change the x and y values. You'll need to collect the 'old' x and y values before you change them.

nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 1st Nov 2011 10:27
Hodgey is right. My personal suggestion is to use it like this:



As this will save 4 lines of code and perform the update JUST before repositioning.

BeastDeath
13
Years of Service
User Offline
Joined: 7th Jul 2011
Location:
Posted: 1st Nov 2011 12:47 Edited at: 1st Nov 2011 18:58
Edit: Fixed my problem, thanks

Login to post a reply

Server time is: 2024-11-22 12:01:09
Your offset time is: 2024-11-22 12:01:09