I'm not sure I understand. Can you draw up an example?
-
tr1p1ea
- Cemetech Expert (Posts: 1773)
- 02 Jun 2014 05:52:03 pm
- Last edited by tr1p1ea on 02 Jun 2014 05:56:30 pm; edited 1 time in total
Well it tests for collisions between rectangular coordinates so if you have say a sprite that is:
X = 10
Y = 10
W = 8
H = 8
And you wanted to test if this 'rectangle' overlaps with an enemy sprite at:
X = 15
Y = 15
W = 8
H = 8
Like so:
Then you can use the function to check:
real(4,6,1,10,10,8,8,15,15,8,8
In which case they do collide so the result will be a list:
{1,1,0
{1 = collision found
1 = number of collisions found
0 = index of collision passed with real( statement
And since there was only 1 set of coordinates passed the first index that collided is 0 (the red square).
Another case:
Rectangles at:
X = 10
Y = 10
W = 8
H = 8
Tested against others where:
X = 15
Y = 15
W = 8
H = 8
X = 48
Y = 32
W = 16
H = 16
X = 8
Y = 0
W = 64
H = 16
Like so:
The call would be: real(4,6,3,10,10,8,8,15,15,8,8,48,32,16,16,8,0,64,16
And the result would be:
{1,2,0,2
{1 = collision found (would be 0 if no collisions occured)
2 = number of collisions found (green and red)
0 = collision with index 0 (red)
2 = collision with index 2 (green)
Index 1 is the orange square for which there was no collision.
Does this help?
X = 10
Y = 10
W = 8
H = 8
And you wanted to test if this 'rectangle' overlaps with an enemy sprite at:
X = 15
Y = 15
W = 8
H = 8
Like so:
Then you can use the function to check:
real(4,6,1,10,10,8,8,15,15,8,8
In which case they do collide so the result will be a list:
{1,1,0
{1 = collision found
1 = number of collisions found
0 = index of collision passed with real( statement
And since there was only 1 set of coordinates passed the first index that collided is 0 (the red square).
Another case:
Rectangles at:
X = 10
Y = 10
W = 8
H = 8
Tested against others where:
X = 15
Y = 15
W = 8
H = 8
X = 48
Y = 32
W = 16
H = 16
X = 8
Y = 0
W = 64
H = 16
Like so:
The call would be: real(4,6,3,10,10,8,8,15,15,8,8,48,32,16,16,8,0,64,16
And the result would be:
{1,2,0,2
{1 = collision found (would be 0 if no collisions occured)
2 = number of collisions found (green and red)
0 = collision with index 0 (red)
2 = collision with index 2 (green)
Index 1 is the orange square for which there was no collision.
Does this help?
That does help--thought red/green are not the best choices to use to demonstrate something to someone who is red/green colorblind . Seems neat, especially being able to specific any rectangles.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
» Go to Registration page
» Goto page Previous 1, 2, 3 ... 16, 17, 18
» View previous topic :: View next topic
» View previous topic :: View next topic
Page 18 of 18
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Advertisement