Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pilas/actores/disparo.py
diff options
context:
space:
mode:
Diffstat (limited to 'pilas/actores/disparo.py')
-rw-r--r--pilas/actores/disparo.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/pilas/actores/disparo.py b/pilas/actores/disparo.py
new file mode 100644
index 0000000..ccd19c0
--- /dev/null
+++ b/pilas/actores/disparo.py
@@ -0,0 +1,33 @@
+# -*- encoding: utf-8 -*-
+# Pilas engine - A video game framework.
+#
+# Copyright 2010 - Hugo Ruscitti
+# License: LGPLv3 (see http://www.gnu.org/licenses/lgpl.html)
+#
+# Website - http://www.pilas-engine.com.ar
+
+import pilas
+from pilas.actores import Animacion
+import math
+
+class Disparo(Animacion):
+ "Representa un disparo que avanza."
+
+ def __init__(self, x=0, y=0, rotacion=0, velocidad=2):
+ self.velocidad = velocidad
+ grilla = pilas.imagenes.cargar_grilla("disparo.png", 2)
+ Animacion.__init__(self, grilla, ciclica=True, x=x, y=y)
+ self.radio_de_colision = 10
+ self.rotacion = rotacion
+
+ def actualizar(self):
+ Animacion.actualizar(self)
+ self.avanzar()
+
+ def avanzar(self):
+ "Hace avanzar la nave en direccion a su angulo."
+ rotacion_en_radianes = math.radians(-self.rotacion + 90)
+ dx = math.cos(rotacion_en_radianes) * self.velocidad
+ dy = math.sin(rotacion_en_radianes) * self.velocidad
+ self.x += dx
+ self.y += dy