# Flappy bird browsing

• posted
1

Hello everyone! I'm writing the game and at the beginning now

• posted
0

my game example will show u MANY things throught and is currently at 1400 lines

@stephen this is *10 more than anything I have ever read😳 Don't worry, you can't show too little things in it😅
I should be an easy game, I thought I the beginning

• posted
0

@Karina ill be posting the example shortly

• posted
0

@Karina said:

``````def touch_began(self, touch):
self.player.run_action(
a.sequence(
a.move_by(128, 64, 0.5, TIMING_LINEAR),
a.wait(0.1),
a.move_by(128, 128, 2, TIMING_LINEAR)), 'tag:player-jump')
``````

But it means he moves on 128 forward, cause move_by(dx, dy, duration, timing_mode). And after wait he should move Dow, so dy with minus? And what is 'tag:player-jump'?

yes your correct i made a boo boo lol i didnt test i just wrote

``````def touch_began(self, touch):
self.player.run_action(
a.sequence(
a.move_by(128, 64, 0.5, TIMING_LINEAR),
a.wait(0.1),
a.move_by(-128, -128, 2, TIMING_LINEAR)), 'tag:player-jump')

``````

• posted
0

@stephen still nothing. I just did copy paste for not to do mistakes. Maybe it's somewhere else in the code

``````from scene import *
import sound
import random
import time

def sw(): return get_screen_size()
def sh(): return get_screen_size()
def bw(): return 64
def bh(): return 96
def so(): return 1 if sw() > sh() else 2
def lw(): return 1024.0 if so() == 1 else 768.0
def lh(): return 1024.0 if so() == 2 else 768.0

A = Action()
player_textures = [Texture('plf:AlienBeige_walk1'),
Texture('plf:AlienBeige_walk2'), Texture('plf:AlienBeige_hit'), Texture('plf:AlienBeige_jump'), Texture('plf:AlienBeige_stand')]

def GroundBlock(parent):
return SpriteNode('plf:Ground_Grass', parent=parent)

def ColumnBlock(parent, x, y):
return SpriteNode('plc:Brown_Block', parent=parent, anchor_point = (0.5, 0), position = Point(x, y))

class BottomBrush(Node):
def __init__(self):
self.ground = GroundBlock(self)
self.position = (self.size.w)

class Game(Scene):
def setup(self):
self.background_color = '#99d7ff'
#to track when 5 seconds passed and need to add a new column
self.time_passed = 0
#add the first column so you don't have to wait for it 5 seconds
self.columns = []
self.moveTo = (220, 120)
x = 0
ground = Node(parent=self)
ground.z_position = -1
#building the upper and lower ground
while x < self.size.w:
lower_tile = SpriteNode('plf:Ground_Grass', position = Point(x, 30))
higher_tile = SpriteNode('plf:Ground_GrassCenter', position = Point(x, 738))
x += bw() - 2

self.player = SpriteNode('plf:AlienBeige_front', parent=self)
self.player.position = (40, 120)
self.play_effect = 0
self.game_over = False

def update(self):
if self.t > 1:
self.player_runs()
self.time_passed += self.dt
if self.time_passed >= 1.5:
self.time_passed = 0
self.column_moves()
self.player_hit()
if self.game_over == True and self.player.position.y < 30:
self.player.remove_from_parent()

def touch_began(self, touch):
#self.player_jumps()
self.player.run_action(
A.sequence(
A.move_by(128, 64, 0.5, TIMING_LINEAR),
A.wait(0.1),
A.move_by(-128, -128, 2, TIMING_LINEAR)), 'tag:player-jump')

def new_game(self):
A.wait(2)
for i in self.columns:
i.remove_from_parent()
self.player.texture = player_textures
self.player.position = (40, 120)

lower = random.randint(0, 360) // bw()
#building the lower part
for i in range(lower):
self.columns.append(ColumnBlock(self, self.size.w + bw(), i*64 + 55))
#building the higher part
for i in range(9 - lower):
self.columns.append(ColumnBlock(self, self.size.w + bw(), (self.size.h - 100) - i*64))

def column_moves(self):
action = A.move_by(-self.size.w - bw(), 0, 0.7, TIMING_SINODIAL)
for i in self.columns:
i.run_action(action)

def player_runs(self):
self.player.x_scale = 1
walking_sounds = ['rpg:Footstep04', 'rpg:Footstep05']
if self.player.position.x <= 200:
step = int(self.player.position.x/5) % 2
self.player.texture = player_textures[step]
action = A.move_by(20, 0, 1.5)
self.player.run_action(action)
self.play_effect += 1
if self.play_effect % 30 == 0:
sound.play_effect(walking_sounds[step])

