Penguin Master
Dec 02, 2020 - 00:39
i tried adding "LANDSCAPE" to the run part, but im using a rotation based controls and they only work on portrait. Please help me. Thanks!
```
from scene import *
import sound
import ui
import os
x,y = get_screen_size()
def cmp(a, b):
return ((a > b) - (a < b))
standing_texture = Texture('IMG.GIF')
walk_textures = [Texture('IMG-1.GIF'), Texture('IMG.GIF'), Texture("IMG-2.GIF")]
class Game (Scene):
def setup(self):
self.background_color = '#004f82'
ground = Node(parent=self)
x = 0
while x <= self.size.w + 64:
tile = SpriteNode('plf:Ground_PlanetHalf_mid', position=(x, 0))
ground.add_child(tile)
x += 64
self.player = SpriteNode(standing_texture)
self.player.anchor_point = (0.5, 0)
self.player.position = (self.size.w/2, 32)
self.add_child(self.player)
self.walk_step = -1
def update(self):
g = gravity()
if abs(g.x) > 0.05:
self.player.x_scale = cmp(g.x, 0)
x = self.player.position.x
max_speed = 5
x = max(0, min(self.size.w, x + g.x * max_speed))
self.player.position = x, 32
step = int(self.player.position.x / 40) % 2
if step != self.walk_step:
self.player.texture = walk_textures[step]
sound.play_effect('FART #2.mp3', 0.05, 1.0 + 0.5 * step)
self.walk_step = step
else:
self.player.texture = standing_texture
self.walk_step = -1
if name == 'main':
run(Game(), LANDSCAPE) ```