My student would like for his trex to jump and land on the line and stay there. We have referenced several lessons, particularly U3L18 bubble 11 to see how that was coded. However, we were still unable to get it working the way he wants it.
When jumping, you want to use velocityY. each frame you can add to the velocity, to make it slowly move down. once the y of the dino is >= the original position, it should make the velocityY 0, and set the y to the original position (in case it goes past)
I hope this makes sense.
@keisa.carrhudson, This one took me a few minutes to figure out, but let me give you a few suggestions that I think will make this one easier to debug. 1st of all, your student needs to crop their sprites, specifically the trex and the line. See the image below. The red arrow is pointing to the crop button. When I first cropped the trex, there was a small white dot at the bottom of the window I had to erase before I got the results in the image below.
Even more important, though, is cropping the line. Since there are a lot of “transparent” pixels above and below the line, the collision is occuring even when the trex isn’t touching the colored part of the line. It can collide with transparent areas even though we tend to think that’s not a collision ourselves.
Another thing I personally did that helped me was to change the color of the line to red so I could see what was happening. After that, it became necessary to adjust the initial y positions of the trex and the line and the velocityY changes of the trex because -5 seemed too much for me, but I think your student will be able to play with all of those kinds of things to their own satisfaction once the sprites are cropped. Once I had it working right, I changed the line back to the same color as the sand.
Lastly, unrelated to the problem, but worth pointing out … your student is using sprites named “background” and “line”. Those are names typically used by GameLab with a very specific meaning, so your student is overriding those names. At this point, there is no harm done, but it’s generally a good idea to not redefine built in names, so I suggest using something like “myBackground” and “myLine” (or something else that isn’t used by GameLab itself).
Hope this helps! Let us know how it goes. Looks like a fun game!
GameLab uses backgroud and line, both are lowercase, for some of my games where i use a background sprite, i use backGround (notice the capital G)
this does not interfere with GameLab, as it’s a completely different string.