Alice Community  

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

Reply
 
Thread Tools Display Modes
Stuck making a platform game! Please help!
Old
mcb0193
Guest
 
Status:
Posts: n/a
Unhappy Stuck making a platform game! Please help! - 04-03-2011, 06:39 PM

I am making a side-scrolling platformer, and would like to make it so that the character turns in the direction that she moves (ex: if she is facing right, and the user tells her to move left, she turns around before moving). I also want to make it so that the turn method won't be called if she is already facing in the direction of the movement. I figured I'd need to use an if/else statement for this, but I can't find a function for it.

I've uploaded the file below for reference. I will greatly appreciate any help.
Attached Files
File Type: a2w platform game.a2w (1.38 MB, 16 views)
   
Reply With Quote
Old
nickster654
Senior Member
 
Status: Offline
Posts: 180
Join Date: Feb 2011
Location: nickster12345678@gmail.com
Default 04-05-2011, 07:23 PM

Quote:
Originally Posted by mcb0193 View Post
I am making a side-scrolling platformer, and would like to make it so that the character turns in the direction that she moves (ex: if she is facing right, and the user tells her to move left, she turns around before moving). I also want to make it so that the turn method won't be called if she is already facing in the direction of the movement. I figured I'd need to use an if/else statement for this, but I can't find a function for it.

I've uploaded the file below for reference. I will greatly appreciate any help.
im kinda stumped on this one, try using some boleon variables though
   
Reply With Quote
Old
Lordelwood
Senior Member
 
Lordelwood's Avatar
 
Status: Offline
Posts: 43
Join Date: Oct 2010
Default 04-05-2011, 08:16 PM

i was thinking a variable as well, ill take a look at it and see what i can do...
   
Reply With Quote
Old
Lordelwood
Senior Member
 
Lordelwood's Avatar
 
Status: Offline
Posts: 43
Join Date: Oct 2010
Default 04-05-2011, 09:02 PM

here is a good game that i think has what your looking to do, take a look at it get some ideas about the code and such

http://www.alice.org/community/showt...highlight=dark
   
Reply With Quote
Old
Matchewawa
Member
 
Status: Offline
Posts: 32
Join Date: Feb 2011
Default 04-05-2011, 09:22 PM

Put some if's or while's in the method that you're attaching to the pressed keys (lets say left and right arrow keys). Make a variable, and make it so that while the left arrow key is pressed, 'move left' method is triggered. In this method, you make a couple of if's in a do together. Make one say, "if 'variable' == 1", which is the default variable value. Make this if turn you to face left and set the variables value to, say, 2, rather than the default 1. So now you only turn and go left that first time that you press the left arrow key. Now, in the other if, put "if 'variable' == 2" and make this if cause you just to move left and not change a variable while your at it. (This will work as long as you start facing right.) It will make you turn left and then just move left without turning. Now, basically, this means that when you are facing left, the variable is 2, and when you are facing right the variable is 1. Because of this, when you copy this code into a seperate method for the right arrow key, not only change it so that you move right rather than left, but also reverse what you are setting the variable to in the method (don't change the starting value of the variable). Otherwise, you will turn when you move right, while you are already facing right.

I'm not much of a teacher. I don't explain things very well, but I hope this will help.

Last edited by Matchewawa; 04-05-2011 at 09:27 PM.
   
Reply With Quote
Here it is
Old
Matchewawa
Member
 
Status: Offline
Posts: 32
Join Date: Feb 2011
Default Here it is - 04-05-2011, 10:32 PM

Here you go. This actually only took me like two minutes, but I've been learning a lot about Alice (self-teaching since my teacher "only knows the basics") at a very fast pace so that's probably it. I think I deleted a couple methods. The jumping and sprinting, I think, but that shouldn't be too much trouble to add back in.

P.S.
I used the same method that I explained in my previous comment to do this.

P.P.S.
Health is finally working for the player and enemies in my RPG, WOOT WOOT! Was trying to get it working for like three hours straight today!
Attached Files
File Type: a2w platform game.a2w (1.39 MB, 14 views)
   
Reply With Quote
Thanks!
Old
mcb0193
Guest
 
Status:
Posts: n/a
Default Thanks! - 04-07-2011, 07:22 AM

Thank you so much for helping me! I never really knew how to use variables, and you helped me understand them better.

However, there's only one complaint; it's that she only turns partially around if you release the key too early. This was easy to solve, though: I simply cut and pasted one of the "if" statements into a new method (turnLeft; turnRight) and put those methods into "begin" on the event. That way, she always turns fully around before moving.
   
Reply With Quote
Reply

Tags
if/else, platform game, platformer, stuck


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.