Skip to content

Commit

Permalink
Day 3
Browse files Browse the repository at this point in the history
-New Colored Birds
  • Loading branch information
pfaj authored May 19, 2021
1 parent 44c5049 commit 33a07a9
Show file tree
Hide file tree
Showing 14 changed files with 549 additions and 15 deletions.
Binary file added Flappy Bird/Flappy Bird.pck
Binary file not shown.
4 changes: 3 additions & 1 deletion Flappy Bird/Global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var started = false
var lost = false
var score = 0
var high_score = 0
var new_score = true
var new_score = false

func lose():
started = false
Expand All @@ -20,6 +20,7 @@ func lose():


func reset():
$button_press.play()
Global.new_score = false
started = false
lost = false
Expand All @@ -38,6 +39,7 @@ func calculate_high_score(current_score):
var last_high_score = config.get_value("score", "high_score", 0)
if current_score > last_high_score:
high_score = current_score
print("new")
new_score = true
config.set_value("score", "high_score", high_score)
config.save("user://score.txt")
Expand Down
8 changes: 7 additions & 1 deletion Flappy Bird/Global.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=6 format=2]

[ext_resource path="res://assets/audio/hit.wav" type="AudioStream" id=1]
[ext_resource path="res://assets/audio/die.wav" type="AudioStream" id=2]
[ext_resource path="res://Global.gd" type="Script" id=3]
[ext_resource path="res://assets/audio/point.wav" type="AudioStream" id=4]
[ext_resource path="res://assets/audio/swoosh.wav" type="AudioStream" id=5]

[node name="Node" type="Node"]
script = ExtResource( 3 )
Expand All @@ -19,3 +20,8 @@ stream = ExtResource( 2 )
[node name="score_sound" type="AudioStreamPlayer2D" parent="."]
position = Vector2( 240, 427 )
stream = ExtResource( 4 )
volume_db = -5.0

[node name="button_press" type="AudioStreamPlayer2D" parent="."]
position = Vector2( 240, 427 )
stream = ExtResource( 5 )
Binary file added Flappy Bird/assets/textures/black_bird.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Flappy Bird/assets/textures/black_bird.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/black_bird.png-98c71c0cede720320c50b22694da6ec9.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/textures/black_bird.png"
dest_files=[ "res://.import/black_bird.png-98c71c0cede720320c50b22694da6ec9.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
Binary file added Flappy Bird/assets/textures/blue_bird.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Flappy Bird/assets/textures/blue_bird.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/blue_bird.png-05075f2001d5ee7d2c0aefbde5961951.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/textures/blue_bird.png"
dest_files=[ "res://.import/blue_bird.png-05075f2001d5ee7d2c0aefbde5961951.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
Binary file added Flappy Bird/assets/textures/red_bird.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Flappy Bird/assets/textures/red_bird.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/red_bird.png-89ec0347c9ecc55ffa95a9e81425d4fa.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/textures/red_bird.png"
dest_files=[ "res://.import/red_bird.png-89ec0347c9ecc55ffa95a9e81425d4fa.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
32 changes: 28 additions & 4 deletions Flappy Bird/character/player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ extends RigidBody2D
export var FLAP_FORCE = -300
onready var animator = $AnimationPlayer


func _process(delta):
if Input.is_action_just_pressed("flap"):
if !Global.started and !Global.lost:
Expand All @@ -13,19 +12,44 @@ func _process(delta):

if linear_velocity.y == 0 and Global.started:
$Sprite.rotation_degrees = 90
elif linear_velocity.y < 0:

$red_bird.rotation_degrees = 90

$blue_bird.rotation_degrees = 90

$black_bird.rotation_degrees = 90

elif linear_velocity.y < 0:
$Sprite.rotation_degrees = lerp($Sprite.rotation_degrees, -30, 25 * delta)

$red_bird.rotation_degrees = lerp($red_bird.rotation_degrees, -30, 25 * delta)

$blue_bird.rotation_degrees = lerp($blue_bird.rotation_degrees, -30, 25 * delta)

$black_bird.rotation_degrees = lerp($black_bird.rotation_degrees, -30, 25 * delta)
else:
$Sprite.rotation_degrees = lerp($Sprite.rotation_degrees, linear_velocity.y / 6, 25 * delta)
$Sprite.rotation_degrees = clamp($Sprite.rotation_degrees, -90, 90)


$red_bird.rotation_degrees = lerp($red_bird.rotation_degrees, linear_velocity.y / 6, 25 * delta)
$red_bird.rotation_degrees = clamp($red_bird.rotation_degrees, -90, 90)

$blue_bird.rotation_degrees = lerp($blue_bird.rotation_degrees, linear_velocity.y / 6, 25 * delta)
$blue_bird.rotation_degrees = clamp($blue_bird.rotation_degrees, -90, 90)

$black_bird.rotation_degrees = lerp($black_bird.rotation_degrees, linear_velocity.y / 6, 25 * delta)
$black_bird.rotation_degrees = clamp($black_bird.rotation_degrees, -90, 90)

func start():
if Global.started: return
Global.started = true
gravity_scale = 8.50
animator.play("flap")

$red_bird_ani.play("flap")
$blue_bird_ani.play("flap")
$black_bird_ani.play("flap")
$button_press.play()

func flap():
linear_velocity.y = FLAP_FORCE
$AudioStreamPlayer2D.play()
Expand Down
Loading

0 comments on commit 33a07a9

Please sign in to comment.