commit f73c86d4a1bad2067cef81d38d4e059161bb9ce7 Author: ajuvercr Date: Tue Jan 14 22:20:17 2020 +0100 init diff --git a/.import/Mobile - Flappy Bird - Version 12 Sprites.png-50665e675b70d6f6b5054e9d15ad7653.md5 b/.import/Mobile - Flappy Bird - Version 12 Sprites.png-50665e675b70d6f6b5054e9d15ad7653.md5 new file mode 100644 index 0000000..b9c34eb --- /dev/null +++ b/.import/Mobile - Flappy Bird - Version 12 Sprites.png-50665e675b70d6f6b5054e9d15ad7653.md5 @@ -0,0 +1,3 @@ +source_md5="5438542557626c9814ef2162a19e2908" +dest_md5="0ef11008070ef53cd0839c6e85118d97" + diff --git a/.import/Mobile - Flappy Bird - Version 12 Sprites.png-50665e675b70d6f6b5054e9d15ad7653.stex b/.import/Mobile - Flappy Bird - Version 12 Sprites.png-50665e675b70d6f6b5054e9d15ad7653.stex new file mode 100644 index 0000000..2510fef Binary files /dev/null and b/.import/Mobile - Flappy Bird - Version 12 Sprites.png-50665e675b70d6f6b5054e9d15ad7653.stex differ diff --git a/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 new file mode 100644 index 0000000..f75f542 --- /dev/null +++ b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 @@ -0,0 +1,3 @@ +source_md5="8dd9ff1eebf38898a54579d8c01b0a88" +dest_md5="da70afec3c66d4e872db67f808e12edb" + diff --git a/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex new file mode 100644 index 0000000..46e6d2a Binary files /dev/null and b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex differ diff --git a/.import/sprites.png-7e797c86c60ebf1baad54990ba20f2d3.md5 b/.import/sprites.png-7e797c86c60ebf1baad54990ba20f2d3.md5 new file mode 100644 index 0000000..b9c34eb --- /dev/null +++ b/.import/sprites.png-7e797c86c60ebf1baad54990ba20f2d3.md5 @@ -0,0 +1,3 @@ +source_md5="5438542557626c9814ef2162a19e2908" +dest_md5="0ef11008070ef53cd0839c6e85118d97" + diff --git a/.import/sprites.png-7e797c86c60ebf1baad54990ba20f2d3.stex b/.import/sprites.png-7e797c86c60ebf1baad54990ba20f2d3.stex new file mode 100644 index 0000000..2510fef Binary files /dev/null and b/.import/sprites.png-7e797c86c60ebf1baad54990ba20f2d3.stex differ diff --git a/Camera2D.gd b/Camera2D.gd new file mode 100644 index 0000000..0f53f48 --- /dev/null +++ b/Camera2D.gd @@ -0,0 +1,19 @@ +extends Node + +onready var screen_size = Vector2(ProjectSettings.get("display/window/size/width"), ProjectSettings.get("display/window/size/height")) +onready var player = get_node("Player") + +func update_view(): + var canvas_transform = get_viewport().get_canvas_transform() + var pos = player.position + pos.y = 0 + canvas_transform[2] = -player.position + screen_size / 2 + get_viewport().set_canvas_transform(canvas_transform) + +func _ready(): + update_view() + +func _on_Player_move(): + print("moving") + update_view() + pass # Replace with function body. diff --git a/Main.tscn b/Main.tscn new file mode 100644 index 0000000..ad129d3 --- /dev/null +++ b/Main.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://Camera2D.gd" type="Script" id=1] +[ext_resource path="res://icon.png" type="Texture" id=2] +[ext_resource path="res://Player.tscn" type="PackedScene" id=3] + +[node name="View" type="Node"] +script = ExtResource( 1 ) + +[node name="Background" type="TextureRect" parent="."] +margin_top = -320.0 +margin_right = 420.0 +margin_bottom = 320.0 +texture = ExtResource( 2 ) +expand = true + +[node name="Player" parent="." instance=ExtResource( 3 )] +jump_speed = 10 +[connection signal="move" from="Player" to="." method="_on_Player_move"] diff --git a/Player.gd b/Player.gd new file mode 100644 index 0000000..ba07ad3 --- /dev/null +++ b/Player.gd @@ -0,0 +1,31 @@ +extends Area2D + +export var speed = 1 # How fast the player will move (pixels/sec). +export var jump_speed = 10 + +signal move + +var screen_size + +var speed_y = 0 + +func start(): + position = screen_size / 2 + +# Called when the node enters the scene tree for the first time. +func _ready(): + screen_size = get_viewport_rect().size + +func _process(delta): + if Input.is_action_just_pressed("ui_accept"): + print("HERE") + speed_y = min(speed_y, 0) - 1 * jump_speed + + speed_y += 1 + position.x += 1 + position.y += speed_y * speed + + emit_signal("move") + + # TODO find the correct rotation, noob + rotation = atan(speed_y / speed) + PI / 2 diff --git a/Player.tscn b/Player.tscn new file mode 100644 index 0000000..5dc7967 --- /dev/null +++ b/Player.tscn @@ -0,0 +1,28 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://Player.gd" type="Script" id=1] +[ext_resource path="res://icon.png" type="Texture" id=2] + +[sub_resource type="SpriteFrames" id=1] +animations = [ { +"frames": [ ExtResource( 2 ) ], +"loop": true, +"name": "default", +"speed": 5.0 +} ] + +[sub_resource type="CapsuleShape2D" id=2] +radius = 12.8837 +height = 4.07484 + +[node name="Player" type="Area2D"] +position = Vector2( 210, 0 ) +script = ExtResource( 1 ) + +[node name="AnimatedSprite" type="AnimatedSprite" parent="."] +scale = Vector2( 0.498334, 0.531778 ) +frames = SubResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +rotation = 1.5708 +shape = SubResource( 2 ) diff --git a/default_env.tres b/default_env.tres new file mode 100644 index 0000000..20207a4 --- /dev/null +++ b/default_env.tres @@ -0,0 +1,7 @@ +[gd_resource type="Environment" load_steps=2 format=2] + +[sub_resource type="ProceduralSky" id=1] + +[resource] +background_mode = 2 +background_sky = SubResource( 1 ) diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..2b65815 Binary files /dev/null and b/icon.png differ diff --git a/icon.png.import b/icon.png.import new file mode 100644 index 0000000..96cbf46 --- /dev/null +++ b/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.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=true +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=true +svg/scale=1.0 diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..6f75ff9 --- /dev/null +++ b/project.godot @@ -0,0 +1,32 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +_global_script_classes=[ ] +_global_script_class_icons={ + +} + +[application] + +config/name="FlappyBird" +run/main_scene="res://Main.tscn" +config/icon="res://icon.png" + +[display] + +window/size/width=420 +window/size/height=640 + +[rendering] + +quality/driver/driver_name="GLES2" +vram_compression/import_etc=true +vram_compression/import_etc2=false +environment/default_environment="res://default_env.tres" diff --git a/res/Mobile - Flappy Bird - Version 12 Sprites.png.import b/res/Mobile - Flappy Bird - Version 12 Sprites.png.import new file mode 100644 index 0000000..bdd536f --- /dev/null +++ b/res/Mobile - Flappy Bird - Version 12 Sprites.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Mobile - Flappy Bird - Version 12 Sprites.png-50665e675b70d6f6b5054e9d15ad7653.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/Mobile - Flappy Bird - Version 12 Sprites.png" +dest_files=[ "res://.import/Mobile - Flappy Bird - Version 12 Sprites.png-50665e675b70d6f6b5054e9d15ad7653.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=true +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=true +svg/scale=1.0 diff --git a/res/sprites.png b/res/sprites.png new file mode 100644 index 0000000..71ab80b Binary files /dev/null and b/res/sprites.png differ diff --git a/res/sprites.png.import b/res/sprites.png.import new file mode 100644 index 0000000..276158f --- /dev/null +++ b/res/sprites.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/sprites.png-7e797c86c60ebf1baad54990ba20f2d3.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/sprites.png" +dest_files=[ "res://.import/sprites.png-7e797c86c60ebf1baad54990ba20f2d3.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=true +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=true +svg/scale=1.0