Changeset 25:e93eac7cf8c2


Ignore:
Timestamp:
Sep 1, 2013, 1:57:07 PM (7 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
rebase_source:
9021a033e4127b4dc786fa035e9ee7c2a01c34f3
Message:

Consider a spherical werewolf.

Location:
nagslang
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nagslang/engine.py

    r20 r25  
    4040            self._current_screen.render(self._surface)
    4141            pygame.display.flip()
    42             self._clock.tick(self._fps)
     42            ms = self._clock.tick(self._fps)
     43            self._current_screen.tick(ms / 1000.)
  • 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.