Hello.
I´m trying to do a simple task with tables.
I have a table with sinus values.
Then I assign a value of that table to a group o chars to can move them.
Until here it,s all ok but along I´m through the table there are a moment it finish and i cant restart it correctly.
I suppose that I have to use the WRAP command but i dont understat it very well.
Any help?
Thanks.
WRAP command
Re: WRAP command
How about a little example:
Say you have an 320x200 screen and want your game object to be able wrap out from other side of the screen, when going off the screen boundaries:
You can just do something like this to your game objects x and y coordinates:
We really don't need to use Wrap() function at all, a little bit of math gives us:
Does this example help at all? 
Say you have an 320x200 screen and want your game object to be able wrap out from other side of the screen, when going off the screen boundaries:
You can just do something like this to your game objects x and y coordinates:
Code: Select all
x = x + dx ; update x position
x = Wrap(x, 0, 320) ; keep within screen boundaries, wrap to other side if necessary
y = y + dy ; update y position
y = Wrap(y, 0, 200) ; keep within screen boundaries, wrap to other side if necessary
Code: Select all
x = x + dx ; update x position
x = (x + 320) % 320 ; keep within screen boundaries, wrap to other side if necessary
y = y + dy ; update y position
y = (y + 200) % 200 ; keep within screen boundaries, wrap to other side if necessary
Re: WRAP command
Thanks very much.
Im going tu rewrite my rutine but you explained it perfectly.
Thanks again jalih.
Im going tu rewrite my rutine but you explained it perfectly.
Thanks again jalih.