Alice Community  

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

Reply
 
Thread Tools Display Modes
a few questions
Old
robert
Guest
 
Status:
Posts: n/a
Default a few questions - 04-18-2007, 04:10 AM

I'm having a hard time figuring out how to do these, and the Programming in Alice book that I have I don't think explicitly answers them (the collision detection one perhaps in a roundabout way, but not so much on the sound one that I can see):

1) I have music playing in the background during the menu, but since it is dictated by user when the menu is exited, I can't set a duration for the audio file. I was wondering if there is a way to stop a source from playing the sound once you transition scenes? Tried having the same source play another sound file (in the hope that I could use a sound file with silence) but all it did was try and play both.

2) There is a fight scene in which the player controls the player, I can set it up where if the player is within distance of the walls, he steps away from it, but realistically, I'd like it just to disable the PJ3.walkForward method if at all possible when he's within distance of the edge.

3) in the combat part, I have it set up for the space bar to do a nested if statement of punch 1, punch 2, and kick. I would like for when he does the actions, for it to push the target back. I am unaware exactly how I would do this without making it where when the character is within distance of the target, it moves. And also, how do you ensure that it moves the target in front of it?

thanks in advance for any assistance you can give
   
Reply With Quote
Some Suggestions
Old
DrJim
Guest
 
Status:
Posts: n/a
Default Some Suggestions - 04-18-2007, 12:05 PM

For turning sound on and off, use a while event and then switch the test condition on and off as needed - see example.

For collision detection, I suggest you do a search of the forum - there are lots of examples. For walls specifically, I suggest you use the "distance in front of" (or to the right/left/behind) tests, since they do the test for the entire bounding box of the object.

Good luck.
Attached Files
File Type: a2w stop_sound.a2w (743.9 KB, 393 views)
   
Reply With Quote
Old
robert
Guest
 
Status:
Posts: n/a
Default 04-18-2007, 06:22 PM

thank you, your sound stopping worked perfectly.

As far as question #3, is that included in the collision detecting in regards to "in front/behind/left/right of"?
   
Reply With Quote
Old
DrJim
Guest
 
Status:
Posts: n/a
Default 04-18-2007, 09:55 PM

I'm afraid I didn't really understand what you were trying to do in #3 well enough to make a suggestion. It looked to me like you could get what you described just with a "do together" block for the kick and the backward move - but I'm probably missing something.

My guess is that you would be better off just using the "distance to (center)" function for collision detection for that case - but would have to see more of what you are trying to do to say for sure. It might be worth trying both ways (center and bounding box) - it's not a hard change (a real advantage of Alice ) and that would let you see which way actually looks more realistic.
   
Reply With Quote
Old
robert
Guest
 
Status:
Posts: n/a
Default 04-19-2007, 02:54 PM

enclosed is a zip of the "export code for printing" or something similar to that in the menu. Of particular importance is World.Scene5() and PJ3.Combat().

I'm not sure exactly where my code is messing up, but I imagine it has something to do with the loop infinite times block? When it runs, the mushrooms follow the lead character around, and if you do the combat() sequence, it runs through it fine graphically (the combat motions sequence great), but apparently it doesn't decrement as they remain up at all times.

Could you possibly tell me where I'm going wrong on this? Thanks in advance with any help you can give
Attached Files
File Type: zip Rise Above.zip (9.8 KB, 362 views)
   
Reply With Quote
Old
DrJim
Guest
 
Status:
Posts: n/a
Default 04-20-2007, 09:53 AM

Looks like a very ambitious and nice game project - I particularly like the way you handled the "youth" and "mature" versions of the game. Unfortunately, there is also much too much code for me to look at in any detail - but I will offer a couple more suggestions.

I think your basic problem is that you are never actually "hitting" the mushrooms. You have the distance test set to 0.02 meters, which is quite close - especially when you consider you are comparing center to center distance of objects (not the object and all of it's sub-objects). In one case I noticed, you were just moving a leg and then testing the whole object again - just moving the leg won't have any effect on that compare. Easy test - make the test distance 1 or 2 meters and see what happens.

Second, I notice you are doing a lot of movement and then compare steps. This test only looks at the setup after the movement is done - you can go right though an object and still not record a "hit". A better way is to use a while loop and a "distance away from is greater than" test (see section 7-2 in the Dunn text, if you have it, for an example ).

Hope this helps. Please post your game when you get it finished - it looks like it will be very interesting.
   
Reply With Quote
Reply

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