playable but no score

main
Lukas 2024-02-28 20:21:50 -05:00
parent 6b32042810
commit ea064173eb
9 changed files with 57129 additions and 33 deletions

7
Control.gd Normal file
View File

@ -0,0 +1,7 @@
extends Node2D
func _on_start_pressed():
get_tree().change_scene_to_file("res://TmAP.tscn")
func _on_quit_pressed():
get_tree().quit()

View File

@ -1,35 +1,58 @@
extends TileMap extends TileMap
@export var playerPos = Vector2.ZERO
@onready var player =$"../CharacterBody2D" @onready var player =$"../CharacterBody2D"
var rng = RandomNumberGenerator.new() var rng = RandomNumberGenerator.new()
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass pass
#return random int
func roller(): func roller():
var rum = rng.randi_range(0, 200) var rum = rng.randi_range(0, 200)
return rum var randomHouse = rng.randi_range(5,10)
var randomPower = rng.randi_range(2,8)
var randomGap = rng.randi_range(1,20)
var randomSet = [rum, randomHouse,randomPower,randomGap]
return randomSet
#draws the ground, houses and powerups
func drawPat(playerPos):
var tilePos = Vector2i(playerPos.x+(36),11)
var tileCheck = tilePos + Vector2i(1,1)
var rum = roller()
if get_cell_tile_data(0,tileCheck,false) == null:
set_pattern(0,tilePos +Vector2i(rum[3],0),tile_set.get_pattern(1))
if int(playerPos.x) % 3 == 0:
if rum[0] > 180:
set_pattern(1,tilePos-Vector2i(-8,rum[1]),tile_set.get_pattern(4))
if int(playerPos.x) % 7 == 0:
if rum[0] > 180:
set_pattern(1,tilePos-Vector2i(-8,rum[2]),tile_set.get_pattern(5))
#removes old tiles
func garbageCollect(playerPos):
for dist in get_used_cells(0):
if playerPos.x-dist.x > 0:
if sqrt((playerPos.x-dist.x) ** 2 + (playerPos.y - dist.y)**2) > 200:
erase_cell(0, dist)
for dist in get_used_cells(1):
if playerPos.x-dist.x > 0:
if sqrt((playerPos.x-dist.x) ** 2 + (playerPos.y - dist.y)**2) > 200:
erase_cell(1, dist)
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): func _process(delta):
var playerPos = self.local_to_map(player.position) playerPos = self.local_to_map(player.position)
if playerPos.y > 15:
NewScript.playerDeath()
get_tree().change_scene_to_file("res://mainMenu.tscn")
var data = get_cell_tile_data(1,playerPos)
if data:
NewScript.hit(data.get_custom_data_by_layer_id(0))
drawPat(playerPos)
garbageCollect(playerPos)
NewScript.playerPoScore() NewScript.playerPoScore()
#var tilePos = playerPos+Vector2i(16,2)
var tilePos = Vector2i(playerPos.x+(16),11)
var tileCheck = tilePos + Vector2i(1,1)
#print(playerPos)
#print($"../TileMap".get_cell_tile_data(0,tileCheck,false))
#print(tileCheck)
if $".".get_cell_tile_data(0,tileCheck,false) == null:
set_pattern(0,tilePos +Vector2i(3,0),tile_set.get_pattern(1))
if int(player.position.x) % 7 == 0:
var rum = roller()
if rum > 180:
set_pattern(1,tilePos-Vector2i(-8,5),tile_set.get_pattern(4))
if get_cell_tile_data(1,playerPos):
NewScript.hit()

