The playlist
Here you will find the playlist of the tutorial about making this game. You can find the official documentation here: http://omz-software.com/pythonista/docs/ios/scene.html#introduction .
I am going to add the new videos util the game will be completed. Have fun.
We made a game before with Pythonista. Now, we want to make it even faster, to show how easy is to make a game on the Ipad with this app, Pythonista.
The Ship
First, we create the ship attaching it to the ground Node.
From the documentation:
from scene import * 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) run(MyScene())
Movement of the ship with tilting
Enemies
# import scene # create a class Game # def setup # create a ground Node # create ship and position # add ship to ground # run the Game from scene import * import random class Game(Scene): def setup(self): ground = Node(parent=self) self.ship = SpriteNode('spc:PlayerShip1Blue') self.ship.position = self.size.w / 2, 51 ground.add_child(self.ship) # def update # use gravity and abs(g.y) to change position # put the limit from 0 to the screen width def update(self): g = gravity() if abs(g.y) > 0.05: self.ship.position = max(0, min(self.size.w, self.ship.position.x + g.x * 120)), 51 # create a class Enemy # import the random module # if random = create enemy at a random pos # make the enemy move if random.random() < .01: enemy = Enemy(parent=self) enemy.position = random.uniform(0, self.size.w), self.size.h+60 enemy.run_action( Action.sequence( Action.move_by(random.uniform(-100,500), 200, 2), Action.move_to(random.uniform(100,500), 500, 2), Action.move_to(random.uniform(100,500), 300,2), Action.move_to(random.uniform(-1,1)*500,0,3), Action.remove() ) ) class Enemy(SpriteNode): def __init__(self, **kwargs): SpriteNode.__init__(self,'spc:EnemyRed1', **kwargs) run(Game())