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

2016/2/3

Rock Paper Scissors Help!!? :(

kevinhmkim kevinhmkim

2016/2/3

#
I need help with creating a Greenfoot game. The game is Rock paper scissors. I have two actors (Player 1 and player 2) and subclasses (rock, paper, scissors). I am having an issue implementing a timer. Currently I have the timer on the world, but when "Run" is pressed, the timer stays the same number. Also, how would I code the game so when the timer runs out, the player's choice (rock paper scissors) appears. The players choose their choices by pressing a key (a = scissors, s = paper, d = rock --> for player 2.. etc). Please help! @danpost (<-- the genius/master of greenfoot)
danpost danpost

2016/2/3

#
'rock', 'paper' and 'scissors' are player choices -- not players; therefore, they should not be subclasses of the two player classes. A proper subclassing would be to have a Player class as subclass of Actor and Player1 and Player2 classes as subclasses of the Player class. You could do similarly with a Choice class and the three choices as subclasses of it; but, that would be a bit much as the only difference between the choices can be represented with a field value that also will determine which image it should display. Also, it would be easier to not keep swapping out actors in the world as a choice will be going from state to state -- from on unknown to something chosen, back to unknown for the next game. Your Player class should create a Choice object or each player created and keep a reference to it. Your subclass of World should have a reference to the timer and the two players and its act method should call the different methods in the player class during the game (the Player class and its subclasses should not have any implementation for their act methods. As far as your timer is concerned, you have not provided the code you are using (all codes related to the timer); so no help can be afforded. Also, you did not state what would happen is a choice is not given before the timer runs out.
You need to login to post a reply.