This site requires JavaScript, please enable it in your browser!
Greenfoot back
Aura_
Aura_ wrote ...

2018/2/23

Midterm project - wanting to make a rhythm game of sorts

Aura_ Aura_

2018/2/23

#
I have a midterm due in two weeks for a software development and game design class and want to make some sort of rhythm game similar to the one in this video: https://www.youtube.com/watch?v=MFLnSfrDD4w (It's scattered throughout the fight) Basically, the player is in the middle. They turn to block off enemies to the beat (or not, if I can't get it to time correctly). If they aren't facing the enemy when it reaches them, they take damage and the enemy disappears. The enemies spawn from the four directions - north, east, south, and west, and go directly at the player. In progression of what I think is "easier" to "harder: 1) Get the arrows working and going at the player (game fundamentals) 2) Get the arrows to spawn at certain points at certain times instead of randomly 3) Get the arrows to change speeds to throw off the player 4) Make the arrows eventually start changing pattern (going from west to south halfway to the player, for example) (this is probably really hard to do, so if I can't get it done in time that's fine) If someone could post some code that could help me with this, that would be great! (And maybe explain it, too, so I know what's going on.) My idea is to have some sort of counter that counts up every half or quarter-second, and when it hits certain numbers (it goes up indefinitely) it spawns the arrows? That seems like it would take forever to individually code the counters for the arrows, though. Thank you!
Vercility Vercility

2018/2/23

#
I'm just gonna asume you know the basics of java else this would be pretty pointless. U can check arrow keys with
Greenfoot.isKeyDown("up") /or left/right/down
U can turn your actor with
actor.setRotation(AngleInDegrees) // 0-360°
Movement :
actor.move(units) // units in integer format e.g 5, 20
Changing their speed randomly is a bit more complicated so we'll handle that later Regarding 4 : Are they just supposed to change direction or change which direction they come from? e.g east -> middle to west -> middle or east->South? Regardless, this isn't harder than the previous tasks
My idea is to have some sort of counter that counts up every half or quarter-second, and when it hits certain numbers (it goes up indefinitely) it spawns the arrows? That seems like it would take forever to individually code the counters for the arrows, though.
No. The problem is just that you cant exactly set the counter time because greenfoot has no wait method for seconds, you can just run a while loop that increments an integer and when it hits a certain value you reset it and spawn an arrow (randomly)
Yehuda Yehuda

2018/2/23

#
@Vercility It could be that you understood better, but, if arrows are supposed to be "going at the player" then I wouldn't think they should be programmed to move only with user input (arrow keys). I might sound hypocritical as I haven't posted any code at all, but I don't see what the (Aura_'s) problem is. It all sounds like a very nice idea, where's the error in the program?
Vercility Vercility

2018/2/23

#
Yehuda wrote...
@Vercility It could be that you understood better, but, if arrows are supposed to be "going at the player" then I wouldn't think they should be programmed to move only with user input (arrow keys). I might sound hypocritical as I haven't posted any code at all, but I don't see what the (Aura_'s) problem is. It all sounds like a very nice idea, where's the error in the program?
thats to move the shield of the actor
Yehuda Yehuda

2018/2/23

#
Oh. I haven't seen the game and I don't really know what we're talking about (I'm unable to go to the supplied link).
danpost danpost

2018/2/23

#
Timing of arrows can be done using one int field in the World class whose act method will spawn the arrows. Just set it to some previously known limit (this can be held in another field) to start the delay and have it decremented once per act. When it becomes zero, spawn an arrow and reset the field to the limit. When coming from the four edges, which edge can be determined by a random rotation using '90*Greenfoot.getRandomNumber(4)'. Spawn the arrow at the center and move it immediately to the edge with 'move(-400)'. To give the arrows the ability to move faster, use a field for the speed (allowing you to change its value with code later). A static boolean field can be used to allow (when true) a chance to turn before reaching the player. A non-static boolean can be set to true when initially turned (so the code can direct the turned arrow around the player). That is how I would start it, at least.
Aura_ Aura_

2018/2/26

#
@Vercility: Change which direction they're coming from. Say the O is the actor, and the () is the arrow; O <() Halfway through, it would go to O ^ () switching from coming from the right to coming from the bottom. I'll try to code what you all said in class today and update as I have problems. Thank you for the help!
Vercility Vercility

2018/2/26

#
Aura_ wrote...
@Vercility: Change which direction they're coming from. Say the O is the actor, and the () is the arrow; O <() Halfway through, it would go to O ^ () switching from coming from the right to coming from the bottom. I'll try to code what you all said in class today and update as I have problems. Thank you for the help!
Thats fairly easy. Assuming your actor is right in the middle. Say your arrow comes from the left, if you wanna swap the direction you just need to remember how many pixels the arrow has already traveled from left to right (x axis) and instead add this on the y axis (and obviously change x to be right in the middle)
You need to login to post a reply.