Collition detection with speed
Author |
Message |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: Wed Apr 12, 2006 4:45 pm Post subject: Collition detection with speed |
|
|
So collition detection is simple enough, but in programs you may have higher speeds thus collition is rendered useless.. Example if my SMALL astroid is going max speed left, and im the space ship going max speed RIGHT, we usually don't collide cause we hop over eachother... To solve this problem i tryed making a small example. I can't figure it out, thus i call on the pro's to assist in this...
Here we have an example to which we show that it HOPS over.
code: |
View.Set ("offscreenonly")
var x, y : int := 0
var wx, wy : int := 0
wx := 243
loop
cls
x += 10
if x + i >= wx and x + i <= wx + 5 then
put "A HA!"
Input.Pause
end if
drawfillbox (x, y, x + 5, maxy, black)
drawfillbox (wx, wy, wx + 5, maxy, brightred)
View.Update
delay (20)
end loop
|
well here i figured, maybe if i add a couter up to the max speed, it would read the spots that it hopes too... But run this and see what happends, We collide, which is GOOD, but, we dont SEE this.., problem is i want it to SHOW the collition, so maybe i should add the pictures with the i variable: But that dosn't work either, and im fusterated at what should be rather simple... anyways, make this work please
code: |
View.Set ("offscreenonly")
var x, y : int := 0
var wx, wy : int := 0
wx := 243
loop
cls
x += 10
for i : 1 .. 10
if x + i >= wx and x + i <= wx + 5 then
drawfillbox (x + i, y, (x + i) + 5, maxy, black)
put "A HA!"
Input.Pause
end if
end for
drawfillbox (x, y, x + 5, maxy, black)
drawfillbox (wx, wy, wx + 5, maxy, brightred)
View.Update
delay (20)
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Mazer
![](http://compsci.ca/v3/uploads/user_avatars/1323750815476d9f446d80c.png)
|
Posted: Wed Apr 12, 2006 5:38 pm Post subject: (No subject) |
|
|
It would help if you defined i. |
|
|
|
|
![](images/spacer.gif) |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: Wed Apr 12, 2006 5:59 pm Post subject: (No subject) |
|
|
meaning? |
|
|
|
|
![](images/spacer.gif) |
cool dude
![](http://www.taylorstrategicmarketing.com/images/king.jpg)
|
Posted: Wed Apr 12, 2006 6:31 pm Post subject: (No subject) |
|
|
meaning if u read the rules u would see that the code has to run! |
|
|
|
|
![](images/spacer.gif) |
Mazer
![](http://compsci.ca/v3/uploads/user_avatars/1323750815476d9f446d80c.png)
|
Posted: Wed Apr 12, 2006 6:58 pm Post subject: (No subject) |
|
|
TokenHerbz wrote: meaning?
You told us to run your code (which, BTW, many people don't like to do: I don't have Turing on this machine). In your code, you use the variable called i, but I can't see you defining it and giving it a value anywhere. Now, aside from the fact that I wouldn't be able to run your code if I wanted to, I don't really know exactly what is going on unless I start making assumptions. |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Wed Apr 12, 2006 7:07 pm Post subject: (No subject) |
|
|
Try this. |
|
|
|
|
![](images/spacer.gif) |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: Thu Apr 13, 2006 3:37 pm Post subject: (No subject) |
|
|
ok i got it to work now, the problem i had was 1) View.Update not displayed in the for loop. 2) exit after collition in for loop... |
|
|
|
|
![](images/spacer.gif) |
|
|