Commit f565a7a4 authored by Nelso Jost's avatar Nelso Jost

FIX: finished maze code, improved calibration

parent ad208926
......@@ -15,19 +15,27 @@ run:
firmware:
cd firmware && make
setup: install-pygame install-paigamu install-python-deps install-platformiowizard
setup:
$(MAKE) check-pygame || $(MAKE) install-pygame
$(MAKE) install-paigamu
$(MAKE) install-python-deps
$(MAKE) install-platformiowizard
check-pygame:
@ (python3 -c "import pygame" && echo "[OK] pygame installed") || \
echo "[FAIL] pygame is not installed"
install-pygame:
@ python3 -c "import pygame" || (sudo apt-get install python3-dev \
sudo apt-get update && sudo apt-get install python3-dev \
python3-numpy libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev \
libsdl-ttf2.0-dev libsmpeg-dev libportmidi-dev libavformat-dev \
libswscale-dev libjpeg-dev libfreetype6-dev mercurial && \
hg clone https://bitbucket.org/pygame/pygame && \
cd pygame && python3 setup.py build && \
cd pygame && sudo python3 setup.py install && \
rm -rf pygame)
@ (python3 -c "import pygame" && echo "[OK] pygame installed") || \
echo "[FAIL] pygame is not installed"
libswscale-dev libjpeg-dev libfreetype6-dev mercurial
rm -rf pygame
hg clone https://bitbucket.org/pygame/pygame
cd pygame && python3 setup.py build
sudo python3 setup.py install
rm -rf pygame
install-paigamu:
@ python3 -c "import paigamu" || ( \
......
......@@ -29,47 +29,46 @@ class MainScene(Scene):
size=(50, 50),
left=100,
centery=self.rect.centery,
vel=(0, 400),
control_with='keyboard',
vel=(0, 200),
control_with='joystick',
keymap={'up': 'K_w', 'down': 'K_s'})
self['top_maze'] = MazeSprite(
points=[(0, 200), (200, 0), (400, 200), (600, 0), (800, 200)],
line_color='white',
vel=[-100, 0])
vel=[-150, 0])
self['top_maze'].shift(dy=50)
self['bottom_maze'] = MazeSprite(
points=[(0, 400), (200, 200), (400, 400), (600, 200), (800, 400)],
line_color='white',
vel=[0, 0])
color_state='normal',
vel=[-150, 0])
self['bottom_maze'].shift(dy=50)
self.last_maze = self['top_maze']
def on_gameloop(self):
if self.last_maze[-1].x <= self.rect.right:
if 'bottom_maze' in self:
del self['bottom_maze']
else:
self.old_maze = self.last_maze
self.last_maze = self['new_top_maze'] = MazeSprite(
points=[(0, 200), (200, 0), (400, 200), (600, 0), (800, 200)],
line_color='white',
vel=[-100, 0])
self['new_top_maze'].shift(dx=self.rect.w, dy=50)
if self.
# self.old_maze = self['top_maze']
# self.last_maze = self['top_maze2']
class MazeSprite(PathSprite):
running_x = True
COLORS = {'normal': Color('white'), 'colliding': Color('red')}
color_state = 'normal'
def update(self):
self.run(self.app.dt)
if self[-1].x <= self.scene.rect.right:
self.append(Vec2D(self[-1].x + 200, self[-2].y))
if self[1].x <= self.scene.rect.left:
del self[0]
@property
def line_color(self):
return self.COLORS[self.color_state]
@line_color.setter
def line_color(self, value):
pass
class PlayerSprite(Sprite):
running = False
......@@ -87,6 +86,11 @@ class PlayerSprite(Sprite):
self.vel.y += self.app.dt * self.accel.y
self.y += self.app.dt * self.vel.y
# if self.path_collide(self.scene['top_maze']):
# self.scene['top_maze'].color_state = 'colliding'
# else:
# self.scene['top_maze'].color_state = 'normal'
def handle_keydown(self, event):
if event.key == pygame.K_DOWN:
self.vel.j, self.running = 1, True
......@@ -102,15 +106,15 @@ class PlayerSprite(Sprite):
self.running = False
def handle_joystick(self):
_MAX_VEL = 300
_MAX_VEL = 150
self.joystick_respirometro.update()
if self.joystick_respirometro.inhaling():
self.accel.y = 200
self.accel.y = 1000
self.vel.j, self.running = 1, True
# print('inhaling', self.pos, self.vel, self.app.dt)
elif self.joystick_respirometro.exhaling():
self.accel.y = -200
self.accel.y = -1000
self.vel.j, self.running = -1, True
# print('exhaling', self.pos, self.vel, self.app.dt)
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment