# Flappy bird browsing

• posted
1

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

• posted
0

@Karina said:

1. self.point=Point(w() + self.position.w, h() - self.size.h)
If w() and self.size.w are the same here, then we got 2*self.position.w? And why instead of sec arg don't just right 0??

2. When I tried to use sleep(), my screen just got black and I couldn't close it. And also was a problem and it all hang and didn't move. I did smth and fixed it, don't know howπ. But why theese things can happen?

I have hundred of questions on each couple lines)

### 1.

self.point=Point(w() + self.position.w, h() - self.size.h) If w() and self.size.w are the same here, then we got 2self.position.w? And why instead of sec arg don't just right 0??*

self.position.w should be self.position.x
translated self.point=Point(w() + self.position.w, h() - self.size.h) means
Node's Position is a Point Object with x coordinate at screen width plus node's position x and y coordinate at screen height minus nodes hieght.

or in other words

x = screen_width + self.position.x
y = screen_hieght - self.size.hieght
self.position = Point(x, y)

### 2.

When I tried to use sleep(), my screen just got black and I couldn't close it. And also was a problem and it all hang and didn't move. I did smth and fixed it, don't know howπ. But why theese things can happen?

this was my fault lol i forgot you need to att a decorator from ui module

@ui.in_background
time.sleep(5)

• posted
0

@Karina

never too many questions

• posted
0

@Karina now im off to write the game in the way i would. so you can compare. in no way is MY way the best or even the most correct. but it is the way i learned to implement different objects and functionality over the years.

• posted
0

@Karina just an update ive been a bit busy but i might have my project ready in the next 20 hours or so. it wont have a lot of comments but ill put a few. but im trying to use only descriptive naming so it should not beva problem.hope to see what you learned from this project π€π€π€

• posted
0

@stephen said:

self.point=Point(w() + self.position.w, h() - self.size.h) <

Ah, I forgot that we're inside Node, not Scene

i understand what lw() does, but what is lower port width? And lw() is the returns the width, if add bw(), we should get beyond the screen?

self.size.w is somthing crazy like 2389488754589433357

I went to check the self.size.w, and it is 1024. What do you it is smth like thatπ? And why in that case for is better than while?

• posted
0

@karina said:

@stephen said:

self.point=Point(w() + self.position.w, h() - self.size.h)
Ah, I forgot that we're inside Node, not Scene

i understand what lw() does, but what is lower port width? And lw() is the returns the width, if add bw(), we should get beyond the screen?

### Response:

sw β screen width
bw β block width
lw β level view port width

top part and lower part , at least in this case, are the same size width. so both top and bottom parts get their size width from our bw() Block Width.
Yes we do want to add AT LEAST block width past screen width.
Video Games are Feuled by immersion. You wand the End User to feel that our Level already exists.. so they must not see the objects pop into our level. so we do this just outside the view port. same for removinghe objects. we wait till they are at least Block Width negative position if block.w < -block.w: del block.
Also in our position checks we want to compare < for removing blocks and > for adding blocks and not <= and >=. by doing this we get a 1 point buffer insuring our create and delete actions are not visible bo End User.

@karina said:

@stephen said:

self.size.w is somthing crazy like 2389488754589433357

I went to check the self.size.w, and it is 1024. What do you it is smth like thatπ? And why in that case for is better than while?

### Response:

β π€π unlikely i know but just for fun... β

the value 2389488754589433357 this game is simple so this shouldnt happen. you coud see similar if you had bad execution order while using large open world type game environment...

since python has a GIL Global Interpreter Lock both the for and the whie loops are "blocking" and both can be used to achive hat you want.. The only prolem i can see making the for loop better choice here is that a while loop has the possibility of being infinit if somthing doesnt go right where the for loop has a predefined end point. insuring the game will not freeze forever do to your code withen.

did i cover what you were confused for these? im not sure i completey understook your questions. π

• posted
0

