projectile.py 821 Bytes
Newer Older
Corentin MIMEAU's avatar
Corentin MIMEAU committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-

# http://pad.univ-nantes.fr/editor/p/g.KMzBqiBBATY1dYss$Ageofdefense

import math
from pygame import *
import time
import os

from carteStruct import *
from constante import Constante
from base import *
from joueur import *
from tour import *

class Projectile:

	def __init__(self, dep, arr, v, u):
		self.depart = dep
		self.arrive = arr
		self.vitesse = v
		self.unite = u
		self.position = dep


	def avancer(self, ecran):
		x = self.position[0] - self.unite.position[0]
		y = self.position[1] - self.unite.position[1]
		
		#pente = y/x

		dx = (-1 if x > 0 else 1)
		dy = (-1 if x > 0 else 1)
		
		u = self.position[0] + dx
		v = self.position[1] + dy
		self.position = (u, v)

		print self.position
		draw.rect(ecran, (255, 0, 0), (u, v, 10, 10))

	def detruire(self):
		print "detruire"