I am working on a platformer game. There is a lot of code which I am not including here. I am including my imports and the method which is giving me the problem. This is a button function which should change color when hovered over. The action has not been added yet, I am still trying to figure out why pygame.mouse.get_pos()
is not working as it should.
import pygame as pg
import random
from settings import *
from sprites import *
from os import path
def botton(self,rectac,rectic,txtc,f_size,x,y,w,h,txt,xt,yt,action=None):
mouse = pg.mouse.get_pos()
print(mouse)
if x+w>mouse[0]>x and y+h>mouse[1]>y:
pg.draw.rect(self.screen,rectac,(x,y,w,h))
else:
pg.draw.rect(self.screen,rectic,(x,y,w,h))
self.draw_text(txt,f_size,txtc,xt,yt)
print(x,y)
But, when I run the program, I noticed that the program does not enter the if condition. So, I printed mouse. The result I get is just one set of coordinates,that is, the position of the mouse when I run the program. It does not give me anything else.
P.S. This is not a homework problem, it is a personal project that I am working on.