debut de definition des models et deux personnages
parent
1f98475dd3
commit
f9025ba480
@ -0,0 +1,4 @@
|
||||
*__.py
|
||||
__pycache__/*
|
||||
*.swp
|
||||
*.pyc
|
@ -0,0 +1,41 @@
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
### Tangled Mind
|
||||
### Author: Arthur 'Grizzly' Grisel-Davy
|
||||
|
||||
import pygame
|
||||
|
||||
class perso():
|
||||
|
||||
def __init__(self,name,posx,posy,width,height,color,key_up,key_down,key_left,key_right):
|
||||
self.name = name
|
||||
self.posx = posx
|
||||
self.posy = posy
|
||||
self.key_up = key_up
|
||||
self.key_down = key_down
|
||||
self.key_left = key_left
|
||||
self.key_right = key_right
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.color = color
|
||||
|
||||
def check_move(self,keystate,screen_width,screen_height,speed):
|
||||
if keystate[self.key_left]:
|
||||
self.posx -= speed
|
||||
if self.posx <0:
|
||||
self.posx=0
|
||||
if keystate[self.key_right]:
|
||||
self.posx += speed
|
||||
if self.posx+self.width > screen_width:
|
||||
self.posx = screen_width-self.width
|
||||
if keystate[self.key_up]:
|
||||
self.posy -= speed
|
||||
if self.posy < 0:
|
||||
self.posy = 0
|
||||
if keystate[self.key_down]:
|
||||
self.posy += speed
|
||||
if self.posy+self.height > screen_height:
|
||||
self.posy = screen_height-self.height
|
||||
|
||||
def draw(self,surface):
|
||||
pygame.draw.rect(surface,self.color,(self.posx,self.posy,self.width,self.height))
|
Loading…
Reference in New Issue