Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added reflection for collisions.

  • Loading branch information...
commit 2acce1ab484c8f6e81914d34bf3b969665224ed4 1 parent 076c2c5
namaste authored
Showing with 10 additions and 8 deletions.
  1. +2 −2 soylent/weapon/Enemy.py
  2. +8 −6 soylent/weapon/Hero.py
View
4 soylent/weapon/Enemy.py
@@ -12,10 +12,10 @@ def __init__(self, rect=None):
self.image = pygame.image.load("images/enemy1.png")
self.rect = self.image.get_rect()
self.rect.center = rect.center
- self.hp = 1000
+ self.hp = 5000
self.armor = 1
self.minions = []
- self.mass = 100
+ self.mass = 100.0
self.velocity = (0,0)
self.damage = 10
View
14 soylent/weapon/Hero.py
@@ -18,7 +18,7 @@ def __init__(self, position):
self.damage = 10
self.agility = 1
self.velocity = (0.0,0.0)
- self.mass = 200
+ self.mass = 200.0
self.armor = 10
self.max_speed = 24
#self.acceleration = (0,0)
@@ -33,6 +33,7 @@ def __init__(self, position):
self.isJumping = False
def Draw(self, surface):
+ """if jumping, draw the jumping image, otherwise draw the standard image"""
if self.isJumping: surface.blit(self.jumpimage, self.rect.move(-16,-16))
else: surface.blit(self.image, self.rect)
self.friendly_sprites.draw(surface)
@@ -88,7 +89,9 @@ def Collide(self, enemy_sprites):
for e in collision_lst:
e.HitHero(self)
e.Impact(self.mass, self.velocity, self.damage)
-
+ #print (float((e.mass/self.mass) * (self.velocity[0] - e.velocity[0])),float((e.mass/self.mass) * (self.velocity[1] - e.velocity[1])))
+ self.velocity = (e.mass/self.mass) * (self.velocity[0] - e.velocity[0]),(e.mass/self.mass) * (self.velocity[1] - e.velocity[1])
+
"""friendlies colliding with enemies"""
collision_dict = pygame.sprite.groupcollide(self.friendly_sprites, enemy_sprites, False, False).iteritems()
for friend,enemy in collision_dict:
@@ -241,16 +244,15 @@ def Update(self):
segment_length = self.currentlength / (self.power - 1)
self.orblist[-1] = (x1, y1)
c = 1
+ """evenly place orbs along gesture"""
for i in range(1, len(self.dragpoints.length)):
while self.dragpoints.length[i] >= (segment_length * c):
diff = self.dragpoints.length[i] - segment_length * c
vect = (float(self.dragpoints.pos[i - 1][0] - self.dragpoints.pos[i][0]),
(self.dragpoints.pos[i - 1][1] - self.dragpoints.pos[i][1]))
mag = sqrt(vect[0]*vect[0] + vect[1]*vect[1])
- if mag != 0:
- vect = (vect[0]/mag, vect[1]/mag)
- if c >= len(self.orblist):
- self.orblist.append((x1, y1))
+ if mag != 0: vect = (vect[0]/mag, vect[1]/mag)
+ if c >= len(self.orblist): self.orblist.append((x1, y1))
self.orblist[c] = (self.dragpoints.pos[i][0] + diff * vect[0], self.dragpoints.pos[i][1] + diff * vect[1])
c+=1
"""end class Gesture"""
Please sign in to comment.
Something went wrong with that request. Please try again.