Created
May 21, 2016 18:19
-
-
Save ssophwang/993ffd3174aed52b45a8f4506ed518af to your computer and use it in GitHub Desktop.
Super_Alien.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scene import * | |
import sound | |
class GameEnvironment(object): | |
def __init__(self): | |
self.background_speed = 2 | |
class MyScene (Scene): | |
def setup(self): | |
self.env = GameEnvironment() | |
self.dirtblocks = [] | |
for i in range(22): | |
dirtblock = SpriteNode('plc:Dirt_Block') | |
dirtblock.position = (i * 50 + 40, 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 | |
if dirtblock.position[0] <= -dirtblock.size.w/2: | |
dirtblock.position = (dirtblock.position[0] + dirtblock.size.w * 21.77, dirtblock.position.y) | |
def touch_began(self, touch): | |
global dirtblock | |
# laser = SpriteNode('spc:LaserBlue9', position = dirtblock.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