Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   Works-In-Progress (http://www.alice.org/community/forumdisplay.php?f=14)
-   -   Collision Detection! (http://www.alice.org/community/showthread.php?t=3491)

Dameria 12-01-2009 05:01 PM

Collision Detection!
 
1 Attachment(s)
I have been hearing a lot about collision detection and how it is so hard in Alice to make, so I decided to give it a try, and so far I think I have one part down really well in this program.

You move with arrow keys, and for now, if you try to move through the blue wall it will not let you, but as soon as you go to the side of the wall it will let you pass, try it yourself, hope you like it.

I am planning to also implement methods where you cannot go backwards through the wall, or through the sides of the wall, but I have no time right now. Tell me what you think please.

[b]ALICE VERSION 2.2 NEEDED TO VIEW THIS PROGRAM --- USING ALICE 2.0 WILL PRODUCE AN ERROR[/b]
[i]If this program produces an error for you, please use x2495iiii's version below, although you will only be able to move forward[/i]

x2495iiii 12-01-2009 05:19 PM

1 Attachment(s)
Not a bad example. There was an error which generated after I let go of the up key, so I fixed that. Here you go.

Dameria 12-01-2009 05:23 PM

[QUOTE=x2495iiii;13775]Not a bad example. There was an error which generated after I let go of the up key, so I fixed that. Here you go.[/QUOTE]

I'm sorry, but when I tried your program it would not even let me go backwards or to the right, and mine works fine on my computer. Also on yours it goes significantly slower, I don't know what you did. If more people get errors when they let go of the up arrow key, then I will see whats wrong and try to fix it, but yours is not working for me.

Try downloading mine again and try it again. Maybe it downloaded wrong or something, and if it keeps happening then I don't know what would be wrong.

x2495iiii 12-01-2009 05:33 PM

Oh yeah. I was hoping you'd see what I did the the forward method and reproduce it when you made the other three directions' collision detection checkers.

You see, the error (which will probably happen to everyone) comes from ending an animation from inside an event by letting go of a key. For some reason, though, it works fine if you use booleans, like upHeld, to trigger and end the animation. For your forward moving method, there was a command for the cube to move for 100000 seconds (or something similar). This is the animation that was ended from inside the event, generating the error. I replaced the method calls in the events with boolean variable changes, which allows you to make the other three directions error-free as well, once they are made. Until then, all it will do is change the respective variables to true while held, and false when released.

Take a look at the moveForward method to see what I mean.

(EDIT: I re-dowloaded your to be sure, but yes, the error is still there. It happens to all "While a key is pressed" events which cut long animations short.)

(EDIT again: You can speed up the motion by changing the meters value in the moveForward method from .05 to something larger, like .1)

Dameria 12-01-2009 06:09 PM

ok, I never knew that. They seem to work on my computer for some reason.

Dameria 12-01-2009 06:36 PM

Hey, I think I found out your problem. Are you using Alice 2.0? I tried my program on 2.0 and the same error occurred when I tried it there.

I think they fixed that error for Alice 2.2. When using 2.2 I do not get those errors like in 2.0. Also, in 2.2 I cannot do While(true) and put a variable in the true part, and you can in 2.0, that is another reason why I think you might be using 2.0 instead of 2.2

Which version are you using?

dubastot 12-01-2009 07:37 PM

x249iiii always uses alice 2.2.:D

Dameria 12-01-2009 07:38 PM

did it work for you dubastot on 2.2?

dubastot 12-01-2009 07:42 PM

It works fine for me. That is some pretty ingenious coding you have there. I know how to use alice, but I am definitely not creative enough to think of all these great ideas.

Dameria 12-01-2009 07:49 PM

I'm glad to hear its not a problem that everyone is having, and to hear a person that has been hear longer than I have saying that my coding is good is a really good compliment! Thanks!


All times are GMT -5. The time now is 04:34 PM.

Copyright ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.