Python Forum
pygame error in my clicker game
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pygame error in my clicker game
#2
I don't know about the 2nd issue you had,
but the following might help you w/ the 1st issue:

button1("GO!", intro_button_width1, intro_button_height, 100, 50, green, bright_green, game_loop)
button1("Quit", intro_button_width2, intro_button_height, 100, 50, red, bright_red, quit)
mouse = pygame.mouse.get_pos()

if (intro_button_width1 + 100 > mouse[0] > intro_button_width1
and intro_button_height + 50 > mouse[1] > intro_button_height):
pygame.draw.rect(gameDisplay, bright_green, (intro_button_width1, intro_button_height, 100, 50))
else:
pygame.draw.rect(gameDisplay, green, (intro_button_width1, intro_button_height, 100, 50))

smallText = pygame.font.Font("freesansbold.ttf", 20)
textSurf, textRect = text_objects("GO!", smallText)
textRect.center = ((intro_button_width1 + (100 / 2)), (intro_button_height + (50 / 2)))
gameDisplay.blit(textSurf, textRect)

if (intro_button_width2 + 100 > mouse[0] > intro_button_width2
and intro_button_height + 50 > mouse[1] > intro_button_height):
pygame.draw.rect(gameDisplay, bright_red, (intro_button_width2, intro_button_height, 100, 50))
else:
pygame.draw.rect(gameDisplay, red, (intro_button_width2, intro_button_height, 100, 50))

**** button1 is defined as:
def button1(msg,x,y,w,h,ic,ac,action=None):
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()

if x+w > mouse[0] > x and y+h > mouse[1] > y:
pygame.draw.rect(gameDisplay, ac,(x,y,w,h))

if click[0] == 1 and action != None:
action()
else:
pygame.draw.rect(gameDisplay, ic,(x,y,w,h))


Hopefully, this helps.
Reply


Messages In This Thread
pygame error in my clicker game - by CrazyMakes - Apr-17-2020, 01:58 AM
RE: pygame error in my clicker game - by vman44 - Apr-19-2020, 12:38 AM
RE: pygame error in my clicker game - by Windspar - Apr-19-2020, 03:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Isometric game pygame Tiled howardberger 1 751 Jan-31-2024, 10:01 PM
Last Post: deanhystad
  [PyGame] Pygame attribute error djwilson0495 3 4,038 Feb-18-2021, 03:34 PM
Last Post: michael1789
Big Grin Error installing Pygame-Zero dpa2007 1 3,234 Dec-26-2020, 03:50 PM
Last Post: MK_CodingSpace
  Error to install pygame skp 1 3,578 Apr-14-2020, 05:17 PM
Last Post: joe_momma
  installing pygame error pylab 1 4,315 Dec-31-2019, 05:44 PM
Last Post: pylab
  [PyGame] pygame image loading error BlueClaw 6 6,497 Dec-10-2019, 08:50 PM
Last Post: BlueClaw
  Problem with music - Pygame.error GaseBall 1 3,257 Nov-28-2019, 07:46 PM
Last Post: SheeppOSU
  Pygame to exe error Clunk_Head 0 3,030 Oct-19-2019, 01:34 PM
Last Post: Clunk_Head
  Basically a Python Tetris game [pygame] rather keyboard arrows can be controlled with lsepolis123 9 5,278 Sep-10-2019, 08:12 PM
Last Post: metulburr
  Pygame 2d game maximk301 1 2,915 Apr-08-2019, 11:22 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020