Jan-19-2025, 07:23 PM
(This post was last modified: Jan-19-2025, 08:12 PM by Gribouillis.)
Good day, I'm attempting to help with an assignment. The school uses TechSmart. I was able to help with a couple of things, but this has us both stumped. The assignment is to show mouse action when hovering over an object. This part is okay. Here's the scenario.
Crow displayed at rest.
Move the cursor over the crow
Mallet is displayed and crow squawks
Remove cursor focus from the crow and it is displayed at rest.
This all works.
But, what doesn't work is removing the displayed mallet when focus is removed from the squawking crow.
I learned some C decades ago, but I'm a Python newbie and not much help with this. I've tried some things in the ELSE, but nothing is working to remove the mallet. Any direction is appreciated.
Thank you,
Jim
This is the current code:
Crow displayed at rest.
Move the cursor over the crow
Mallet is displayed and crow squawks
Remove cursor focus from the crow and it is displayed at rest.
This all works.
But, what doesn't work is removing the displayed mallet when focus is removed from the squawking crow.
I learned some C decades ago, but I'm a Python newbie and not much help with this. I've tried some things in the ELSE, but nothing is working to remove the mallet. Any direction is appreciated.
Thank you,
Jim
This is the current code:
import tsapp window = tsapp.GraphicsWindow() #### ---- SPRITE SETUP ---- #### camp = tsapp.Sprite("Campgrounds.jpg", 0, 0) crow = tsapp.Sprite("Crow.png", 400, 200) crow.scale = 1.20 mallet = tsapp.Sprite("Mallet.png", 350, 50) mallet.scale = 0.75 #### ---- SCENE CREATION ---- #### window.add_object(camp) window.add_object(crow) while window.is_running: mouse_x, mouse_y = tsapp.get_mouse_position() if crow.is_colliding_point(mouse_x, mouse_y): crow.image = "CrowStartled.png" window.add_object(mallet) else: crow.image = "Crow.png" window.finish_frame()
Gribouillis write Jan-19-2025, 08:12 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.