I thought of grouping the blocks but don't know how to do it.

It's quite difficult to me to formulate them now cause I don't have anything to write on and can't buy itπΏ But:

I don't know what the timing_sinodial, timing_ease in and others mean. I tried to play with them in examples but didn't see the difference, also anti-alias and its 4x multisampling
And the Brushes, so didn't implement it and MaxSizeBrush, but maybe I will when do the jumps

• posted
0

@Karina ill whip up a quick example that will show the diferences and ill Annotate as much as i can π hang tight

what do you mean you have nothing to write on?

• posted
0

@stephen a notebook or smth and I wouldn't have to look what was in the beginning and had important things in front of me

• posted
0

@Karina said:

@stephen a notebook or smth and I wouldn't have to look what was in the beginning and had important things in front of me

what are you using currently? and im sorry im taking so long to get back but i read overball the comments and im not sure i covered all the questions before. do you still not understand how the following works?

• w()
-update(self)
-self.dt
-self
-self.size.w
-lw()

my final example full game will include all these and more but i dont want you to throw a full script at you unless you can comprehend a good amount. most of what has been covered has been mostly linear and the full script ill feel like a spider web lol but ill annotate as much as i can.

• posted
0

w()
-update(self)
-self.dt
-self
-self.size.w
-lw()

This yes, here it looks quite easy.
I'm trying to write for now like I can, though it's not the best way and I get annoying bugs sometimes
What it means that it all was linear?

the full script ill feel like a spider web lol but ill annotate as much as i can.

Wow I'm scared

• posted
0

@stephen You said @in_background makes smth run on a dif thread. I'm not into the ui for now, but what is the dif thread?

• posted
0

@Karina what i mean by linear is the scripts are writen in a step by step manner. and then the rest is all focused inside the loop body. just a way i refer to simple writing techniques. where alternatively i tend write in a manner that jumps around. multiple inheritence, conroller types, delegates.. and so on.

@karina said:

@stephen You said @in_background makes smth run on a dif thread. I'm not into the ui for now, but what is the dif thread?

ui.in_background() decorator executes the following process in the main thread instead of on your current event loop's. whenever you call module level run() function from scene or class method View.Present()from ui you create a new event loop separate from Interpreters main thread. Python uses GIL (Global Interpreter Lock) that only alows one thread. you can still use multiprocessing though. for info on that check out Asynchronous programming. the reason for GIL is objC memory managment is not considered "Thread Safe".

Docs said:

### ui.in_background(fn):

Call a function on the main interpreter thread. This is useful to perform long-running tasks from an action or delegate callback without blocking the UI. It can also be used for functions that donβt support being called from the main UI thread (e.g. console.alert()).

as far as you not using the ui module... you have been this whole time.. lol scene uses ui quite heavely. and you dont need to import ui separatly. by using from scene import * ui is also included. from your game just call ui. and then whatever you want from there. when you run your scene game it actually prepares the ui stuff for you and then presents a SceneView if you setup a custom View class in your game script you can create a scene.SceneView and set its SceneView.scene property to your Game Object. then instead of using run(MyScene()) you present the View which places your game in its own frame on your screen making it easy to add ui objects as your gui for ur game.

• posted
0

@Karina and im almost finished with the Animation/Actions demo. should be posted later this evening.

currently 5pm my time

• posted
0

@Karina and im almost finished with the Animation/Actions demo. should be posted later this evening.
currently 5pm my time

π

• posted
0

def touch_began(self, touch):
self.player.texture = player_textures[3]
jumping = [A.move_by(0, 100, 0.2), A.wait(1), A.move_by(0, -100, 0.1)]
self.player.run_action(A.sequence(jumping)

I tried to make him jump but it doesn't work. I know there should be a more clever way to do that but I have no idea

• posted
0

@Karina I havenβt used Actions much, I prefer animating nodes myself. But theoretically, from reading the docs, your code should work (assuming your indentation is correct and your actual code doesnβt miss the closed bracket at the end)

• posted
0

@stephen you mean fixing the Node pos by yourself? Action should work smoother and easier to write. If it also worked here)
And why in your program you called this blocks brushes?π

