Discuss Scratch

monkey2012halfpint
Scratcher
0 posts

How do make a flappy bird game

How do you make a flappy bird game can I have some code help
kiwilover2736
Scratcher
1000+ posts

How do make a flappy bird game

There are various tutorials on YouTube, so i'd recommend searching for one. You can always also check already existing Flappy Bird games here on Scratch!
Zenocker
Scratcher
9 posts

How do make a flappy bird game

Look at some tutorials! They’re basically everywhere.
Just look it up on google/YouTube.

Here’s the first video I found when searching on google:
https://www.youtube.com/watch?v=WNElB_uppNQ
(Not advertisement)
OsomKoolGuy
Scratcher
78 posts

How do make a flappy bird game

you can use some code like this to get the bird to work:
when green flag clicked
forever
if <mouse down?> then
change y by (10)
end
change y by (-10)
end
when green flag clicked
forever
if <touching [sprite1 v] ?> then
stop [all v]
end
end
Then for the pipes you can use
when green flag clicked
forever
repeat until <touching [edge v] ?>
go to x: (-200) y: (0)
change x by (-10)
end
end
You could program a velocity system for the bird if you know how instead of the more simple approach given
youormeletsbringit
Scratcher
71 posts

How do make a flappy bird game

You can get an idea from the code in my project https://scratch.mit.edu/projects/1000104964
abubriski
Scratcher
500+ posts

How do make a flappy bird game

when green flag clicked
forever
change [yV v] by [-1]
change y by (yV)
end
when green flag clicked
forever
if <key [space v] pressed?> then
set [yV v] to [5]
wait until <not <key [space v] pressed?>>
end
end
abubriski
Scratcher
500+ posts

How do make a flappy bird game

abubriski wrote:

when green flag clicked
forever
change [yV v] by [-1]
change y by (yV)
end
when green flag clicked
forever
if <key [space v] pressed?> then
set [yV v] to [5]
wait until <not <key [space v] pressed?>>
end
end
And for the pipes:
when green flag clicked
go to x: (240) y: (0)
forever
wait (pick random (3) to (10)) secs
create clone of [myself v]
end
when I start as a clone
glide (5) secs to x: (-240) y: (0)
delete this clone

Last edited by abubriski (June 5, 2024 12:11:32)

PointerOS_software
Scratcher
35 posts

How do make a flappy bird game

monkey2012halfpint wrote:

How do you make a flappy bird game can I have some code help
Just put this code on the bird sprite:
when green flag clicked
forever
if <not <<key [whichever key] pressed?>>> then
repeat until <(vertical velocity) = [0]>
change [ vertical velocity] by [-1]
end



else
set [ vertical velocity] to [5]
end
end

you can increase the vertical velocity value in the else branch to increase the speed of falling. Also you can rearrange the code so as to omit the “not” operator if u want.

follow this code by:

when green flag clicked
forever
change y by (vertical velocity)
end

then go to the obstacle sprite and you can make some clones scripts for the obstacles and if then clone touching bird, broadcast death, game over.
PointerOS_software
Scratcher
35 posts

How do make a flappy bird game

OsomKoolGuy wrote:

you can use some code like this to get the bird to work:
when green flag clicked
forever
if <mouse down?> then
change y by (10)
end
change y by (-10)
end
when green flag clicked
forever
if <touching [sprite1 v] ?> then
stop [all v]
end
end
Then for the pipes you can use
when green flag clicked
forever
repeat until <touching [edge v] ?>
go to x: (-200) y: (0)
change x by (-10)
end
end
You could program a velocity system for the bird if you know how instead of the more simple approach given
The mouse down script could be abused and players could just hold onto the mouse button instead of clicking in an order, also changing Y this drastically will make way for some choppy movements.
ayushdel_test
Scratcher
1 post

How do make a flappy bird game

Bird code -
when green flag clicked
set [gravity v] to [0]
set [canI v] to [1]
forever
change y by (gravity)
change [gravity v] by (-1)
if <touching [obs v] ?> then
set [gravity v] to [-10]
set [canI v] to [0]
end
if <touching [edge v] ?> then
set [canI v] to [0]
end
end
when [ space v] key pressed
if <(canI) = [1]> then
set [gravity v] to [10]
wait (.1) secs
end

obs-
when green flag clicked
set [score v] to [0]
if <(canI) = [1]> then
set [y v] to (pick random (80) to (-80))
go to x: (290) y: ((y))
glide (1) secs to x: (-290) y: ((y))
if <not <(canI) = [0]>> then
change [score v] by (1)
end
end

Last edited by ayushdel_test (June 6, 2024 10:03:36)

abubriski
Scratcher
500+ posts

How do make a flappy bird game

PointerOS_software wrote:

OsomKoolGuy wrote:

you can use some code like this to get the bird to work:
when green flag clicked
forever
if <mouse down?> then
change y by (10)
end
change y by (-10)
end
when green flag clicked
forever
if <touching [sprite1 v] ?> then
stop [all v]
end
end
Then for the pipes you can use
when green flag clicked
forever
repeat until <touching [edge v] ?>
go to x: (-200) y: (0)
change x by (-10)
end
end
You could program a velocity system for the bird if you know how instead of the more simple approach given
The mouse down script could be abused and players could just hold onto the mouse button instead of clicking in an order, also changing Y this drastically will make way for some choppy movements.
That's why I made sure to do it this way (I am not @OsomKoolGuy):

abubriski wrote:

when green flag clicked
forever
change [yV v] by [-1]
change y by (yV)
end
when green flag clicked
forever
if <key [space v] pressed?> then
set [yV v] to [5]
wait until <not <key [space v] pressed?>>
end
end

Powered by DjangoBB