def player_hit(self):
player_hitbox = Rect(self.player.position.x - 10, self.player.position.y + 10, 10, 10)
for c in self.columns:
if c.frame.intersects(player_hitbox):
self.player.texture = player_textures
self.player.run_action(A.move_by(0, -200, 0.2))
self.game_over = True

def player_jumps(self):
self.player.run_action(
A.sequence(
A.move_by(128, 64, 0.5, TIMING_LINEAR),
A.wait(0.1),
A.move_by(-128, -128, 2, TIMING_LINEAR)), 'tag:player-jump')

run(Game())
``````

• posted
0

@Karina i added isGrounded and adjusted the Actions. it needs some fine tuning but he jumps. im finalizing my game now so after a few touchups ill postit here

``````
from scene import *
import sound
import random
import time

def sw(): return get_screen_size()
def sh(): return get_screen_size()
def bw(): return 64
def bh(): return 96
def so(): return 1 if sw() > sh() else 2
def lw(): return 1024.0 if so() == 1 else 768.0
def lh(): return 1024.0 if so() == 2 else 768.0

A = Action()
player_textures = [Texture('plf:AlienBeige_walk1'),
Texture('plf:AlienBeige_walk2'), Texture('plf:AlienBeige_hit'), Texture('plf:AlienBeige_jump'), Texture('plf:AlienBeige_stand')]

def GroundBlock(parent):
return SpriteNode('plf:Ground_Grass', parent=parent)

def ColumnBlock(parent, x, y):
return SpriteNode('plc:Brown_Block', parent=parent, anchor_point = (0.5, 0), position = Point(x, y))

class BottomBrush(Node):
def __init__(self):
self.ground = GroundBlock(self)
self.position = (self.size.w)

class Game(Scene):
def setup(self):
self.background_color = '#99d7ff'
#to track when 5 seconds passed and need to add a new column
self.time_passed = 0
#add the first column so you don't have to wait for it 5 seconds
self.columns = []
self.moveTo = (220, 120)
x = 0
ground = Node(parent=self)
ground.z_position = -1
#building the upper and lower ground
while x < self.size.w:
lower_tile = SpriteNode('plf:Ground_Grass', position = Point(x, 30))
higher_tile = SpriteNode('plf:Ground_GrassCenter', position = Point(x, 738))
x += bw() - 2

self.player = SpriteNode('plf:AlienBeige_front', parent=self)
self.player.position = (40, 120)
self.play_effect = 0
self.game_over = False
self.isGrounded=True

def update(self):

if self.t > 1:
self.player_runs()
self.time_passed += self.dt
if self.time_passed >= 1.5:
self.time_passed = 0
self.column_moves()
self.player_hit()
if self.game_over == True and self.player.position.y < 30:
self.player.remove_from_parent()

def touch_began(self, touch):
self.player_jumps()

def toggle_Grounded(self):
self.isGrounded = not self.isGrounded

def new_game(self):
A.wait(2)
for i in self.columns:
i.remove_from_parent()
self.player.texture = player_textures
self.player.position = (40, 120)

lower = random.randint(0, 360) // bw()
#building the lower part
for i in range(lower):
self.columns.append(ColumnBlock(self, self.size.w + bw(), i*64 + 55))
#building the higher part
for i in range(9 - lower):
self.columns.append(ColumnBlock(self, self.size.w + bw(), (self.size.h - 100) - i*64))

def column_moves(self):
action = A.move_by(-self.size.w - bw(), 0, 0.9, TIMING_SINODIAL)
for i in self.columns:
i.run_action(action)

def player_runs(self):
self.player.x_scale = 1
walking_sounds = ['rpg:Footstep04', 'rpg:Footstep05']
if self.player.position.x <= 200 and self.isGrounded:
step = int(self.player.position.x/5) % 2
self.player.texture = player_textures[step]
action = A.move_by(20, 0, 0.5)
#self.player.run_action(action)
self.play_effect += 1
if self.play_effect % 30 == 0:
sound.play_effect(walking_sounds[step])

def player_hit(self):
player_hitbox = Rect(self.player.position.x - 10, self.player.position.y + 10, 10, 10)
for c in self.columns:
if c.frame.intersects(player_hitbox):
self.player.texture = player_textures
self.player.run_action(A.move_by(0, -200, 0.2))
self.game_over = True

def player_jumps(self):
self.player.run_action(
A.sequence(
A.move_by(32, 128, 0.5, TIMING_LINEAR),
A.move_to(self.player.position+128, 120, 0.5, TIMING_LINEAR)))

run(Game())

``````

• posted
0

• posted
0

@stephen thank you, I've began to read it

• posted
0

@Karina Awesome if you have any questions please post on the new thread 😉

• posted
0

@Karina also "brushes" are properly used in the example so hopfully you see the diference

Internal error.

Oops! Looks like something went wrong!