Changeset 56:b9430b4a48da


Ignore:
Timestamp:
Sep 1, 2013, 4:51:06 PM (7 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
rebase_source:
be434e81ee3eba66faabc246dfd2deba6f813498
Message:

Now with a werewolf

Location:
nagslang
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nagslang/mutators.py

    r31 r56  
    22
    33import pygame
    4 from pygame.transform import rotate
     4from pygame.transform import rotate, flip
    55
    66
     
    4848R270 = Mutator(rotate, -90)
    4949
     50FLIP_H = Mutator(flip, True, False)
     51FLIP_V = Mutator(flip, False, True)
     52
    5053# Colour
    5154RED = Colour((255, 0, 0))
  • nagslang/screens/area.py

    r53 r56  
    11"""Display a game area."""
    22
     3import math
    34import pygame
    45import pymunk
     
    89from nagslang.level import Level
    910from nagslang.events import ScreenChange
     11from nagslang.resources import resources
     12from nagslang.mutators import FLIP_H
    1013
    1114
     
    4649
    4750    def render(self, surface):
    48         pymunk.pygame_util.draw(surface, self.shape)
     51        if self.werewolf:
     52            pos = pymunk.pygame_util.to_pygame(self.body.position, surface)
     53            transforms = ()
     54            if abs(self.body.angle) < math.pi / 2:
     55                transforms = (FLIP_H,)
     56
     57            wolf = resources.get_image('creatures', 'werewolf_1.png',
     58                                       transforms=transforms)
     59            surface.blit(wolf, pos)
     60        else:
     61            pymunk.pygame_util.draw(surface, self.shape)
    4962
    5063    def go_werewolf(self):
Note: See TracChangeset for help on using the changeset viewer.