Alice Community  

Go Back   Alice Community > Alice 2 > Works-In-Progress

Reply
 
Thread Tools Display Modes
Collision Detection!
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default Collision Detection! - 12-01-2009, 05:01 PM

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.

ALICE VERSION 2.2 NEEDED TO VIEW THIS PROGRAM --- USING ALICE 2.0 WILL PRODUCE AN ERROR
If this program produces an error for you, please use x2495iiii's version below, although you will only be able to move forward
Attached Files
File Type: a2w CollisionDetectionTest 2.0.a2w (342.9 KB, 148 views)

Last edited by Dameria; 12-04-2009 at 08:38 PM.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 12-01-2009, 05:19 PM

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.
Attached Files
File Type: a2w CollisionDetectionTest.a2w (271.0 KB, 86 views)


(')>
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 12-01-2009, 05:23 PM

Quote:
Originally Posted by x2495iiii View Post
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.
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.

Last edited by Dameria; 12-01-2009 at 05:30 PM.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 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)


(')>

Last edited by x2495iiii; 12-01-2009 at 05:40 PM.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 12-01-2009, 06:09 PM

ok, I never knew that. They seem to work on my computer for some reason.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 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?
   
Reply With Quote
Old
dubastot
Senior Member
 
dubastot's Avatar
 
Status: Offline
Posts: 661
Join Date: Apr 2009
Location: Two Steps From Hell
Default 12-01-2009, 07:37 PM

x249iiii always uses alice 2.2.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 12-01-2009, 07:38 PM

did it work for you dubastot on 2.2?
   
Reply With Quote
Old
dubastot
Senior Member
 
dubastot's Avatar
 
Status: Offline
Posts: 661
Join Date: Apr 2009
Location: Two Steps From Hell
Default 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.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Smile 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!
   
Reply With Quote
Reply

Tags
collision detection

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



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