56988
TmA1648.tmp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=3 uid="uid://dv4jschw3ddoi"] [gd_scene load_steps=15 format=3 uid="uid://dv4jschw3ddoi"]
[ext_resource type="Texture2D" uid="uid://cdkrvq4u78vjf" path="res://Maintilemap_No_Shadows.png" id="1_76aq7"] [ext_resource type="Texture2D" uid="uid://cdkrvq4u78vjf" path="res://Maintilemap_No_Shadows.png" id="1_76aq7"]
[ext_resource type="Texture2D" uid="uid://yqys05keer2l" path="res://CL_MainLev.png" id="2_p3aam"] [ext_resource type="Texture2D" uid="uid://yqys05keer2l" path="res://CL_MainLev.png" id="2_p3aam"]
@ -21,6 +21,9 @@ tile_data = PackedInt32Array(0, 327682, 15, 65536, 327682, 16, 131072, 327682, 1
[sub_resource type="TileMapPattern" id="TileMapPattern_n6nqg"] [sub_resource type="TileMapPattern" id="TileMapPattern_n6nqg"]
tile_data = PackedInt32Array(65536, 12976128, 22, 131072, 12976128, 23, 196608, 12976128, 24, 262144, 12976128, 25, 327680, 12976128, 26, 1, 13041664, 21, 65537, 13041664, 22, 131073, 13041664, 23, 196609, 13041664, 24, 262145, 13041664, 25, 327681, 13041664, 26, 65538, 13107200, 22, 131074, 13107200, 23, 196610, 13107200, 24, 262146, 13107200, 25, 327682, 13107200, 26) tile_data = PackedInt32Array(65536, 12976128, 22, 131072, 12976128, 23, 196608, 12976128, 24, 262144, 12976128, 25, 327680, 12976128, 26, 1, 13041664, 21, 65537, 13041664, 22, 131073, 13041664, 23, 196609, 13041664, 24, 262145, 13041664, 25, 327681, 13041664, 26, 65538, 13107200, 22, 131074, 13107200, 23, 196610, 13107200, 24, 262146, 13107200, 25, 327682, 13107200, 26)
[sub_resource type="TileMapPattern" id="TileMapPattern_5elbu"]
tile_data = PackedInt32Array(0, 16908288, 13, 65536, 16908288, 14, 1, 16973824, 13, 65537, 16973824, 14)
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_7eiqt"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_7eiqt"]
texture = ExtResource("1_76aq7") texture = ExtResource("1_76aq7")
3:0/0 = 0 3:0/0 = 0
@ -11233,11 +11236,13 @@ texture = ExtResource("1_76aq7")
258:13/0/physics_layer_0/angular_velocity = 0.0 258:13/0/physics_layer_0/angular_velocity = 0.0
258:13/0/physics_layer_1/linear_velocity = Vector2(0, 0) 258:13/0/physics_layer_1/linear_velocity = Vector2(0, 0)
258:13/0/physics_layer_1/angular_velocity = 0.0 258:13/0/physics_layer_1/angular_velocity = 0.0
258:13/0/custom_data_0 = "power"
259:13/0 = 0 259:13/0 = 0
259:13/0/physics_layer_0/linear_velocity = Vector2(0, 0) 259:13/0/physics_layer_0/linear_velocity = Vector2(0, 0)
259:13/0/physics_layer_0/angular_velocity = 0.0 259:13/0/physics_layer_0/angular_velocity = 0.0
259:13/0/physics_layer_1/linear_velocity = Vector2(0, 0) 259:13/0/physics_layer_1/linear_velocity = Vector2(0, 0)
259:13/0/physics_layer_1/angular_velocity = 0.0 259:13/0/physics_layer_1/angular_velocity = 0.0
259:13/0/custom_data_0 = "power"
260:13/0 = 0 260:13/0 = 0
260:13/0/physics_layer_0/linear_velocity = Vector2(0, 0) 260:13/0/physics_layer_0/linear_velocity = Vector2(0, 0)
260:13/0/physics_layer_0/angular_velocity = 0.0 260:13/0/physics_layer_0/angular_velocity = 0.0
@ -11823,11 +11828,13 @@ texture = ExtResource("1_76aq7")
258:14/0/physics_layer_0/angular_velocity = 0.0 258:14/0/physics_layer_0/angular_velocity = 0.0
258:14/0/physics_layer_1/linear_velocity = Vector2(0, 0) 258:14/0/physics_layer_1/linear_velocity = Vector2(0, 0)
258:14/0/physics_layer_1/angular_velocity = 0.0 258:14/0/physics_layer_1/angular_velocity = 0.0
258:14/0/custom_data_0 = "power"
259:14/0 = 0 259:14/0 = 0
259:14/0/physics_layer_0/linear_velocity = Vector2(0, 0) 259:14/0/physics_layer_0/linear_velocity = Vector2(0, 0)
259:14/0/physics_layer_0/angular_velocity = 0.0 259:14/0/physics_layer_0/angular_velocity = 0.0
259:14/0/physics_layer_1/linear_velocity = Vector2(0, 0) 259:14/0/physics_layer_1/linear_velocity = Vector2(0, 0)
259:14/0/physics_layer_1/angular_velocity = 0.0 259:14/0/physics_layer_1/angular_velocity = 0.0
259:14/0/custom_data_0 = "power"
260:14/0 = 0 260:14/0 = 0
260:14/0/physics_layer_0/linear_velocity = Vector2(0, 0) 260:14/0/physics_layer_0/linear_velocity = Vector2(0, 0)
260:14/0/physics_layer_0/angular_velocity = 0.0 260:14/0/physics_layer_0/angular_velocity = 0.0
@ -56941,6 +56948,7 @@ pattern_1 = SubResource("TileMapPattern_ktijn")
pattern_2 = SubResource("TileMapPattern_jp87s") pattern_2 = SubResource("TileMapPattern_jp87s")
pattern_3 = SubResource("TileMapPattern_3q1rf") pattern_3 = SubResource("TileMapPattern_3q1rf")
pattern_4 = SubResource("TileMapPattern_n6nqg") pattern_4 = SubResource("TileMapPattern_n6nqg")
pattern_5 = SubResource("TileMapPattern_5elbu")
[node name="Node2D" type="Node2D"] [node name="Node2D" type="Node2D"]
@ -56950,16 +56958,22 @@ tile_set = SubResource("TileSet_t3610")
collision_animatable = true collision_animatable = true
format = 2 format = 2
layer_0/y_sort_enabled = true layer_0/y_sort_enabled = true
layer_0/tile_data = PackedInt32Array(786430, 2, 15, 851966, 2, 16, 917502, 2, 17, 786431, 65538, 15, 851967, 65538, 16, 917503, 65538, 17, 720896, 131074, 15, 786432, 131074, 16, 851968, 131074, 17, 720897, 196610, 15, 786433, 196610, 16, 851969, 196610, 17, 720898, 65538, 15, 786434, 65538, 16, 851970, 65538, 17, 720899, 131074, 15, 786435, 131074, 16, 851971, 131074, 17, 720900, 65538, 15, 786436, 65538, 16, 851972, 65538, 17, 720901, 131074, 15, 786437, 131074, 16, 851973, 131074, 17, 720902, 196610, 15, 786438, 196610, 16, 851974, 196610, 17, 720903, 65538, 15, 786439, 65538, 16, 851975, 65538, 17, 720904, 131074, 15, 786440, 131074, 16, 851976, 131074, 17, 720905, 196610, 15, 786441, 196610, 16, 851977, 196610, 17, 720906, 262146, 15, 786442, 262146, 16, 851978, 262146, 17, 720907, 65538, 15, 786443, 65538, 16, 851979, 65538, 17, 720908, 131074, 15, 786444, 131074, 16, 851980, 131074, 17, 720909, 196610, 15, 786445, 196610, 16, 851981, 196610, 17, 720910, 65538, 15, 786446, 65538, 16, 851982, 65538, 17, 720911, 131074, 15, 786447, 131074, 16, 851983, 131074, 17, 720912, 196610, 15, 786448, 196610, 16, 851984, 196610, 17, 720913, 262146, 15, 786449, 262146, 16, 851985, 262146, 17, 720914, 65538, 15, 786450, 65538, 16, 851986, 65538, 17, 720915, 131074, 15, 786451, 131074, 16, 851987, 131074, 17, 720916, 65538, 15, 786452, 65538, 16, 851988, 65538, 17, 720917, 131074, 15, 786453, 131074, 16, 851989, 131074, 17, 720918, 65538, 15, 786454, 65538, 16, 851990, 65538, 17, 720919, 131074, 15, 786455, 131074, 16, 851991, 131074, 17, 720920, 65538, 15, 786456, 65538, 16, 851992, 65538, 17, 720921, 131074, 15, 786457, 131074, 16, 851993, 131074, 17, 720922, 65538, 15, 786458, 65538, 16, 851994, 65538, 17, 720923, 131074, 15, 786459, 131074, 16, 851995, 131074, 17, 720924, 196610, 15, 786460, 196610, 16, 851996, 196610, 17, 720925, 262146, 15, 786461, 262146, 16, 851997, 262146, 17, 720926, 327682, 15, 786462, 327682, 16, 851998, 327682, 17) layer_0/tile_data = PackedInt32Array(786430, 2, 15, 851966, 2, 16, 917502, 2, 17, 786431, 65538, 15, 851967, 65538, 16, 917503, 65538, 17, 720896, 131074, 15, 786432, 131074, 16, 851968, 131074, 17, 720897, 196610, 15, 786433, 196610, 16, 851969, 196610, 17, 720898, 65538, 15, 786434, 65538, 16, 851970, 65538, 17, 720899, 131074, 15, 786435, 131074, 16, 851971, 131074, 17, 720900, 65538, 15, 786436, 65538, 16, 851972, 65538, 17, 720901, 131074, 15, 786437, 131074, 16, 851973, 131074, 17, 720902, 196610, 15, 786438, 196610, 16, 851974, 196610, 17, 720903, 65538, 15, 786439, 65538, 16, 851975, 65538, 17, 720904, 131074, 15, 786440, 131074, 16, 851976, 131074, 17, 720905, 196610, 15, 786441, 196610, 16, 851977, 196610, 17, 720906, 262146, 15, 786442, 262146, 16, 851978, 262146, 17, 720907, 65538, 15, 786443, 65538, 16, 851979, 65538, 17, 720908, 131074, 15, 786444, 131074, 16, 851980, 131074, 17, 720909, 196610, 15, 786445, 196610, 16, 851981, 196610, 17, 720910, 65538, 15, 786446, 65538, 16, 851982, 65538, 17, 720911, 131074, 15, 786447, 131074, 16, 851983, 131074, 17, 720912, 196610, 15, 786448, 196610, 16, 851984, 196610, 17, 720913, 262146, 15, 786449, 262146, 16, 851985, 262146, 17, 720914, 65538, 15, 786450, 65538, 16, 851986, 65538, 17, 720915, 131074, 15, 786451, 131074, 16, 851987, 131074, 17, 720916, 65538, 15, 786452, 65538, 16, 851988, 65538, 17, 720917, 131074, 15, 786453, 131074, 16, 851989, 131074, 17, 720918, 65538, 15, 786454, 65538, 16, 851990, 65538, 17, 720919, 131074, 15, 786455, 131074, 16, 851991, 131074, 17, 720920, 65538, 15, 786456, 65538, 16, 851992, 65538, 17, 720921, 131074, 15, 786457, 131074, 16, 851993, 131074, 17, 720922, 65538, 15, 786458, 65538, 16, 851994, 65538, 17, 720923, 131074, 15, 786459, 131074, 16, 851995, 131074, 17, 720924, 196610, 15, 786460, 196610, 16, 851996, 196610, 17, 720925, 262146, 15, 786461, 262146, 16, 851997, 262146, 17, 720926, 65538, 15, 786462, 65538, 16, 851998, 65538, 17, 720927, 131074, 15, 786463, 131074, 16, 851999, 131074, 17, 720928, 196610, 15, 786464, 196610, 16, 852000, 196610, 17, 720929, 262146, 15, 786465, 262146, 16, 852001, 262146, 17, 720930, 65538, 15, 786466, 65538, 16, 852002, 65538, 17, 720931, 131074, 15, 786467, 131074, 16, 852003, 131074, 17, 720932, 196610, 15, 786468, 196610, 16, 852004, 196610, 17, 720933, 262146, 15, 786469, 262146, 16, 852005, 262146, 17, 720934, 65538, 15, 786470, 65538, 16, 852006, 65538, 17, 720935, 131074, 15, 786471, 131074, 16, 852007, 131074, 17, 720936, 196610, 15, 786472, 196610, 16, 852008, 196610, 17, 720937, 262146, 15, 786473, 262146, 16, 852009, 262146, 17)
layer_1/y_sort_enabled = true layer_1/y_sort_enabled = true
layer_1/tile_data = PackedInt32Array(458776, 12976128, 22, 524312, 12976128, 23, 589848, 12976128, 24, 655384, 12976128, 25, 720920, 12976128, 26, 393241, 13041664, 21, 458777, 13041664, 22, 524313, 13041664, 23, 589849, 13041664, 24, 655385, 13041664, 25, 720921, 13041664, 26, 458778, 13107200, 22, 524314, 13107200, 23, 589850, 13107200, 24, 655386, 13107200, 25, 720922, 13107200, 26) layer_1/tile_data = PackedInt32Array(458776, 12976128, 22, 524312, 12976128, 23, 589848, 12976128, 24, 655384, 12976128, 25, 720920, 12976128, 26, 393241, 13041664, 21, 458777, 13041664, 22, 524313, 13041664, 23, 589849, 13041664, 24, 655385, 13041664, 25, 720921, 13041664, 26, 458778, 13107200, 22, 524314, 13107200, 23, 589850, 13107200, 24, 655386, 13107200, 25, 720922, 13107200, 26, 655399, 16908288, 14, 589864, 16973824, 13, 655400, 16973824, 14, 589863, 16908288, 13)
script = ExtResource("3_xipsd") script = ExtResource("3_xipsd")
[node name="CanvasLayer" type="CanvasLayer" parent="."] [node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="PanelContainer" type="PanelContainer" parent="CanvasLayer"] [node name="PanelContainer" type="PanelContainer" parent="CanvasLayer"]
offset_right = 40.0 anchors_preset = 1
offset_bottom = 40.0 anchor_left = 1.0
anchor_right = 1.0
offset_left = -88.0
offset_top = 16.0
offset_right = -30.0
offset_bottom = 72.0
grow_horizontal = 0
[node name="MarginContainer" type="MarginContainer" parent="CanvasLayer/PanelContainer"] [node name="MarginContainer" type="MarginContainer" parent="CanvasLayer/PanelContainer"]
custom_minimum_size = Vector2(5, 5) custom_minimum_size = Vector2(5, 5)
@ -56968,7 +56982,14 @@ size_flags_horizontal = 4
theme_override_constants/margin_left = 5 theme_override_constants/margin_left = 5
theme_override_constants/margin_right = 5 theme_override_constants/margin_right = 5
[node name="hud" type="Label" parent="CanvasLayer/PanelContainer/MarginContainer"] [node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/PanelContainer/MarginContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="CanvasLayer/PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2
text = "Score:"
[node name="hud" type="Label" parent="CanvasLayer/PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "Text" text = "Text"
script = ExtResource("4_u57d5") script = ExtResource("4_u57d5")

52
mainMenu.tscn Normal file
View File

@ -0,0 +1,52 @@
[gd_scene load_steps=3 format=3 uid="uid://dttqkk2r2ltw"]
[ext_resource type="Script" path="res://Control.gd" id="1_hkt1o"]
[sub_resource type="Theme" id="Theme_2vrso"]
[node name="Panel" type="Panel"]
offset_right = 1152.0
offset_bottom = 656.0
[node name="Control" type="Node2D" parent="."]
script = ExtResource("1_hkt1o")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 0
offset_top = 37.0
offset_right = 1144.0
offset_bottom = 174.0
theme = SubResource("Theme_2vrso")
alignment = 1
[node name="Label" type="Label" parent="HBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 100
text = "fastRunner"
[node name="Start" type="Button" parent="."]
layout_mode = 0
offset_left = 192.0
offset_top = 216.0
offset_right = 448.0
offset_bottom = 328.0
text = "Start Game"
[node name="High" type="Button" parent="."]
layout_mode = 0
offset_left = 448.0
offset_top = 448.0
offset_right = 704.0
offset_bottom = 560.0
text = "High Scores"
[node name="Quit" type="Button" parent="."]
layout_mode = 0
offset_left = 704.0
offset_top = 224.0
offset_right = 960.0
offset_bottom = 336.0
text = "Quit Game"
[connection signal="pressed" from="Start" to="Control" method="_on_start_pressed"]
[connection signal="pressed" from="Quit" to="Control" method="_on_quit_pressed"]

View File

@ -5,5 +5,11 @@ var score= 0
func playerPoScore(): func playerPoScore():
score += 1 score += 1
func hit(): func hit(data):
if data == "Hit":
score -= 50 score -= 50
elif data == "power":
score += 30
func playerDeath():
score = 0

View File

@ -1,7 +1,7 @@
extends CharacterBody2D extends CharacterBody2D
const speed = 190.0 const speed = 190.0
const JUMP_VELOCITY = -400.0 const JUMP_VELOCITY = -400.0
const accel = 1.01 const accel = 1.0071
const strength= 3.5 const strength= 3.5
# Get the gravity from the project settings to be synced with RigidBody nodes. # Get the gravity from the project settings to be synced with RigidBody nodes.
@ -29,8 +29,7 @@ func _physics_process(delta):
velocity.y = lerp(0.0,JUMP_VELOCITY*strength, 0.93) velocity.y = lerp(0.0,JUMP_VELOCITY*strength, 0.93)
velocity = lerp(velocity, playerInput * speed, .01) * Vector2(accel,accel) velocity = lerp(velocity, playerInput * speed, .01) * Vector2(accel,accel)
velocity.x = min(velocity.x,300) velocity.x = min(velocity.x,600)
print(velocity)
move_and_slide() move_and_slide()

View File

@ -11,7 +11,7 @@ config_version=5
[application] [application]
config/name="Testrun" config/name="Testrun"
run/main_scene="res://TmAP.tscn" run/main_scene="res://mainMenu.tscn"
config/features=PackedStringArray("4.2", "Forward Plus") config/features=PackedStringArray("4.2", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"