diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2022-08-05 20:17:55 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2022-08-05 20:17:55 -0400 |
| commit | 19aba81bd9920c470ff258b35ef14276faa1146e (patch) | |
| tree | 2937e91c1822edaf4ad0fcaf44f8a50ecf303203 /game | |
| parent | cc3ae0f86b824cec321ee7734df4daa22b81af70 (diff) | |
| download | frivolous-run-19aba81bd9920c470ff258b35ef14276faa1146e.tar.gz frivolous-run-19aba81bd9920c470ff258b35ef14276faa1146e.tar.bz2 frivolous-run-19aba81bd9920c470ff258b35ef14276faa1146e.zip | |
Finally some gameplay
Diffstat (limited to 'game')
| -rw-r--r-- | game/Characters/Player/Player.gd | 34 | ||||
| -rw-r--r-- | game/Characters/Player/Player.tscn | 38 | ||||
| -rw-r--r-- | game/FPS.gd | 16 | ||||
| -rw-r--r-- | game/Game.gd | 16 | ||||
| -rw-r--r-- | game/Game.tscn | 39 | ||||
| -rw-r--r-- | game/Interface.tscn | 23 |
6 files changed, 166 insertions, 0 deletions
diff --git a/game/Characters/Player/Player.gd b/game/Characters/Player/Player.gd new file mode 100644 index 0000000..f764015 --- /dev/null +++ b/game/Characters/Player/Player.gd @@ -0,0 +1,34 @@ +extends KinematicBody2D + +const UP = Vector2(0,-1) +export var GRAVITY = 20 +export var MAXFALLSPEED = 200 +export var MAXSPEED = 80 +export var JUMPFORCE = 300 +export var ACCEL = 10 + +var motion = Vector2() + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +func _physics_process(_delta): + + motion.y += GRAVITY + + if motion.y > MAXFALLSPEED: + motion.y = MAXFALLSPEED + + if is_on_floor(): + if Input.is_action_just_released("jump"): + motion.y = -JUMPFORCE + pass + + motion.x = clamp(motion.x,-MAXSPEED,MAXSPEED) + + motion.x += ACCEL + motion = move_and_slide(motion,UP) + + pass diff --git a/game/Characters/Player/Player.tscn b/game/Characters/Player/Player.tscn new file mode 100644 index 0000000..a7ee0e4 --- /dev/null +++ b/game/Characters/Player/Player.tscn @@ -0,0 +1,38 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://assets/images/white.png" type="Texture" id=2] + +[sub_resource type="GDScript" id=2] +script/source = "extends KinematicBody2D + + +# Declare member variables here. Examples: +# var a = 2 +# var b = \"text\" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass +" + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 160, 160 ) + +[node name="Player" type="KinematicBody2D"] +script = SubResource( 2 ) + +[node name="White" type="Sprite" parent="."] +position = Vector2( -4.76837e-07, 0 ) +scale = Vector2( 20, 20 ) +texture = ExtResource( 2 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource( 1 ) + +[node name="Camera2D" type="Camera2D" parent="."] diff --git a/game/FPS.gd b/game/FPS.gd new file mode 100644 index 0000000..8b4c50f --- /dev/null +++ b/game/FPS.gd @@ -0,0 +1,16 @@ +extends Label + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(_delta: float) -> void: + set_text("FPS " + String(Engine.get_frames_per_second())) diff --git a/game/Game.gd b/game/Game.gd new file mode 100644 index 0000000..d144d48 --- /dev/null +++ b/game/Game.gd @@ -0,0 +1,16 @@ +extends Node2D + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/game/Game.tscn b/game/Game.tscn new file mode 100644 index 0000000..426b2ae --- /dev/null +++ b/game/Game.tscn @@ -0,0 +1,39 @@ +[gd_scene load_steps=7 format=2] + +[ext_resource path="res://game/Game.gd" type="Script" id=1] +[ext_resource path="res://game/Interface.tscn" type="PackedScene" id=2] +[ext_resource path="res://assets/tilemap.tres" type="TileSet" id=3] +[ext_resource path="res://assets/images/white.png" type="Texture" id=4] +[ext_resource path="res://game/Characters/Player/Player.gd" type="Script" id=5] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 8, 8 ) + +[node name="World" type="Node2D"] +script = ExtResource( 1 ) + +[node name="Interface" parent="." instance=ExtResource( 2 )] + +[node name="TileMap" type="TileMap" parent="."] +tile_set = ExtResource( 3 ) +cell_size = Vector2( 16, 16 ) +format = 1 +tile_data = PoolIntArray( 1966133, 0, 0, 1966134, 0, 0, 1966135, 0, 0, 1966136, 0, 0, 1966137, 0, 0, 1966138, 0, 0, 1966139, 0, 0, 1966140, 0, 0, 1966141, 0, 0, 1966142, 0, 0, 1966143, 0, 0, 1966144, 0, 0, 1966145, 0, 0, 1966146, 0, 0, 1966147, 0, 0, 1966148, 0, 0, 1966149, 0, 0, 1966150, 0, 0, 1966151, 0, 0, 1966152, 0, 0, 1966153, 0, 0, 1966154, 0, 0, 1966155, 0, 0, 1966156, 0, 0, 1966157, 0, 0, 1966158, 0, 0, 1966159, 0, 0, 2424870, 0, 0, 2424871, 0, 0, 2424872, 0, 0, 2424873, 0, 0, 2424874, 0, 0, 2424875, 0, 0, 2424876, 0, 0, 2424877, 0, 0, 2424878, 0, 0, 2424879, 0, 0, 2424880, 0, 0, 2424881, 0, 0, 2424882, 0, 0, 2424883, 0, 0, 2424884, 0, 0, 2424885, 0, 0, 2424886, 0, 0, 2424887, 0, 0, 2424888, 0, 0, 2424889, 0, 0, 2424890, 0, 0, 2424891, 0, 0, 2424892, 0, 0, 2424893, 0, 0, 2424894, 0, 0, 2424895, 0, 0, 2424896, 0, 0, 2424897, 0, 0, 2424898, 0, 0, 2818048, 0, 0, 2818049, 0, 0, 2818050, 0, 0, 2818051, 0, 0, 2818052, 0, 0, 2818053, 0, 0, 2818054, 0, 0, 2818055, 0, 0, 2818056, 0, 0, 2818057, 0, 0, 2818058, 0, 0, 2818059, 0, 0, 2818060, 0, 0, 2818061, 0, 0, 2818062, 0, 0, 2818063, 0, 0, 2818064, 0, 0, 2818065, 0, 0, 2818066, 0, 0, 2818067, 0, 0, 2818068, 0, 0, 2818069, 0, 0, 2818070, 0, 0, 2818071, 0, 0, 2818072, 0, 0, 2818073, 0, 0, 2818074, 0, 0, 2818075, 0, 0, 2818076, 0, 0, 2818077, 0, 0, 2818078, 0, 0, 2818079, 0, 0, 2818080, 0, 0, 2818081, 0, 0, 2818082, 0, 0, 2818083, 0, 0, 2818084, 0, 0, 2818085, 0, 0, 2818086, 0, 0, 2818087, 0, 0, 2818088, 0, 0, 2818089, 0, 0, 2818090, 0, 0, 2818091, 0, 0, 2818092, 0, 0, 2818093, 0, 0, 2818094, 0, 0, 2818095, 0, 0, 2818096, 0, 0, 2818097, 0, 0, 2818098, 0, 0, 2818099, 0, 0, 2818100, 0, 0, 2818101, 0, 0, 2818102, 0, 0, 2818103, 0, 0, 2818104, 0, 0, 2818105, 0, 0, 2818106, 0, 0, 2818107, 0, 0, 2818108, 0, 0, 2818109, 0, 0, 2818110, 0, 0, 2818111, 0, 0, 2818112, 0, 0, 2818113, 0, 0, 2818114, 0, 0, 2818115, 0, 0, 2818116, 0, 0, 2818117, 0, 0, 2818118, 0, 0, 2818119, 0, 0, 2818120, 0, 0, 2818121, 0, 0, 2818122, 0, 0, 2818123, 0, 0, 2818124, 0, 0, 2818125, 0, 0, 2818126, 0, 0, 2818127, 0, 0, 2883584, 0, 0, 2883585, 0, 0, 2883586, 0, 0, 2883587, 0, 0, 2883588, 0, 0, 2883589, 0, 0, 2883590, 0, 0, 2883591, 0, 0, 2883592, 0, 0, 2883593, 0, 0, 2883594, 0, 0, 2883595, 0, 0, 2883596, 0, 0, 2883597, 0, 0, 2883598, 0, 0, 2883599, 0, 0, 2883600, 0, 0, 2883601, 0, 0, 2883602, 0, 0, 2883603, 0, 0, 2883604, 0, 0, 2883605, 0, 0, 2883606, 0, 0, 2883607, 0, 0, 2883608, 0, 0, 2883609, 0, 0, 2883610, 0, 0, 2883611, 0, 0, 2883612, 0, 0, 2883613, 0, 0, 2883614, 0, 0, 2883615, 0, 0, 2883616, 0, 0, 2883617, 0, 0, 2883618, 0, 0, 2883619, 0, 0, 2883620, 0, 0, 2883621, 0, 0, 2883622, 0, 0, 2883623, 0, 0, 2883624, 0, 0, 2883625, 0, 0, 2883626, 0, 0, 2883627, 0, 0, 2883628, 0, 0, 2883629, 0, 0, 2883630, 0, 0, 2883631, 0, 0, 2883632, 0, 0, 2883633, 0, 0, 2883634, 0, 0, 2883635, 0, 0, 2883636, 0, 0, 2883637, 0, 0, 2883638, 0, 0, 2883639, 0, 0, 2883640, 0, 0, 2883641, 0, 0, 2883642, 0, 0, 2883643, 0, 0, 2883644, 0, 0, 2883645, 0, 0, 2883646, 0, 0, 2883647, 0, 0, 2883648, 0, 0, 2883649, 0, 0, 2883650, 0, 0, 2883651, 0, 0, 2883652, 0, 0, 2883653, 0, 0, 2883654, 0, 0, 2883655, 0, 0, 2883656, 0, 0, 2883657, 0, 0, 2883658, 0, 0, 2883659, 0, 0, 2883660, 0, 0, 2883661, 0, 0, 2883662, 0, 0, 2883663, 0, 0 ) + +[node name="Player" type="KinematicBody2D" parent="."] +position = Vector2( 50, 600 ) +script = ExtResource( 5 ) +MAXSPEED = 100 +JUMPFORCE = 500 +ACCEL = 200 + +[node name="Sprite" type="Sprite" parent="Player"] +texture = ExtResource( 4 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"] +shape = SubResource( 1 ) + +[node name="Camera2D" type="Camera2D" parent="Player"] +current = true +zoom = Vector2( 0.5, 0.5 ) +smoothing_enabled = true diff --git a/game/Interface.tscn b/game/Interface.tscn new file mode 100644 index 0000000..8efd082 --- /dev/null +++ b/game/Interface.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://game/FPS.gd" type="Script" id=1] + +[node name="Interface" type="Control"] +margin_right = 40.0 +margin_bottom = 40.0 + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +margin_right = 67.0 +margin_bottom = 40.0 + +[node name="FPS" type="Label" parent="VBoxContainer"] +margin_right = 67.0 +margin_bottom = 14.0 +text = "FPS" +script = ExtResource( 1 ) + +[node name="Money" type="Label" parent="VBoxContainer"] +margin_top = 18.0 +margin_right = 67.0 +margin_bottom = 32.0 +text = "Money: $0" |
