Skip to content

Commit

Permalink
Parrot image in the game.
Browse files Browse the repository at this point in the history
  • Loading branch information
illume committed Jul 14, 2019
1 parent 5146e00 commit 85bbbcc
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ For making music, and visuals. [https://github.com/pygame/parrotjoy](https://git




## Get started.

### Installation
Expand Down
Binary file added parrotjoy/data/images/parrotjoy-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion parrotjoy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@


class App:
FLAGS = pg.SCALED | pg.FULLSCREEN
FLAGS = pg.FULLSCREEN
FLAGS = 0
FLAGS = pg.SCALED | pg.FULLSCREEN
WIDTH = 1024
HEIGHT = 768
# FPS = 30
Expand Down
35 changes: 25 additions & 10 deletions parrotjoy/scenes/looper/looper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from parrotjoy.draw_sound import draw_wave
from parrotjoy.camera_cv import VideoThread
from parrotjoy.tracks import Track

from parrotjoy.resources import gfx


class Joy:
Expand Down Expand Up @@ -351,6 +351,18 @@ def update(self):
# print (self.state, self.track.recording, self.track.add_to_mode)


class Parrot(pg.sprite.DirtySprite):
"""
"""
def __init__(self):
pg.sprite.DirtySprite.__init__(self)
self.image = gfx('parrotjoy-logo.png')
self.rect = self.image.get_rect().copy()
self.rect.x = pg.display.get_surface().get_width() - self.rect.width
self.rect.y = 20
# self.dirty = 1


class Gif:
def __init__(self):
self.path = '/tmp/'
Expand Down Expand Up @@ -399,8 +411,8 @@ def update(self, events, screen):
self.surfs.append(screen.copy())




# CAMERA_RES = list(map(int, [640//1.3, 480//1.3]))
CAMERA_RES = [480, 360]

class Looper:
def __init__(self, app):
Expand All @@ -412,7 +424,9 @@ def __init__(self, app):
# We loop quickly so timing can be more accurate with the sounds.
self.fps = 240

self.video_thread = VideoThread(1, 640, 480)
#TODO: FIXME: this camera id should be selectable.
camera_id = 0
self.video_thread = VideoThread(camera_id, CAMERA_RES[0], CAMERA_RES[1])
self.video_thread.daemon = True
self.video_thread.start()

Expand Down Expand Up @@ -444,6 +458,7 @@ def __init__(self, app):
self.bpm_line = bpm_line


self.parrot = Parrot()

pg.display.set_caption('press space 4 times to adjust BPM timing')
screen = app.screen
Expand All @@ -453,7 +468,7 @@ def __init__(self, app):
background.fill((0, 0, 0))
self.background = background

sprite_list = [bpm_counter, bpm_light, bpm_line] + recording_lights + recording_waves
sprite_list = [bpm_counter, bpm_light, bpm_line] + recording_lights + recording_waves + [self.parrot]
allsprites = pg.sprite.LayeredDirty(
sprite_list,
_time_threshold=1000/10.0
Expand Down Expand Up @@ -497,15 +512,15 @@ def events(self, events):
# allsprites.clear(screen, background)
video_thread.stop()
# video_thread = VideoThread(1, 1920, 1080)
video_thread = VideoThread(1, 640, 480)
video_thread = VideoThread(0, CAMERA_RES[0], CAMERA_RES[1])
video_thread.daemon = True
video_thread.start()
if e.type == pg.KEYDOWN and e.key in [pg.K_v]:
screen.blit(background, (0, 0))
allsprites.clear(screen, background)
video_thread.stop()
# video_thread = VideoThread(1, 1920, 1080)
video_thread = VideoThread(1, 640, 480)
video_thread = VideoThread(0, CAMERA_RES[0], CAMERA_RES[1])
video_thread.daemon = True
video_thread.start()

Expand Down Expand Up @@ -562,9 +577,9 @@ def render(self):
while not video_thread.queue.empty():
surface = video_thread.queue.get()
if surface:
if video_thread.width == 640:
video_x = screen.get_width() - 640
video_y = screen.get_height() - 480
if video_thread.width == CAMERA_RES[0]:
video_x = screen.get_width() - CAMERA_RES[0]
video_y = (screen.get_height() - CAMERA_RES[1]) - 25
else:
video_x = 0
video_y = 0
Expand Down
2 changes: 2 additions & 0 deletions parrotjoy/scenes/videosynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def events(self, events):
))

elif event.type == ONSETS:
# for onset in event.onsets:
# print("onset", onset)
if self.blend == 2:
for onset in event.onsets:
self.visuals.append(Visual(
Expand Down

0 comments on commit 85bbbcc

Please sign in to comment.