Skip to content

Commit

Permalink
Ent updates and common Media class added
Browse files Browse the repository at this point in the history
  • Loading branch information
Ropes committed Jan 28, 2012
1 parent b2759ae commit a631b4a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
22 changes: 21 additions & 1 deletion common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,24 @@
# def tup(self):
# return (self.x, self.y)

vec = b2Vec2
vec = b2Vec2

class Media():
def __init__(self):
#Load all media needed(images, animations, sounds, etc)
self.test = load_img('test.png')


'''
Returns the image surface resource only
'''
def load_img(name, colorkey = None):
fullname = os.path.join('media', name)
image = pygame.image.load(fullname)
# To speed things up, convert the images to SDL's internal format
image = image.convert_alpha()
if colorkey is not None:
if colorkey == -1:
colorkey = image.get_at((0,0))
image.set_colorkey(colorkey, pygame.RLEACCEL)
return image
Binary file added media/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 22 additions & 8 deletions units.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,33 @@ def screenCoords(self):

class Home(pygame.sprite.Sprite, Unit):

class Ent(pygame.sprite.Sprite):
class Ent(pygame.sprite.Sprite, home):
def __init__(self):
super(Ent, self).__init__()

#Angle in relation to Home
self.position = 0.0
self.firing = False
self.home = home
#Cooldown for allowing the player to move
self.move_cool = 5
#Cooldown for allowing the player to fire SOILORBS
self.shot_cool = 20

#Returns [x,y] coordinates for the ent moving around the planet
#Param: angle -- angle of the ent relative to the Home
#Param: radius ---- the radius...
@property
def pos(self):
rad = math.radians(self.home.angle)
return vec(math.cos(rad)*self.home.radius, math.sin(rad)*self.home.radius)

def update(self):
if self.firing == True:
print 'Firing!'
self.move_cool -= 1
self.shot_cool -= 1
pass
def draw(self):
pass

def __init__(self):
super(Home, self).__init__()
ent = Ent(self)
self.angle = 0.0
self.mass = 10000
screen = pygame.display.get_surface()
Expand All @@ -38,10 +51,11 @@ def radius(self):
return math.sqrt(float(self.mass)/math.pi)

def update(self):
ent.update()
pass

def draw(self, screen):

ent.draw()
pygame.draw.circle(screen, [255,255,0], self.screenCoords, int(self.radius), 0)


Expand Down

0 comments on commit a631b4a

Please sign in to comment.