redid star images
started to add rudimentary animation support --HG-- branch : vssg
5
gametimer.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
def timer_elapsed():
|
||||
"""
|
||||
get the amount of time passed since the last frame was displayed
|
||||
"""
|
||||
return get_
|
BIN
img/base_star_lg.png
Normal file
After Width: | Height: | Size: 529 B |
BIN
img/base_star_lg2.png
Normal file
After Width: | Height: | Size: 552 B |
BIN
img/base_star_md.png
Normal file
After Width: | Height: | Size: 409 B |
BIN
img/base_star_md2.png
Normal file
After Width: | Height: | Size: 467 B |
BIN
img/base_star_sm.png
Normal file
After Width: | Height: | Size: 355 B |
BIN
img/base_star_sm2.png
Normal file
After Width: | Height: | Size: 347 B |
Before Width: | Height: | Size: 272 B After Width: | Height: | Size: 358 B |
BIN
img/blue_dwarf2.png
Normal file
After Width: | Height: | Size: 353 B |
BIN
img/blue_giant1.png
Normal file
After Width: | Height: | Size: 544 B |
BIN
img/blue_giant2.png
Normal file
After Width: | Height: | Size: 538 B |
BIN
img/blue_star1.png
Normal file
After Width: | Height: | Size: 411 B |
BIN
img/blue_star2.png
Normal file
After Width: | Height: | Size: 421 B |
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 358 B |
BIN
img/green_dwarf2.png
Normal file
After Width: | Height: | Size: 354 B |
BIN
img/green_giant1.png
Normal file
After Width: | Height: | Size: 529 B |
BIN
img/green_giant2.png
Normal file
After Width: | Height: | Size: 569 B |
BIN
img/green_star1.png
Normal file
After Width: | Height: | Size: 437 B |
BIN
img/green_star2.png
Normal file
After Width: | Height: | Size: 424 B |
BIN
img/orange_dwarf1.png
Normal file
After Width: | Height: | Size: 359 B |
BIN
img/orange_dwarf2.png
Normal file
After Width: | Height: | Size: 354 B |
BIN
img/orange_giant1.png
Normal file
After Width: | Height: | Size: 534 B |
BIN
img/orange_giant2.png
Normal file
After Width: | Height: | Size: 572 B |
BIN
img/orange_star1.png
Normal file
After Width: | Height: | Size: 434 B |
BIN
img/orange_star2.png
Normal file
After Width: | Height: | Size: 431 B |
Before Width: | Height: | Size: 250 B After Width: | Height: | Size: 339 B |
BIN
img/red_dwarf2.png
Normal file
After Width: | Height: | Size: 308 B |
BIN
img/red_giant1.png
Normal file
After Width: | Height: | Size: 505 B |
BIN
img/red_giant2.png
Normal file
After Width: | Height: | Size: 499 B |
BIN
img/red_star1.png
Normal file
After Width: | Height: | Size: 402 B |
BIN
img/red_star2.png
Normal file
After Width: | Height: | Size: 403 B |
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 351 B |
BIN
img/white_dwarf2.png
Normal file
After Width: | Height: | Size: 346 B |
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 349 B |
BIN
img/yellow_dwarf2.png
Normal file
After Width: | Height: | Size: 350 B |
BIN
img/yellow_giant1.png
Normal file
After Width: | Height: | Size: 515 B |
BIN
img/yellow_giant2.png
Normal file
After Width: | Height: | Size: 533 B |
BIN
img/yellow_star1.png
Normal file
After Width: | Height: | Size: 433 B |
BIN
img/yellow_star2.png
Normal file
After Width: | Height: | Size: 418 B |
39
starmap.py
|
@ -1,5 +1,6 @@
|
|||
import math
|
||||
import pygame
|
||||
import random
|
||||
|
||||
class Galaxy(object):
|
||||
def __init__(self, width, height):
|
||||
|
@ -50,8 +51,16 @@ class StarSys(object):
|
|||
self.habitat = habitat
|
||||
self.minerals = minerals
|
||||
def draw(self, surf):
|
||||
frame = random.random()
|
||||
if frame > 0.5:
|
||||
frame = 1
|
||||
else:
|
||||
frame = 2
|
||||
self.startype.draw(surf, int(self.x / 10), int(self.y / 10), frame)
|
||||
|
||||
self.startype.draw(surf, int(self.x / 10), int(self.y / 10))
|
||||
def set_frame_timers(self, show1, show2):
|
||||
self.show1 = show1
|
||||
self.show2 = show2
|
||||
|
||||
class StarClass(object):
|
||||
def __init__(self, name, color, size, habitat_mod, minerals_mod):
|
||||
|
@ -60,13 +69,23 @@ class StarClass(object):
|
|||
self.size = size
|
||||
self.habitat_mod = habitat_mod
|
||||
self.minerals_mod = minerals_mod
|
||||
self.pngsurf = None
|
||||
self.png1 = None
|
||||
self.png2 = None
|
||||
|
||||
def draw(self, surf, x, y):
|
||||
if self.pngsurf == None:
|
||||
self.pngsurf = pygame.image.load('img/%s_dwarf1.png' % (self.color.lower(),))
|
||||
self.pngsurf.convert_alpha(surf)
|
||||
dest = self.pngsurf.get_rect()
|
||||
dest.x = x - (dest.w / 2) + 1
|
||||
dest.y = y - (dest.h / 2) + 1
|
||||
surf.blit(self.pngsurf, dest)
|
||||
def draw(self, surf, x, y, frame):
|
||||
if self.png1 == None:
|
||||
self.png1 = pygame.image.load('img/%s_%s1.png' % (self.color.lower(), self.size.lower()))
|
||||
self.png1.convert_alpha(surf)
|
||||
self.png2 = pygame.image.load('img/%s_%s2.png' % (self.color.lower(), self.size.lower()))
|
||||
self.png2.convert_alpha(surf)
|
||||
if frame == 1:
|
||||
dest = self.png1.get_rect()
|
||||
dest.x = x - (dest.w / 2) + 1
|
||||
dest.y = y - (dest.h / 2) + 1
|
||||
surf.blit(self.png1, dest)
|
||||
else:
|
||||
dest = self.png2.get_rect()
|
||||
dest.x = x - (dest.w / 2) + 1
|
||||
dest.y = y - (dest.h / 2) + 1
|
||||
surf.blit(self.png2, dest)
|
||||
|
|
@ -164,6 +164,7 @@ def starmap_generate():
|
|||
print "Generated star %s %s %s at (%s, %s)" % (startype.name, hab, min, int(x), int(y))
|
||||
|
||||
star = StarSys(int(x), int(y), startype, hab, min)
|
||||
star.set_frame_timers(0.1 + (random.random() * 2), 0.1 + (random.random() * 2))
|
||||
map.add_star(star)
|
||||
|
||||
i += 1
|
||||
|
|