Skip to content

Instantly share code, notes, and snippets.

@SpaceVoyager
Created May 21, 2016 18:02
Show Gist options
  • Select an option

  • Save SpaceVoyager/3be5b8783d982512cce2886caeb6da88 to your computer and use it in GitHub Desktop.

Select an option

Save SpaceVoyager/3be5b8783d982512cce2886caeb6da88 to your computer and use it in GitHub Desktop.
blocksexample.py
from scene import *
import sound
class GameEnvironment(object):
def __init__(self):
self.background_speed = 1
class MyScene (Scene):
def setup(self):
self.env = GameEnvironment()
self.dirtblocks = []
for i in range(3):
dirtblock = SpriteNode('plc:Dirt_Block')
dirtblock.position = (100*(i+10), dirtblock.size.h/2)
self.add_child(dirtblock)
self.dirtblocks.append(dirtblock)
self.background_color = 'midnightblue'
def update(self):
for dirtblock in self.dirtblocks:
pos = dirtblock.position
pos.x -= self.env.background_speed
dirtblock.position = pos
def touch_began(self, touch):
laser = SpriteNode('spc:LaserBlue9', position=self.ship.position, z_position=-1, parent=self)
laser.run_action(Action.sequence(Action.move_by(0, 1000), Action.remove()))
sound.play_effect('arcade:Laser_1')
run(MyScene())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment