Add direction and assets
211
asset/asset.svg
|
@ -25,9 +25,9 @@
|
|||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="11.2"
|
||||
inkscape:cx="-1065.1419"
|
||||
inkscape:cy="195.80413"
|
||||
inkscape:zoom="2.8"
|
||||
inkscape:cx="-990.35093"
|
||||
inkscape:cy="138.68996"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
|
@ -49,7 +49,7 @@
|
|||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
|
@ -58,12 +58,12 @@
|
|||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<rect
|
||||
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.05785796;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.04628637;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect815"
|
||||
width="13.229167"
|
||||
height="13.229167"
|
||||
x="-283.10416"
|
||||
y="237.46875"
|
||||
width="10.583341"
|
||||
height="10.583325"
|
||||
x="-281.78125"
|
||||
y="238.79167"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<rect
|
||||
|
@ -84,5 +84,198 @@
|
|||
y="238.79167"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<rect
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
y="238.79167"
|
||||
x="-264.58334"
|
||||
height="10.583325"
|
||||
width="10.583341"
|
||||
id="rect842"
|
||||
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.04628637;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<rect
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
y="240.11458"
|
||||
x="-263.26041"
|
||||
height="7.9375"
|
||||
width="7.9374938"
|
||||
id="rect844"
|
||||
style="opacity:1;fill:#5555ff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.22474444;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<rect
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
y="248.05208"
|
||||
x="-260.61459"
|
||||
height="1.3229166"
|
||||
width="2.6458333"
|
||||
id="rect846"
|
||||
style="opacity:1;fill:#ff6600;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<rect
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
y="238.79167"
|
||||
x="-247.38544"
|
||||
height="10.583325"
|
||||
width="10.583341"
|
||||
id="rect854"
|
||||
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.04628637;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<rect
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
y="238.79166"
|
||||
x="-230.1875"
|
||||
height="10.583325"
|
||||
width="10.583341"
|
||||
id="rect860"
|
||||
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.04628637;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<rect
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
y="240.11458"
|
||||
x="-246.0625"
|
||||
height="7.9375"
|
||||
width="7.9374938"
|
||||
id="rect856"
|
||||
style="opacity:1;fill:#5555ff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.22474444;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<rect
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
y="240.11456"
|
||||
x="-228.86456"
|
||||
height="7.9375"
|
||||
width="7.9374938"
|
||||
id="rect862"
|
||||
style="opacity:1;fill:#5555ff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.22474444;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<rect
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
y="236.80208"
|
||||
x="242.76042"
|
||||
height="1.3229166"
|
||||
width="2.6458333"
|
||||
id="rect858"
|
||||
style="opacity:1;fill:#ff6600;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
transform="rotate(90)" />
|
||||
<rect
|
||||
transform="rotate(90)"
|
||||
style="opacity:1;fill:#ff6600;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect866"
|
||||
width="2.6458333"
|
||||
height="1.3229166"
|
||||
x="242.76042"
|
||||
y="228.86458"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<rect
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
y="257.31253"
|
||||
x="-281.78125"
|
||||
height="10.583325"
|
||||
width="10.583341"
|
||||
id="rect868"
|
||||
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.04628637;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<rect
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
y="258.63544"
|
||||
x="-280.45831"
|
||||
height="7.9375"
|
||||
width="7.9374938"
|
||||
id="rect870"
|
||||
style="opacity:1;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.22474444;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<rect
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
y="257.31253"
|
||||
x="-277.8125"
|
||||
height="1.3229166"
|
||||
width="2.6458333"
|
||||
id="rect872"
|
||||
style="opacity:1;fill:#ff6600;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<rect
|
||||
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.04628637;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect874"
|
||||
width="10.583341"
|
||||
height="10.583325"
|
||||
x="-264.58334"
|
||||
y="257.31253"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<rect
|
||||
style="opacity:1;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.22474444;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect876"
|
||||
width="7.9374938"
|
||||
height="7.9375"
|
||||
x="-263.26041"
|
||||
y="258.63544"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<rect
|
||||
style="opacity:1;fill:#ff6600;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect878"
|
||||
width="2.6458333"
|
||||
height="1.3229166"
|
||||
x="-260.61459"
|
||||
y="266.57294"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<rect
|
||||
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.04628637;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect880"
|
||||
width="10.583341"
|
||||
height="10.583325"
|
||||
x="-247.38544"
|
||||
y="257.31253"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<rect
|
||||
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.04628637;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect882"
|
||||
width="10.583341"
|
||||
height="10.583325"
|
||||
x="-230.1875"
|
||||
y="257.3125"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<rect
|
||||
style="opacity:1;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.22474444;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect884"
|
||||
width="7.9374938"
|
||||
height="7.9375"
|
||||
x="-246.0625"
|
||||
y="258.63544"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<rect
|
||||
style="opacity:1;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.22474444;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect886"
|
||||
width="7.9374938"
|
||||
height="7.9375"
|
||||
x="-228.86456"
|
||||
y="258.63541"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<rect
|
||||
transform="rotate(90)"
|
||||
style="opacity:1;fill:#ff6600;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect888"
|
||||
width="2.6458333"
|
||||
height="1.3229166"
|
||||
x="261.28128"
|
||||
y="236.80208"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
<rect
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
y="228.86458"
|
||||
x="261.28128"
|
||||
height="1.3229166"
|
||||
width="2.6458333"
|
||||
id="rect890"
|
||||
style="opacity:1;fill:#ff6600;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
transform="rotate(90)" />
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 10 KiB |
BIN
asset/perso1.png
Before Width: | Height: | Size: 238 B |
BIN
asset/perso1_down.png
Normal file
After Width: | Height: | Size: 235 B |
BIN
asset/perso1_left.png
Normal file
After Width: | Height: | Size: 242 B |
BIN
asset/perso1_right.png
Normal file
After Width: | Height: | Size: 236 B |
BIN
asset/perso1_up.png
Normal file
After Width: | Height: | Size: 231 B |
BIN
asset/perso2.png
Before Width: | Height: | Size: 238 B |
BIN
asset/perso2_down.png
Normal file
After Width: | Height: | Size: 229 B |
BIN
asset/perso2_left.png
Normal file
After Width: | Height: | Size: 223 B |
BIN
asset/perso2_right.png
Normal file
After Width: | Height: | Size: 224 B |
BIN
asset/perso2_up.png
Normal file
After Width: | Height: | Size: 224 B |
4
main.py
|
@ -20,8 +20,8 @@ WHITE=(255,255,255)
|
|||
BLUE=(0,0,255)
|
||||
RED=(255,0,0)
|
||||
|
||||
perso1 = perso('Alice',200,200,pygame.K_o,pygame.K_l,pygame.K_k,pygame.K_m,'asset/perso1.png')
|
||||
perso2 = perso('Bjorn',600,600,pygame.K_z,pygame.K_s,pygame.K_q,pygame.K_d,'asset/perso2.png')
|
||||
perso1 = perso('Alice',200,200,pygame.K_o,pygame.K_l,pygame.K_k,pygame.K_m,'asset/perso1')
|
||||
perso2 = perso('Bjorn',600,600,pygame.K_z,pygame.K_s,pygame.K_q,pygame.K_d,'asset/perso2')
|
||||
|
||||
speed = 1
|
||||
|
||||
|
|
10
models.py
|
@ -15,7 +15,11 @@ class perso():
|
|||
self.key_down = key_down
|
||||
self.key_left = key_left
|
||||
self.key_right = key_right
|
||||
self.img = pygame.image.load(texture)
|
||||
self.img_up = pygame.image.load(texture+'_up.png')
|
||||
self.img_down = pygame.image.load(texture+'_down.png')
|
||||
self.img_right = pygame.image.load(texture+'_right.png')
|
||||
self.img_left = pygame.image.load(texture+'_left.png')
|
||||
self.img = self.img_up
|
||||
self.size = self.img.get_size()
|
||||
|
||||
def check_move(self,keystate,screen_width,screen_height,speed):
|
||||
|
@ -23,18 +27,22 @@ class perso():
|
|||
self.posx -= speed
|
||||
if self.posx <0:
|
||||
self.posx=0
|
||||
self.img = self.img_left
|
||||
if keystate[self.key_right]:
|
||||
self.posx += speed
|
||||
if self.posx+self.size[0] > screen_width:
|
||||
self.posx = screen_width-self.size[0]
|
||||
self.img = self.img_right
|
||||
if keystate[self.key_up]:
|
||||
self.posy -= speed
|
||||
if self.posy < 0:
|
||||
self.posy = 0
|
||||
self.img = self.img_up
|
||||
if keystate[self.key_down]:
|
||||
self.posy += speed
|
||||
if self.posy+self.size[1] > screen_height:
|
||||
self.posy = screen_height-self.size[1]
|
||||
self.img = self.img_down
|
||||
|
||||
def draw(self,surface):
|
||||
surface.blit(self.img,(self.posx,self.posy))
|