Commit f37d21f0 authored by Nathan Lovato's avatar Nathan Lovato
Browse files

Add base code for flappy GNU: character controller and pillars

parent 30e18bfb
Pipeline #4932 passed with stage
in 4 minutes and 8 seconds
extends Node
func _ready():
print("Hi, I'm FlossyGnu!")
\ No newline at end of file
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Game.gd" type="Script" id=1]
[ext_resource path="res://gnu/Gnu.tscn" type="PackedScene" id=2]
[ext_resource path="res://Pillar.tscn" type="PackedScene" id=3]
[node name="Game" type="Node" index="0"]
[node name="Game" type="Node2D"]
script = ExtResource( 1 )
[node name="Gnu" parent="." instance=ExtResource( 2 )]
position = Vector2( 190, 960 )
[node name="Pillar" parent="." instance=ExtResource( 3 )]
position = Vector2( 680, 990 )
[node name="Pillar2" parent="." instance=ExtResource( 3 )]
position = Vector2( 1306, 990 )
[gd_scene load_steps=3 format=2]
[ext_resource path="res://assets/pillar_top.png" type="Texture" id=1]
[ext_resource path="res://assets/pillar_bottom.png" type="Texture" id=2]
[node name="Pillar" type="StaticBody2D"]
[node name="pillar_top" type="Sprite" parent="."]
position = Vector2( -10, -584 )
texture = ExtResource( 1 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
position = Vector2( 0, 46 )
polygon = PoolVector2Array( -120, -240, 100, -240, 100, -1060, -120, -1060 )
[node name="pillar_bottom" type="Sprite" parent="."]
position = Vector2( 0, 526 )
texture = ExtResource( 2 )
[node name="CollisionPolygon2D2" type="CollisionPolygon2D" parent="."]
position = Vector2( 0, 1226 )
polygon = PoolVector2Array( -120, -240, 100, -240, 100, -1060, -120, -1060 )
......@@ -2,100 +2,7 @@
[sub_resource type="ProceduralSky" id=1]
radiance_size = 4
sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
sky_curve = 0.25
sky_energy = 1.0
ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
ground_curve = 0.01
ground_energy = 1.0
sun_color = Color( 1, 1, 1, 1 )
sun_latitude = 35.0
sun_longitude = 0.0
sun_angle_min = 1.0
sun_angle_max = 100.0
sun_curve = 0.05
sun_energy = 16.0
texture_size = 2
[resource]
background_mode = 2
background_sky = SubResource( 1 )
background_sky_custom_fov = 0.0
background_color = Color( 0, 0, 0, 1 )
background_energy = 1.0
background_canvas_max_layer = 0
ambient_light_color = Color( 0, 0, 0, 1 )
ambient_light_energy = 1.0
ambient_light_sky_contribution = 1.0
fog_enabled = false
fog_color = Color( 0.5, 0.6, 0.7, 1 )
fog_sun_color = Color( 1, 0.9, 0.7, 1 )
fog_sun_amount = 0.0
fog_depth_enabled = true
fog_depth_begin = 10.0
fog_depth_curve = 1.0
fog_transmit_enabled = false
fog_transmit_curve = 1.0
fog_height_enabled = false
fog_height_min = 0.0
fog_height_max = 100.0
fog_height_curve = 1.0
tonemap_mode = 0
tonemap_exposure = 1.0
tonemap_white = 1.0
auto_exposure_enabled = false
auto_exposure_scale = 0.4
auto_exposure_min_luma = 0.05
auto_exposure_max_luma = 8.0
auto_exposure_speed = 0.5
ss_reflections_enabled = false
ss_reflections_max_steps = 64
ss_reflections_fade_in = 0.15
ss_reflections_fade_out = 2.0
ss_reflections_depth_tolerance = 0.2
ss_reflections_roughness = true
ssao_enabled = false
ssao_radius = 1.0
ssao_intensity = 1.0
ssao_radius2 = 0.0
ssao_intensity2 = 1.0
ssao_bias = 0.01
ssao_light_affect = 0.0
ssao_color = Color( 0, 0, 0, 1 )
ssao_quality = 0
ssao_blur = 3
ssao_edge_sharpness = 4.0
dof_blur_far_enabled = false
dof_blur_far_distance = 10.0
dof_blur_far_transition = 5.0
dof_blur_far_amount = 0.1
dof_blur_far_quality = 1
dof_blur_near_enabled = false
dof_blur_near_distance = 2.0
dof_blur_near_transition = 1.0
dof_blur_near_amount = 0.1
dof_blur_near_quality = 1
glow_enabled = false
glow_levels/1 = false
glow_levels/2 = false
glow_levels/3 = true
glow_levels/4 = false
glow_levels/5 = true
glow_levels/6 = false
glow_levels/7 = false
glow_intensity = 0.8
glow_strength = 1.0
glow_bloom = 0.0
glow_blend_mode = 2
glow_hdr_threshold = 1.0
glow_hdr_scale = 2.0
glow_bicubic_upscale = false
adjustment_enabled = false
adjustment_brightness = 1.0
adjustment_contrast = 1.0
adjustment_saturation = 1.0
extends Camera2D
func _ready():
set_as_toplevel(true)
position = owner.position
func _physics_process(delta):
position.x = owner.position.x
extends KinematicBody2D
onready var tween = get_node("Tween")
onready var sprite = get_node("Sprite")
export(float) var gravity = 4000.0
export(float) var flap_force = 1200.0
export(float) var max_fall_speed = 1200.0
export(float) var max_angular_velocity = PI
export(float) var angular_acceleration = 2.0 * PI
export(float) var speed_horizontal = 280.0
var _velocity = Vector2(speed_horizontal, 0.0)
var _angular_velocity = 0.0
var _idle = true setget set_idle
var _target_angle = 0.0
func _ready():
self._idle = true
func set_idle(value):
_idle = value
set_physics_process(not value)
func _unhandled_input(event):
if event.is_action_pressed("flap"):
if _idle:
self._idle = false
flap()
func flap():
_angular_velocity = 0.0
_velocity.y = -flap_force
_target_angle = -PI / 5.0
if not tween.is_active():
tween.interpolate_property(sprite, 'rotation', sprite.rotation, _target_angle, 0.12, Tween.TRANS_CUBIC, Tween.EASE_OUT)
tween.start()
func _physics_process(delta):
_velocity.y += gravity * delta
_velocity.y = min(_velocity.y, max_fall_speed)
if not tween.is_active() and sprite.rotation < PI / 5.0:
_angular_velocity += angular_acceleration * delta
_angular_velocity = min(_angular_velocity, max_angular_velocity)
sprite.rotate(_angular_velocity * delta)
var motion = _velocity * delta
var collision = move_and_collide(motion)
if collision:
die()
func die():
set_physics_process(false)
set_process_unhandled_input(false)
tween.interpolate_property(sprite, 'scale', sprite.scale, Vector2(), 0.4, Tween.TRANS_QUAD, Tween.EASE_OUT)
tween.start()
func _on_Tween_tween_completed(object, key):
if key == ':scale':
queue_free()
[gd_scene load_steps=5 format=2]
[ext_resource path="res://gnu/Gnu.gd" type="Script" id=1]
[ext_resource path="res://gnu/Camera2D.gd" type="Script" id=2]
[ext_resource path="res://assets/gnu.png" type="Texture" id=3]
[sub_resource type="CircleShape2D" id=1]
radius = 55.8274
[node name="Gnu" type="KinematicBody2D"]
script = ExtResource( 1 )
[node name="Camera2D" type="Camera2D" parent="."]
current = true
process_mode = 0
drag_margin_left = 0.0
drag_margin_top = 0.0
drag_margin_right = 0.0
drag_margin_bottom = 0.0
script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
editor/display_folded = true
position = Vector2( -66.5, 1 )
scale = Vector2( 0.786026, 0.786026 )
texture = ExtResource( 3 )
offset = Vector2( 84.6028, -31.3285 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
[node name="Tween" type="Tween" parent="."]
[connection signal="tween_completed" from="Tween" to="." method="_on_Tween_tween_completed"]
......@@ -6,14 +6,47 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=3
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="FlossyGnu"
config/name="Flappy Gnu"
run/main_scene="res://Game.tscn"
config/icon="res://icon.png"
[display]
window/size/width=1080
window/size/height=1920
window/size/test_width=540
window/size/test_height=960
window/handheld/orientation="portrait"
window/stretch/mode="2d"
window/stretch/aspect="expand"
[input]
flap={
"deadzone": 0.5,
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
]
}
reset={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"unicode":0,"echo":false,"script":null)
]
}
[input_devices]
pointing/emulate_touch_from_mouse=true
[rendering]
environment/default_environment="res://default_env.tres"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment