Ignore:
Timestamp:
09/01/13 13:57:07 (8 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Phase:
public
Rebase:
39303231613033336534313237623464633738366661303335653965653763326130316333346633
Message:

Consider a spherical werewolf.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/screens/area.py

    r21 r25  
    2727
    2828    def add_protagonist(self, world):
    29         body = pymunk.Body(100, 1000)
    30         body.position = (400, 300)
    31         self.protagonist = pymunk.Circle(body, 30)
    32         self.space.add(self.protagonist)
     29        self.protagonist_body = pymunk.Body(100, 1000)
     30        self.protagonist_body.position = (400, 300)
     31        self.protagonist = pymunk.Circle(self.protagonist_body, 30)
     32        self.space.add(self.protagonist_body, self.protagonist)
     33
     34    def protagonist_move(self, dx, dy):
     35        self.protagonist_body.apply_impulse((dx * 2000, dy * 2000))
    3336
    3437    def handle_event(self, ev):
     
    3639            if ev.key == pygame.locals.K_ESCAPE:
    3740                ScreenChange.post('menu')
     41            elif ev.key == pygame.locals.K_UP:
     42                self.protagonist_move(0, 1)
     43            elif ev.key == pygame.locals.K_DOWN:
     44                self.protagonist_move(0, -1)
     45            elif ev.key == pygame.locals.K_LEFT:
     46                self.protagonist_move(-1, 0)
     47            elif ev.key == pygame.locals.K_RIGHT:
     48                self.protagonist_move(1, 0)
    3849
    3950    def render(self, surface):
Note: See TracChangeset for help on using the changeset viewer.