Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 days learning Python 3
#7
Thank you to you all for the helpfull replies. I have managed to resolve this now.
ypos=50
pygame.draw.circle(screen,(0,255,0),(xpos,ypos),20)
import pygame, sys
from pygame.locals import *
pygame.init()
pygame.display.set_caption("first program")
screen = pygame.display.set_mode((640,480))
xpos = 50
ypos = 50
clock = pygame.time.Clock()
while 1:
	clock.tick(60)
	for event in pygame.event.get():
		if event.type == pygame.QUIT:
			sys.exit()
	pressed_keys = pygame.key.get_pressed()
	if pressed_keys[K_RIGHT]:
		xpos += 1
	if pressed_keys[K_LEFT]:
		xpos -= 1
	if pressed_keys[K_UP]:
		ypos -= 1
	if pressed_keys[K_DOWN]:
		ypos += 1

	screen.fill((255,255,255))
	pygame.draw.circle(screen,(0,255,0),(xpos,ypos),20)
	
	pygame.display.update()
Reply


Messages In This Thread
2 days learning Python 3 - by Donny - Nov-02-2019, 11:59 AM
RE: 2 days learning Python 3 - by menator01 - Nov-02-2019, 12:09 PM
RE: 2 days learning Python 3 - by Donny - Nov-02-2019, 12:18 PM
RE: 2 days learning Python 3 - by nilamo - Nov-07-2019, 05:41 PM
RE: 2 days learning Python 3 - by menator01 - Nov-02-2019, 12:23 PM
RE: 2 days learning Python 3 - by Donny - Nov-02-2019, 12:29 PM
RE: 2 days learning Python 3 - by Donny - Nov-08-2019, 10:20 PM

Forum Jump:

User Panel Messages

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