Changeset 66:8bf0459ebc56


Ignore:
Timestamp:
Sep 1, 2013, 5:53:18 PM (7 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Message:

Clean up a few things.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/protagonist.py

    r65 r66  
    1 import pygame
    21import pymunk
    32import pymunk.pygame_util
     
    3029
    3130    def _setup_physics(self, position):
    32         self.body = pymunk.Body(10, 10000)
    33         self.body.position = position
    34         self.body.velocity_func = self.velocity_func
     31        self._body = pymunk.Body(10, 10000)
     32        self._body.position = position
     33        self._body.velocity_func = self.velocity_func
    3534
    36         self.shape = pymunk.Circle(self.body, 30)
     35        self.shape = pymunk.Circle(self._body, 30)
    3736        self.shape.elasticity = 1.0
    3837        self.shape.friction = 10.0
     38
     39    def _get_image(self, name, *transforms):
     40        return resources.get_image('creatures', name, transforms=transforms)
    3941
    4042    def _setup_renderers(self):
    4143        self._renderers = {
    4244            self.HUMAN_FORM: FacingImageRenderer(
    43                 resources.get_image(
    44                     'creatures', 'werewolf_1.png', transforms=(BLUE,)),
    45                 resources.get_image(
    46                     'creatures', 'werewolf_1.png', transforms=(FLIP_H, BLUE))),
     45                self._get_image('werewolf_1.png', BLUE),
     46                self._get_image('werewolf_1.png', BLUE, FLIP_H)),
    4747            self.WOLF_FORM: FacingImageRenderer(
    48                 resources.get_image('creatures', 'werewolf_1.png'),
    49                 resources.get_image(
    50                     'creatures', 'werewolf_1.png', transforms=(FLIP_H,))),
     48                self._get_image('werewolf_1.png'),
     49                self._get_image('werewolf_1.png', FLIP_H)),
    5150        }
    5251
     
    6463    def go_werewolf(self):
    6564        self.form = self.WOLF_FORM
    66         self.body.mass = 100
    67         self.body.moment = 10000
    68         self.body.velocity_limit = 1000
    69         self.shape.color = pygame.color.THECOLORS['red']
     65        self._body.mass = 100
     66        self._body.moment = 10000
     67        self._body.velocity_limit = 1000
    7068        self.impulse_factor = 4000
    7169        self.damping = 0.9
     
    7472    def go_human(self):
    7573        self.form = self.HUMAN_FORM
    76         self.body.mass = 10
    77         self.body.moment = 1000
    78         self.body.velocity_limit = 1000
    79         self.shape.color = pygame.color.THECOLORS['blue']
     74        self._body.mass = 10
     75        self._body.moment = 1000
     76        self._body.velocity_limit = 1000
    8077        self.impulse_factor = 500
    8178        self.damping = 0.8
     
    8683            return
    8784        vec = pymunk.Vec2d((dx, dy))
    88         self.body.angle = vec.angle
    89         self.body.apply_impulse(
     85        self._body.angle = vec.angle
     86        self._body.apply_impulse(
    9087            (dx * self.impulse_factor, dy * self.impulse_factor))
    9188
Note: See TracChangeset for help on using the changeset viewer.