Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ligen131 committed Jan 28, 2024
2 parents e7bc634 + 844573d commit 2158fb3
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 9 deletions.
46 changes: 46 additions & 0 deletions bg/dynamic_bg/dynamic_bg.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
extends Node2D


const DynamicBgPattern = preload("res://bg/dynamic_bg/dynamic_bg_pattern/dynamic_bg_pattern.tscn")


const WIDTH = 1920 / 4
const HEIGHT = 1080 / 4

const W_STEP := 60
const H_STEP := 6

var VELOCITY = 30 * Vector2.from_angle(-atan(2))

func spawn(x_offset, y_offset):
var pat_x = -WIDTH + x_offset
var pat_y = HEIGHT + y_offset

while pat_x < WIDTH + 50:
var new_pattern = DynamicBgPattern.instantiate()

new_pattern.position = Vector2(pat_x, pat_y)
new_pattern.velocity = VELOCITY
add_child(new_pattern)

pat_x += W_STEP
pat_y += H_STEP


func _ready():
var x_offset = 0
var y_offset = 0
while HEIGHT + y_offset + (WIDTH / W_STEP) * H_STEP > -50:
spawn(x_offset, y_offset)
x_offset += $Timer.wait_time * VELOCITY.x
x_offset -= int(x_offset / W_STEP) * W_STEP
y_offset += $Timer.wait_time * VELOCITY.y
print(y_offset)

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass


func _on_timer_timeout():
spawn(0, 0)
13 changes: 13 additions & 0 deletions bg/dynamic_bg/dynamic_bg.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_scene load_steps=2 format=3 uid="uid://d3geq38s5fjc6"]

[ext_resource type="Script" path="res://bg/dynamic_bg/dynamic_bg.gd" id="1_g3cph"]

[node name="DynamicBg" type="Node2D"]
z_index = -4096
script = ExtResource("1_g3cph")

[node name="Timer" type="Timer" parent="."]
wait_time = 2.0
autostart = true

[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
18 changes: 18 additions & 0 deletions bg/dynamic_bg/dynamic_bg_pattern/dynamic_bg_pattern.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
extends Node2D


var velocity : Vector2


func _ready():
if randi() % 2 == 1:
$Word1.set_word("=*"[randi_range(0, 1)])
$Word2.set_word("DPb>"[randi_range(0, 2)])
else:
$Word1.set_word("qd<"[randi_range(0, 2)])
$Word2.set_word("=*"[randi_range(0, 1)])

func _process(delta):
position += velocity * delta
if position.x > 1920 / 4 + 70 or position.y < -70:
queue_free()
14 changes: 14 additions & 0 deletions bg/dynamic_bg/dynamic_bg_pattern/dynamic_bg_pattern.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[gd_scene load_steps=3 format=3 uid="uid://dkm7ljv01kwma"]

[ext_resource type="Script" path="res://bg/dynamic_bg/dynamic_bg_pattern/dynamic_bg_pattern.gd" id="1_hrrmh"]
[ext_resource type="PackedScene" uid="uid://cvx7wowcbfo0r" path="res://objects/word/word.tscn" id="2_7jm3n"]

[node name="DynamicBgPattern" type="Node2D"]
modulate = Color(1, 1, 1, 0.12549)
script = ExtResource("1_hrrmh")

[node name="Word1" parent="." instance=ExtResource("2_7jm3n")]
position = Vector2(-6, 0)

[node name="Word2" parent="." instance=ExtResource("2_7jm3n")]
position = Vector2(6, 0)
19 changes: 13 additions & 6 deletions levels/base_level/base_level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,22 @@ func _on_back_button_pressed():
queue_free()

func _on_next_level_button_pressed():
var base_level := BaseLevel.instantiate()

if lvl_id == len(DATA[chap_id]) - 1:
base_level.init(chap_id + 1, 0)
var level_menu := LevelMenu.instantiate()
level_menu.init(chap_id + 1, -1)
get_tree().root.add_child(level_menu)
else:
var base_level := BaseLevel.instantiate()
base_level.init(chap_id, lvl_id + 1)
get_tree().root.add_child(base_level)
get_tree().root.add_child(base_level)
queue_free()

func _on_replay_button_pressed():
for card_base: CardBase in $CardBases.get_children():
card_base.reset_all_card_position()
var new_level = BaseLevel.instantiate()
new_level.init(chap_id, lvl_id)
get_tree().root.add_child(new_level)
queue_free()
#print(get_tree().current_scene)
#get_tree().reload_current_scene()
#for card_base: CardBase in $CardBases.get_children():
#card_base.reset_all_card_position()
4 changes: 2 additions & 2 deletions levels/base_level/base_level.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=15 format=3 uid="uid://cother2aiigge"]
[gd_scene load_steps=16 format=3 uid="uid://cother2aiigge"]

