Student wants the trex to jump when the space bar is pressed and we can not get the cacti to move and loop anymore.
It looks like the line still needs to be cropped. Right now, it has a lot of blank space above it, so collisions are not happening the way they would be expected. So, I would recommend:
- Crop the line using the crop tool in the animation tab.
- Crop the trex (one more time… there is still space below it).
- Lines 57-62 and lines 63-68 are identical. Delete 63-68.
- Simplify 57-62. One line (no if block) that just says
trex.collide(Line);should cause the trex to stop when it hits the line. If both are cropped, that will look right as well.
As for the cacti, right now the code is saying “If the cactus x position is greater than 5, set the cactus x position to a random spot between 0 and 400” This means basically, if the cactus is on the screen somewhere, randomly place it on the screen somewhere (at y=230). I think your student wants to say if it is LESS than 5, place it randomly on the screen somewhere or maybe even place it on the right side of the screen so it can come back across. So they will want to adjust those lines (48 & 52) accordingly (< rather than >) and perhaps a different range nearer to the right side of the screen.
Let us know how it goes.
I just wanted to check back to see if Mike’s solution was helpful or if you needed any more assistance.