Answers for "detect when the mosue is pressed in pygame"

C
2

how to detect mouse click in pygame

while running: # Gameloop
  for event in pygame.event.get(): # Checks all events
    if event.type == pygame.MOUSEBUTTONDOWN: # If the current event is the mouse button down event
      pos = pygame.mouse.get_pos() # Stores the mouse position
Posted by: Guest on July-26-2021
0

how to detect when a key is pressed in pygame

import pygame

keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
    x -= 1
if keys[pygame.K_RIGHT]:
	x += 1
Posted by: Guest on June-12-2021

Code answers related to "detect when the mosue is pressed in pygame"

Code answers related to "C"

Browse Popular Code Answers by Language