[ext_resource type="Script" path="res://levels/base_level/base_level.gd" id="1_diojb"]
[ext_resource type="PackedScene" uid="uid://xom5kpqs1rue" path="res://objects/calculator/calculator.tscn" id="1_tpuy7"]
Expand Down Expand Up @@ -94,7 +94,7 @@ centered = false

[node name="LevelClear" type="AudioStreamPlayer2D" parent="SFXs"]
stream = ExtResource("3_ou3kh")
volume_db = -26.29
volume_db = -5.0

[node name="WrongAnswer" type="AudioStreamPlayer2D" parent="SFXs"]
stream = ExtResource("4_yxsxp")
Expand Down
7 changes: 7 additions & 0 deletions levels/chapter_menu/level_menu/level_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const I_NUMBER = ["I","II","III","VI","V"]

const LevelButton := preload("res://levels/chapter_menu/level_menu/level_button/level_button.tscn")
const BaseLevel := preload("res://levels/base_level/base_level.tscn")
const Credits := preload("res://objects/credits/credits.tscn")

# Called when the node enters the scene tree for the first time.

Expand All @@ -18,6 +19,12 @@ const button_heigth : int = 50
func init(chap_id : int, lvl_num : int) -> void:
#print("init?")

if chap_id == len(BaseLevel.instantiate().DATA):
add_child(Credits.instantiate())
$Title.set_text("")
return


if lvl_num == -1:
lvl_num = len(BaseLevel.instantiate().DATA[chap_id])

Expand Down
7 changes: 6 additions & 1 deletion main.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
[gd_scene load_steps=2 format=3 uid="uid://c17fbsiogbgo1"]
[gd_scene load_steps=3 format=3 uid="uid://c17fbsiogbgo1"]

[ext_resource type="PackedScene" uid="uid://c07co5p46apu7" path="res://objects/main_menu/main_menu.tscn" id="1_fk6j6"]
[ext_resource type="PackedScene" uid="uid://d3geq38s5fjc6" path="res://bg/dynamic_bg/dynamic_bg.tscn" id="2_8k4il"]

[node name="Main" type="Node"]

[node name="MainMenu" parent="." instance=ExtResource("1_fk6j6")]

[node name="Bg" type="Node" parent="."]

[node name="DynamicBg" parent="Bg" instance=ExtResource("2_8k4il")]
22 changes: 22 additions & 0 deletions objects/credits/credits.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[gd_scene load_steps=2 format=3 uid="uid://cdu8yubd7fyvb"]

[ext_resource type="FontFile" uid="uid://1000owdyvwfg" path="res://fonts/unifont-15.1.04.otf" id="1_re7ax"]

[node name="Label" type="Label"]
custom_minimum_size = Vector2(480, 256)
offset_right = 40.0
offset_bottom = 23.0
theme_override_fonts/font = ExtResource("1_re7ax")
text = "
[ Equal to P ]
Created by 玩一个四字音游导致的 @ GGJ2024
ligen131 Tsukimaru
Bunnycxk IssactheMouse
THANKS FOR PLAYING! ;-)"
horizontal_alignment = 1

0 comments on commit 2158fb3

Please sign in to comment.