What I am trying to do is show 2 different images based on where the mouse is positioned or what the score is (I posted my full code below). I have the mouse position function working and displaying the mouse current position in real time. I have a global score variable that increments based on the mouse position differently, and I want to have an image change either based on a score value or if the x/y are in a certain place.
I have not been able to make the images show over the background in any way. I have tried doing it with a screen or a label with no luck, and I think the switchCondition will be the cleanest option but it just wont change.
When I run the code below I see imgone.png showing up right away, and when I get to label end I see imagetwo.png, but I am unable to see image two when I move my mouse and see the score change to be over 10.
Any ideas how to approach this or what I am doing wrong? Thank you!
Code: Select all
define nar = Character("Narrator")
default x = 0
default y = 0
default score = 0
image scoreimage = ConditionSwitch(
"score <= 10", "imgone.png",
"score > 10", "imgtwo.png",
"True", "imgthree.png")
init python:
import math
## Get cursor position
def dd_cursor_position(st, at):
x, y = renpy.get_mouse_pos()
if (x<=750 or (x>=750 and x<=1170 and y<=450) or x>=1170):
globals()['score'] += 1
renpy.hide("scoreimage")
renpy.show("scoreimage")
return Text("{size=-5}%d - %d: %d"%(x, y, score)), .1
elif (x>=750 and x<=1070 and y>=450):
globals()['score'] -= 1
renpy.hide("scoreimage")
renpy.show("scoreimage")
return Text("{size=-5}%d - %d: %d"%(x, y, score)), .1
return Text("{size=-5}%d - %d"%(x, y)), .1
## screen for the cursor position
screen Mouse_Position():
zorder 10**10
add DynamicDisplayable(dd_cursor_position) xpos 10 yalign 0.99
label start:
#test background to put images on top
scene testing bkgd
show screen Mouse_Position
"'Space' when done"
jump end
label end:
nar "Your score is [score]"
# This ends the game.
return