• posted
0

• posted
2

@Karina @Drizzel here is a demo for action timing. i intended to have much more informative and visually attractive version and ill improve it in time but for noe you can see a visual difference between each interpolation.

note: this is formated for ipad only. future versions will have formatting for other devices. i appoligise.

from scene import *

class BaseSign(SpriteNode):
def __init__(self, texture=None, tag='Sign', *args, **kwargs):
super().__init__(texture=texture, *args, **kwargs)
self.anchor_point=(0.0, 1.0)
self.position = Point(10, get_screen_size()[1]-10)
self.z_position=1
self.color='#000000'
self.size=Size(get_screen_size()[0]-20, get_screen_size()[1]-20)
self.bg=SpriteNode(
texture=None,
color='#80cdff',
position=Point(3, -3),
anchor_point=(0.0, 1.0),
size=Size(get_screen_size()[0]-26, get_screen_size()[1]-26),
parent=self)
self.sign=LabelNode(
'',
position=Point(1, 15),
z_position=3,
font=('Ubuntu Mono', 18),
parent=self.bg,
color='#000000',
anchor_point=(0.0, 1.0))

class MyScene (Scene):
def setup(self):
self.dur=5
self.moveToPos=(73, 245)

self.sign=BaseSign(parent=self, position=self.size/2)

self.sign.sign.text=self.Text()
for x in range(16):
b=SpriteNode(Texture('pzl:BallGray'),
size=Size(16, 16),
color='#00f90b',
position=Point(73, (get_screen_size()[1]-132) - 36.15*x),
z_position=9,
parent=self)
b.run_action(
Action.repeat(
Action.sequence(
Action.call(self.UpdateTime, 0.1),
Action.wait(0.5),
Action.move_to(self.moveToPos[1], b.position[1], 2, x),
Action.move_to(self.moveToPos[0], b.position[1], 2, x)),-1))

def UpdateTime(self, node, progress):
if self.speed is 1:
self.speed=0.5
else:
self.speed=1
self.sign.sign.text=self.Text()

def Text(self):
return f'''
ββββββββββββββββββββββββββ
β    BUILT_IN_CONSTANT   β
β βββββ¦βββββββββ¦βββββββββββ£
β 2s β 2 part β 1x speed β
βTIMING_LINEAR           β
βββ‘                    βββ’
βTIMING_EASE_IN_2        β
βββ‘                    βββ’
βTIMING_EASE_IN_2        β
βββ‘                    βββ’
βTIMING_EASE_OUT         β
βββ‘                    βββ’
βTIMING_EASE_OUT_2       β
βββ‘                    βββ’
βTIMING_EASE_IN_OUT      β
βββ‘                    βββ’
βTIMING_SINODIAL         β
βββ‘                    βββ’
βTIMING_ELASTIC_OUT      β
βββ‘                    βββ’
βTIMING_ELASTIC_IN       β
βββ‘                    βββ’
βTIMING_ELASTIC_IN_OUT   β
βββ‘                    βββ’
βTIMING_BOUNCE_OUT       β
βββ‘                    βββ’
βTIMING_BOUNCE_IN        β
βββ‘                    βββ’
βTIMING_BOUNCE_IN_OUT    β
βββ‘                    βββ’
βTIMING_EASE_BACK_IN     β
βββ‘                    βββ’
βTIMING_EASE_BACK_OUT    β
βββ‘                    βββ’
βTIMING_EASE_BACK_IN_OUT β
βββ‘                    βββ’
ββββββββββββββββββββββββββ'''

if __name__ == '__main__':

run(MyScene(), show_fps=True)

Internal error.

Oops! Looks like something went wrong!