/simulatie/pyg.py (d490572ea387ef19a8ed9d2b386255cdb36c0a80) (1488 bytes) (mode 100644) (type blob)

#!/bin/env python

import sys, pygame
import thread

pygame.init()

screen = pygame.display.set_mode((800,600))
screen.fill((255,255,255))
speed= [1,1]

class Auto(object):
	def __init__(self, x, y):
		self.auto = pygame.image.load("auto.png")
		self.auto = pygame.transform.scale(self.auto, (64,64))
		self.rect = self.auto.get_rect()
		self.x = x
		self.y = y
		self.dest = [x,y]

	def _move_callb(self):
		origin = [self.x, self.y]
		print(str(origin) + " -> " + str(self.dest) + "\n")
		if origin[0] > self.dest[0]:
			self.rect.move([-1,0])
		elif origin[0] < self.dest[0]:
			self.rect.move([1,0])
			#screen.blit(self.auto, self.rect)
		print("origin(" + str(origin) + ") > dest(" + str(self.dest) + ")\n")
		if origin[1] > self.dest[1]:
			self.rect.move([0,-1])
		elif origin[1] < self.dest[1]:
			self.rect.move([0,1])
			#screen.blit(self.auto, self.rect)
		print("origin(" + str(origin) + ") < dest(" + str(self.dest) + ")\n")
		#screen.blit(self.auto, self.rect)

	def goto(self, x, y):
		self.dest = [x,y]
		

car = Auto(50,50)
#car.goto(1000, 1500)
clock = pygame.time.Clock()

# Mainloop
while True:
	clock.tick(60)
	for event in pygame.event.get():
		if event.type == pygame.QUIT: sys.exit()

	car.rect = car.rect.move(speed)
	if car.rect.left < 0 or car.rect.right > 800:
		speed[0] = -speed[0]
	if car.rect.top < 0 or car.rect.bottom > 600:
		speed[1] = -speed[1]

#	car._move_callb()
	screen.fill((255,255,255))
	screen.blit(car.auto, car.rect)
	pygame.display.flip()


Mode Type Size Ref File
100644 blob 6 0d20b6487c61e7d1bde93acf4a14b7a89083a16d .gitignore
100644 blob 2385 b8d340fa5ab0d6d6ae333614e91159cb56014d9f Connectie
100644 blob 565 39af52c077c0d4c3bc7730b362592e0bf7f635db README.md
040000 tree - 748818351ca67d5c8ba9f2480e15c3dd499964ec simulatie
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/kapstok/NHL-SoftDev

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/kapstok/NHL-SoftDev

Clone this repository using git:
git clone git://git.rocketgit.com/user/kapstok/NHL-SoftDev

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main