Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Collition detection with speed
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TokenHerbz




PostPosted: 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 Smile

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
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Wed Apr 12, 2006 5:38 pm   Post subject: (No subject)

It would help if you defined i.
TokenHerbz




PostPosted: Wed Apr 12, 2006 5:59 pm   Post subject: (No subject)

meaning?
cool dude




PostPosted: 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!
Mazer




PostPosted: 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.
Cervantes




PostPosted: Wed Apr 12, 2006 7:07 pm   Post subject: (No subject)

Try this.
TokenHerbz




PostPosted: 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...
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: