Unit 6, Lesson 9 Help

I have a student who is programming his “game” on Lesson 9. What he is trying to accomplish is to use the L and R buttons on the circuit board to control the dot and get through the maze. He wants to incorporate the toggle switch in order to move in the four directions. When the switch is open it should move up and down when the buttons are pressed and when the switch is closed it should move left and right. The left to right movement works sometimes, but then when the switch is toggled the dot will start moving diagonally and we can’t figure out why. I haven’t had much experience in Unit 6 and we’ve tried a number of different things with no luck. I am hoping someone can take a look at what he has and see what might be the issue. Here is the link to his project: Unit 6 Project

Just taking a quick look at the code, the first problem that I see is that his onBoardEvents are inside of the movePlayerAllDirections function. This function is only called when startButton is clicked. He’ll need to move the onBoardEvents outside of the functions to work correctly. You can check inside the onBoardEvents to see if the toggle switch is open or closed to determine which directions to move the player. I made some changes to the code so you can see what I am referring to.

He also needs to move the call to the CheckWins function so that it is called everytime the player moves. It was only being called when the start button was pressed.

1 Like

Thank you, I will try that with him in our next class and see if that does the trick.

Joey,

Checking in - did you get it figured out?

Brad

Yes, the code that @kammie.dill shared worked and the student was able to get his program running the way he wanted.

1 Like

Ok, so I have multiple students issues that I need some help with. I just don’t have the background in Unit 6 to really help them and I have to admit it’s a bit frustrating for me as well as the students.

The first student wants his “Win” screen to appear when the “player” gets to the exit of the maze. I’m not sure how to program that. We tried some conditional statements, but to no avail. Here is his code: Student 1

The second student has been trying to set up a rock, paper, scissors game and I have to admit, to me his code looks like a huge dumpster fire so I’m not sure if anyone would be able to help. When you hit play and select Player 1 or Player 2, a button appears and he is trying to code it so that when you hit ButtonL or ButtonR on the circuit board it will start each respective player’s game. I honestly don’t even know where to start with this one. Student 2

The third student wants her program to work like a game from Game Lab. She wants the fish on the bottom of the screen to continually be moving up the screen and the hook is controlled with the L and R buttons. When 15 fish have been collected she wants the Winner screen to display. This is much different than sprites, so I’m struggling to figure out how to make that happen. Here is her code: Student 3

Thank you for all the help. It’s a lot for the end of the school year! I’m not sure I’d make it without this community.

Both of your conditionals are checking to see if the switch is open. I am assuming one of them should check for a non-open switch or you should have a more complex statement such as and if then else.

IF (switch is open)
do this
ELSE (switch is not open)
do this
END

@dkeely Right. That is meant to be programmed that way. That is how he is able to move the dot up/down/left/right with the L and R buttons on the circuit board. His current struggle is getting his Win screen to display if the dot makes it to the exit of the maze.

Hi Joey,

For student 1, I looked at the checkWin function, which I assume checks whether the player has won and sets the win screen in that condition. The problem is the condition it’s checking. "player" < 5 doesn’t make any sense to me. A string (piece of text) cannot be less than or greater than a number. Most likely the student was trying to check a property of the player element against the number, but to do that, the student will need to use a getProperty block.

For student 2, there are no board events in the program, so I don’t see how this is a circuit playground game. The student should review how to create an event that check for a button click on the circuit playground. I’m not clear how the game is supposed to work, but I know for sure it won’t work as intended without checking for board events.

For student 3, it sounds like you want to program in some kind of collision detection into App Lab. That is possible, but it is complicated. If the student takes a look back at the Animations and Games unit where collision detection was first explained, she can see the code that can make it work, but basically you need to check the x and y properties of the two elements and see whether they are close enough to each other for the elements to be overlapping. This is a different problem from keeping track of how many fish have been collected, which is different from making a fish disappear after it’s been collected, which is different from changing the screen when the number of fish hits a certain point. The student will need to figure out how to do each one of these things to make the game work, but breaking them into pieces will allow her to just think about one thing at a time.

Elizabeth

Thank you for the thorough responses @elizabeth_admin . I think I know how to help Student 1. I tried a getProperty block yesterday but wasn’t quite sure how to make that work to check on the position, as it’s not a sprite. I am definitely more comfortable in Game Lab than I am in App Lab.

I really have no idea how to help Student 2. To me, his code is such a dumpster fire that I don’t even know where to start. He also has autism and is really wanting to get this to work so I can see it becoming a huge issue if we can’t figure it out.

Student 3 has a good idea, but I agree that it would probably be something that would work better in Game Lab than App Lab. Without sprites, I’m not sure how to program the elements to move. I know she could type in text mode and use the JavaScript code from Unit 3, but I haven’t had enough experience in App Lab to know how to make that work.