Added image points to BaseActor class.

This commit is contained in:
2013-01-10 09:29:11 -04:30
parent fc255ed3ef
commit 73ed9fc9cb
2 changed files with 33 additions and 10 deletions

View File

@@ -16,11 +16,10 @@ import game
class IntroState(BaseState):
def __init__(self):
BaseState.__init__(self)
self.count = 0
screen_center = self.get_screen_center()
self.rectangle = pygame.Rect(screen_center[0] - 50, screen_center[1] - 50, 100, 100)
self.next_transition = VALID_STATES['STAY']
self.background_color = (139, 210, 228)
self.screen_vertical_half = pygame.display.Info().current_h / 2
@@ -36,6 +35,7 @@ class IntroState(BaseState):
image2 = pygame.image.load('gfx/submarino1.png')
self.submarine = actor.BaseActor(1, image2, "Submarine", True, True, False)
self.submarine.set_image_point_tuple((117, 284))
# Instert second animation frame of the subamrine.
# Create the particle system.
@@ -54,24 +54,33 @@ class IntroState(BaseState):
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
self.next_transition = VALID_STATES['QUIT']
else:
self.next_transition = VALID_STATES['MENU']
if event.type == pygame.QUIT:
self.next_transition = VALID_STATES['QUIT']
def update(self):
if event.type == pygame.MOUSEBUTTONDOWN:
self.next_transition = VALID_STATES['MENU']
def update(self):
self.sine_movement.update()
sm_position = self.sine_movement.get_position()
self.submarine.set_position([sm_position[0], self.screen_vertical_half + math.sin(0.05 * float(sm_position[0])) * 42.0])
if game.DEBUG:
print
print "OBJECT: " + self.sine_movement.get_name()
print "Velocity: " + str(self.sine_movement.get_velocity())
print "Position: " + str(self.sine_movement.get_position())
print self.sine_movement.is_moving()
if self.next_transition != VALID_STATES['QUIT']:
sm_position = self.sine_movement.get_position()
if sm_position[0] > pygame.display.Info().current_w + 300:
if sm_position[0] > pygame.display.Info().current_w + 300:
self.next_transition = VALID_STATES['MENU']
else:
self.next_transition = VALID_STATES['STAY']
return self.next_transition
def render(self, canvas):
canvas.fill(self.background_color)
self.sine_movement.draw(canvas)
self.submarine.draw(canvas)