Changeset 21:1b048d2a8411


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

Fake area.

Location:
nagslang/screens
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nagslang/screens/area.py

    r20 r21  
    22
    33import pygame
     4import pymunk
     5import pymunk.pygame_util
    46
    57from nagslang.screens.base import Screen
     
    810
    911class AreaScreen(Screen):
     12
     13    def setup(self, world):
     14        self.add_walls(world)
     15        self.add_protagonist(world)
     16
     17    def add_walls(self, world):
     18        self.walls = []
     19        body = pymunk.Body()
     20        body.position = (400, 300)
     21        corners = [(-200, -150), (-200, 150), (200, 150), (200, -150)]
     22        corner = corners[-1]
     23        for next_corner in corners:
     24            self.walls.append(pymunk.Segment(body, corner, next_corner, 5))
     25            corner = next_corner
     26        self.space.add(*self.walls)
     27
     28    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)
     33
    1034    def handle_event(self, ev):
    1135        if ev.type == pygame.locals.KEYDOWN:
     
    1539    def render(self, surface):
    1640        surface.fill(pygame.color.Color(0, 0, 0))
     41        pymunk.pygame_util.draw(surface, *self.walls)
     42        pymunk.pygame_util.draw(surface, self.protagonist)
  • nagslang/screens/menu.py

    r20 r21  
    1717
    1818    def render(self, surface):
     19        surface.fill(pygame.color.Color(0, 0, 0))
    1920        color = pygame.color.Color(255, 0, 0)
    2021        rect = pygame.rect.Rect(10, 10, 200, 200)
Note: See TracChangeset for help on using the changeset viewer.