Created
January 30, 2017 03:46
-
-
Save ericlifka/c7792a827a29e6ef722bb3b44d5bb623 to your computer and use it in GitHub Desktop.
test-game.py
This file contains hidden or 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 | |
import random | |
import math | |
class MyScene (Scene): | |
def setup(self): | |
self.background_color = 'midnightblue' | |
self.ship = SpriteNode('spc:PlayerShip1Orange') | |
self.ship.position = self.size / 2 | |
self.add_child(self.ship) | |
def did_change_size(self): | |
pass | |
def update(self): | |
x, y, z = gravity() | |
pos = self.ship.position | |
pos += (y * -15, z * -q15, 0) | |
# check boundaries | |
pos.x = max(0, min(self.size.w, pos.x)) | |
pos.y = max(0, min(self.size.h, pos.y)) | |
self.ship.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') | |
def touch_moved(self, touch): | |
pass | |
def touch_ended(self, touch): | |
pass | |
if __name__ == '__main__': | |
run(MyScene(), show_fps=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment