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

Report as inappropriate.

mjrb4
mjrb4 presents ...

2008/7/19

Graviton

Player 1 uses arrow keys, 2 uses wsad. Try and reach the house before the other player. This is the completed scenario that forms the basis of the Graviton tutorial.

UPDATE: Shorter worksheet is now available that just takes the user through implementing the arrow keys. http://www.greenfoot.org/greenroom/index.php/Graviton_(short)

4045 views / 537 in the last 7 days

1 vote | 0 in the last 7 days

Tags: game simulation physics 2-player

There is no HTML 5 translation of this scenario available.
View legacy version (requires Java plugin)

This scenarios uses Java features that are not available for use after conversion to HTML 5. Please try the legacy version, which requires the Java plugin to be installed.

computers.funcomputers.fun

2008/12/18

Hi mjrb4, This looks like a very useful tutorial. I'm trying to follow along on kidslike.info http://kidslike.info/greenfoot_gravitron_tutorial_student_assignment It's trying to teach a lot of things in one tutorial. Would it be possible for you to post a very simple tutorial that only teaches how to have 2 players, each controlling one character? Thank you.
mjrb4mjrb4

2008/12/18

Hi, This was one of the first worksheets I wrote, and as you point out there is a lot to do in it - in the later ones you'll (hopefully) see I've tried to keep things a bit simpler. I haven't had a chance to write a simpler version of this one yet, but I will do at some point - just learning how to use the arrow keys seems like a good thing to focus on. It'll be on the greenroom when it's finished! Oh, and I had no idea it was called gravitron (with the r)... That'd be the second spelling mistake I've made in the name of a game so far (going along with dual / duel)!
computers.funcomputers.fun

2008/12/19

Hi mjrb4, thanks for the comment on kidslike.info to let me know you uploaded the short version. Thank you for making a short version so quickly. I've tried it out. I put in the code for the keys. but nothing happens. Is anything supposed to happen? Is it possible to have it unzip to a folder called graviton-short so it does not wipe out the long gaviton? I'm trying to write the code for a scenario where there are 2 plays, and each player uses keys to move an object. Nothing else happens. Could you upload a scenario for that? Thank you.
mjrb4mjrb4

2008/12/19

Did you also put the ignite(true) and ignite(false) bits in the right places? It's not *just* putting the arrow keys in, I thought that'd be shortening it a bit too much. I've tried it quickly and it seems to work for me... I'll have a look at it in more detail and update the folder name a bit later.
computers.funcomputers.fun

2008/12/23

mjrb4, no. I didn't do anything else beside the arrow keys. I thought the arrow keys would work if I put in the code. That was the only thing I was testing.
computers.funcomputers.fun

2008/12/23

mjrb4, I found a simple game for 2 players. I used it to learn how to make a 2 player game. So I know how to do that now. the new game is at http://greenfootgallery.org/scenarios/516
mjrb4mjrb4

2008/12/23

As well as the arrow keys, if you follow the tutorial through you'll see that you have to tell the game what to do when the assigned keys have been pressed - this was something I deliberately kept in. The methods are all provided in the superclass so it's literally just a case of plugging the right ones in the right places, and (I hope!) it should be pretty clear from the worksheet what methods to use. As for why I didn't just use seperate Greenfoot.isKeyDown() statements in two completely seperate objects - in retrospect it would've been easier and therefore perahps better in the tutorial aspect, but the lack of a common superclass would've meant many many lines of duplicated code, which is almost always a bad thing.
computers.funcomputers.fun

2008/12/23

mjrb4, Thanks. I'll have to go back and finish the tutorial. I agree. It's better to recycle the code, but I did not know where you had put the code for the 2 player if then statement. Where do I go to find the 2 players? How do you get blank lines in your description of your scenario? I press enter, but there is no new line. And all the lines run together. Do I use <br /> or something?
mjrb4mjrb4

2008/12/23

Enter should work... That's all I've done anyway. There's two main "blocks" of code that have to be edited in the short scenario. One block is the key assignment, which it sounds like you've done and is specific to the player. The second is then controlling what the rocket does when each of these keys is pressed - and this is common to both rockets. It should show you where each of these bits of code are in the tutorial, or at least give you enough pointers to find them - but no from memory they're not in the same place.

Want to leave a comment? You must first log in.

Who likes this?

computers.fun