Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Generates error...
Old
Awesomeness
Guest
 
Status:
Posts: n/a
Default Generates error... - 09-28-2010, 04:49 PM

This is the product of 15 minutes of tinkering with Alice. (This is the first thing I've ever made.)

It's an arrow-key controlled T-Rex with semi-realistic walking. At first you had to press keys over and over again to move, but I've come very close to fixing that. So, turning works fine, but when you press forward, it will work until you let go of up, where it will give you an angry queen error thingy.

What's wrong?
Attached Files
File Type: a2w TRex.a2w (1.01 MB, 7 views)
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 09-28-2010, 05:43 PM

This may seem complicated, it is even a little complicated to me, but I had to use a dangerous thing called recursion and I used your boolean variable Walking. I also had to have two events for the same button because when there is an infinite loop in the "Beginning" part of the event, then the "Ending" part of the event will never happen unless you have two of them.

Also I added an event so that if you click the Spacebar, you can look at the TRex from the back point of view at all times, but only if you click Spacebar.
Attached Files
File Type: a2w TRex (1).a2w (1.01 MB, 12 views)


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
Awesomeness
Guest
 
Status:
Posts: n/a
Default 09-28-2010, 05:51 PM

Thanks. By the way, I know what recursion is. I'm new to Alice but I'm a decent programmer in three languages. However, I have a bunch questions regarding Alice:

What caused the error? Is it a problem on my part or is it a problem with Alice? And why do you have to use two separate events? (How do you even get to changing values and stuff when you press a key? I only see methods in the drop down menu.) By the way, wouldn't an of statement be much better than a while loop since if you use a while loop you get deeper and deeper in multiple while loops?
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 09-28-2010, 05:58 PM

Quote:
Originally Posted by Awesomeness View Post
Thanks. By the way, I know what recursion is. I'm new to Alice but I'm a decent programmer in three languages. However, I have a bunch questions regarding Alice:

What caused the error? Is it a problem on my part or is it a problem with Alice? And why do you have to use two separate events? (How do you even get to changing values and stuff when you press a key? I only see methods in the drop down menu.) By the way, wouldn't an of statement be much better than a while loop since if you use a while loop you get deeper and deeper in multiple while loops?
The error was caused by the walk method in the "During" part of the event, which you can never do with an infinite loop (it is a bug in Alice that they have not fixed). It is basically trying to stop your method mid code, so it is trying to stop the TRex from walking while it is still putting its foot forward. For this program, it wouldn't matter that there would be multiple while loops, I just did it as a quick example, but in larger programs it would make a big difference in terms of lag, so yes you would have to fix that.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
Awesomeness
Guest
 
Status:
Posts: n/a
Default 09-28-2010, 06:04 PM

What about those other questions? By the way, I meant 'if' instead of 'of'. And how do you make an object face away from another?

By the way, I love your paint world.

Last edited by Awesomeness; 09-28-2010 at 06:46 PM. Reason: 1 more question
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 09-28-2010, 07:07 PM

And no, actually, the while loop does not overlap with continuing while loops, I am remembering now, because once the "Walking" boolean is turned false, the while loop stops altogether, it does not continue on. I think I answered all of your questions, what else do you want to ask?

And thank you, I thought the Alice Paint was a pretty cool idea too.

Oh yeah, I don't really know what you mean by make an object turn away from another object, but if you mean what I think you mean, try making the first object "turn to face" the second object, and then right after that turn the first object right (or left) 1/2 revolutions. Does that solve your problem?


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
Awesomeness
Guest
 
Status:
Posts: n/a
Default 09-28-2010, 07:20 PM

Yeah, I tried that... Look what it gives me.
Attached Files
File Type: a2w TRex.a2w (1.43 MB, 2 views)
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 09-28-2010, 07:40 PM

I tried to fix it but it just got messed up, so I gave up. Right now, it will check to see if the other dinosaur is near the TRex even when it is dead, maybe you could make a boolean called "isAlive" set to true, and when it gets eaten you change to false. Then put "isAlive" in the parameter of the While statement. Then in the method to turn the dinosaur you can put a method to move the other dinosaur 1 meter forward every 0.5 second (style abruptly) after you turn the dinosaur away from the TRex, this will cause a running away effect. I tried to make it more complicated but things started to mess up, so tell me if what I have just said works at least.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
Awesomeness
Guest
 
Status:
Posts: n/a
Default 09-28-2010, 08:23 PM

I'm not sure what you mean... The ability to turn the dinosaur away is what I need; I know how to make it run away once I get that.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 09-28-2010, 08:34 PM

Yes, but it is because you are constantly turning the dinosaur every split second is the reason why it looks so buggy. Try adding that move forward code at 0.5 duration and see if it still looks bad.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Reply

Tags
trex walk error help


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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.