omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    How do you make game landscape?

    Pythonista
    1
    1
    750
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Penguin Master
      Penguin Master last edited by Penguin Master

      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) ```
      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Powered by NodeBB Forums | Contributors