Program Design Process - Emoji game

Yes, that’s right… I notice that earlier in this thread, @bradleywellsashley gave some advice on fixing that.

Use the if statement in the checkWin function to change what you want about the program. If you want the Y-Player to stop moving, how would you cancel out the things happening in the buttonR and buttonL clicked.

As he mentioned, since some students can view the forum, we don’t usually like to post answers to programming questions directly. I might add another possible solution, though. Rather than cancelling out what is happening in the buttonR and ButtonL clicks, could you perhaps reset the y location of the losing player like in the startGame function?

There is always more than one way to approach a problem.

If you try something and it isn’t working, we’re happy to look at it.

Mike

1 Like

I got it to work by send each player to the y position of -500. that works. I’ve been experimenting win the checkWin if statement.
I tried to make the if stop the players. something like
if (player_y > 350) {
player_y = player_y + 0;
}

objects still move

1 Like

The code you are using to make them stop will for that very instant cause them to not move, however, as soon as the event happens (pressing the button), they will still move again. You would need to find a way to stop the events from happening at all. Moving the players to a y position of -500 does work, although I guess if they sit there for 10 minutes and keep hitting the buttons, they could get another winner again … :wink:

Mike

1 Like

Speaking of challenges, a couple of students and I are attempting to do the sad/meh/happy emoji challenge where the emoji changes as it’s going down the screen. Would you recommend creating a sprite type situation where the costume changes at certain y values? Or completely separate icons whose hidden parameter is changed from true to false throughout the game? Or, something else much more slick that I haven’t thought of yet? Thank you,
Koreen

It sounds like either of those ideas would work. The code would look similar with If statements checking for y value and then either of those things, you mentioned, happening.

I don’t have any other more slick ideas, but others might.

Can you post a link to this challenge so I could take a look at it? Or even better start a new post where others might be more likely to see it.