Skip to content

Commit

Permalink
Merge branch 'main' into kubak2
Browse files Browse the repository at this point in the history
  • Loading branch information
Noarkhh authored Apr 2, 2023
2 parents f68c389 + 58bed90 commit 3bc14d0
Show file tree
Hide file tree
Showing 32 changed files with 529 additions and 42 deletions.
23 changes: 15 additions & 8 deletions DangerScheduler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ var speed_multiplier = log(n) / log(7)

var segment_speed = speed_multiplier * base_speed

var curr_dragon = 0

# Called when the node enters the scene tree for the first time.
func _ready():
set_autostart(true)
Expand All @@ -39,23 +41,23 @@ func _ready():
get_parent().move_child.call_deferred(starting_segment, 2)
segment_queue.push_back(starting_segment)

dragons.append(get_parent().get_node("laser_dragon"))

get_parent().get_node("WallLayer").base_speed = base_speed
dragons[0].activate(125.0)


dragons.append(get_parent().get_node("laser_dragon"))
dragons.append(get_parent().get_node("fireball_dragon"))
dragons[1].activate(125.0)
dragons.append(get_parent().get_node("stone_dragon"))
dragons[2].activate(125.0)

dragons[curr_dragon].activate(125.0)

func next_segment() -> void:
var new_obstacles_segment = segments_scenes[randi() % segments_scenes.size()].instantiate()
new_obstacles_segment.init(segment_speed, 1920)
get_parent().add_child(new_obstacles_segment)
get_parent().move_child(new_obstacles_segment, 2)
segment_queue.push_back(new_obstacles_segment)

dragons[0].start_attack()


n += 1
speed_multiplier = log(n) / log(7)
Expand All @@ -72,8 +74,13 @@ func next_segment() -> void:

wait_time = 1275.0 / segment_speed

dragons[1].start_attack()
dragons[2].start_attack()
if (randi() % 10 == 0):
dragons[curr_dragon].leave()
curr_dragon = (curr_dragon + 1) % 3
dragons[curr_dragon].activate(125.0 * speed_multiplier)

if (randi() % 3 == 0):
dragons[curr_dragon].start_attack()

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
Expand Down
1 change: 0 additions & 1 deletion assets/character_slide.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://ddqlkuyaw8nuu"

path="res://.godot/imported/character_slide.png-252d25389d6bc6e15cd5aa54bae0ea19.ctex"
metadata={
"vram_texture": false
Expand Down
1 change: 0 additions & 1 deletion assets/character_slide_sequence_begin.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://qpk1nl7txlb7"

path="res://.godot/imported/character_slide_sequence_begin.png-9e4ddf7a339c52dc0d3b47d003b24976.ctex"
metadata={
"vram_texture": false
Expand Down
1 change: 0 additions & 1 deletion assets/character_slide_sequence_end.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dw5cmbo4fwb61"

path="res://.godot/imported/character_slide_sequence_end.png-33a7ca1165d90b7555aeb2c83fb81ecf.ctex"
metadata={
"vram_texture": false
Expand Down
1 change: 0 additions & 1 deletion assets/clouds.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bunftb2lai5bs"

path="res://.godot/imported/clouds.png-a944dd817d74fea725de5db08cf2d1fe.ctex"
metadata={
"vram_texture": false
Expand Down
1 change: 1 addition & 0 deletions assets/death_sequence.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://r3u1g6500efr"

path="res://.godot/imported/death_sequence.png-be2f23bf5f8d365506f809a91fbc336e.ctex"
metadata={
"vram_texture": false
Expand Down
1 change: 1 addition & 0 deletions assets/fireball.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://d1yjmre0rb48l"

path="res://.godot/imported/fireball.png-ed7e398784db012da0948497b00257d1.ctex"
metadata={
"vram_texture": false
Expand Down
1 change: 0 additions & 1 deletion assets/green_dragon_attack.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://drlo2x1q6hli7"

path="res://.godot/imported/green_dragon_attack.png-173eefdfececba054b0487c276e62e52.ctex"
metadata={
"vram_texture": false
Expand Down
1 change: 0 additions & 1 deletion assets/green_dragon_attack_end.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dbkt1jcoxf8ht"

path="res://.godot/imported/green_dragon_attack_end.png-bb2a5126432a91efec32f2d0813a5297.ctex"
metadata={
"vram_texture": false
Expand Down
1 change: 0 additions & 1 deletion assets/green_dragon_attack_sequence_begin.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dj3bjsd551i66"

path="res://.godot/imported/green_dragon_attack_sequence_begin.png-99ab663be141b0062e3ed88d2d65d3ac.ctex"
metadata={
"vram_texture": false
Expand Down
1 change: 0 additions & 1 deletion assets/sky1.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://0cmltrarx6sr"

path="res://.godot/imported/sky1.png-df6da1e8f17e6335831371c2de97d6d6.ctex"
metadata={
"vram_texture": false
Expand Down
1 change: 1 addition & 0 deletions assets/you_died.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://d07rhbbg7d14g"

path="res://.godot/imported/you_died.png-5f8b5c92545abce5b3729ea027c3073d.ctex"
metadata={
"vram_texture": false
Expand Down
1 change: 1 addition & 0 deletions danger_scheduler.tscn
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://sxxthl7fu7gi"]


[ext_resource type="Script" path="res://DangerScheduler.gd" id="1_bh304"]

[node name="DangerScheduler" type="Timer"]
Expand Down
28 changes: 28 additions & 0 deletions dragons/CharacterBody2D.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
extends CharacterBody2D


const SPEED = 300.0
const JUMP_VELOCITY = -400.0

# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")


func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y += gravity * delta

# Handle Jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY

# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction = Input.get_axis("ui_left", "ui_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)

move_and_slide()
30 changes: 30 additions & 0 deletions dragons/fireball.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
extends Area2D

var velocity = Vector2(0, -200)
# Called when the node enters the scene tree for the first time.
func _ready():
var lifetime_timer = Timer.new()
lifetime_timer.set_wait_time(1.2)
lifetime_timer.set_one_shot(true)
lifetime_timer.timeout.connect(kill)
add_child(lifetime_timer)
lifetime_timer.start()

func init(new_speed: float) -> void:
velocity.x = new_speed

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
velocity.y += gravity * delta

position += velocity * delta

func kill():

queue_free()


func _on_player_hit(area):
print("area_hit")
if area == get_parent().get_node("Player"):
area.player_hit(1.0)
79 changes: 79 additions & 0 deletions dragons/fireball.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[gd_scene load_steps=12 format=3 uid="uid://bl3ke7fpleyp0"]

[ext_resource type="Script" path="res://dragons/fireball.gd" id="1_4ccul"]
[ext_resource type="Texture2D" uid="uid://d30ikbe4lis2p" path="res://assets/fireball.png" id="1_7isww"]

[sub_resource type="AtlasTexture" id="AtlasTexture_fcmkv"]
atlas = ExtResource("1_7isww")
region = Rect2(0, 0, 19, 19)

[sub_resource type="AtlasTexture" id="AtlasTexture_njpyo"]
atlas = ExtResource("1_7isww")
region = Rect2(19, 0, 19, 19)

[sub_resource type="AtlasTexture" id="AtlasTexture_y6sfg"]
atlas = ExtResource("1_7isww")
region = Rect2(38, 0, 19, 19)

[sub_resource type="AtlasTexture" id="AtlasTexture_372l3"]
atlas = ExtResource("1_7isww")
region = Rect2(57, 0, 19, 19)

[sub_resource type="AtlasTexture" id="AtlasTexture_uga0u"]
atlas = ExtResource("1_7isww")
region = Rect2(76, 0, 19, 19)

[sub_resource type="AtlasTexture" id="AtlasTexture_v3fsn"]
atlas = ExtResource("1_7isww")
region = Rect2(95, 0, 19, 19)

[sub_resource type="AtlasTexture" id="AtlasTexture_xeqtr"]
atlas = ExtResource("1_7isww")
region = Rect2(114, 0, 19, 19)

[sub_resource type="SpriteFrames" id="SpriteFrames_3p26w"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_fcmkv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_njpyo")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_y6sfg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_372l3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uga0u")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_v3fsn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xeqtr")
}],
"loop": true,
"name": &"default",
"speed": 8.0
}]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_m6stc"]
size = Vector2(44, 44)

[node name="Fireball" type="Area2D"]
script = ExtResource("1_4ccul")

[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
texture_filter = 1
scale = Vector2(4, 4)
sprite_frames = SubResource("SpriteFrames_3p26w")
frame_progress = 0.558254

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(4, 4)
shape = SubResource("RectangleShape2D_m6stc")

[connection signal="body_entered" from="." to="." method="_on_player_hit"]
12 changes: 11 additions & 1 deletion dragons/fireball_dragon.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ enum State {
@export var current_state = State.DEFAULT
@export var fireball_attack_time = 2.0

var fireball_scene = preload("res://dragons/fireball.tscn")

var destination_position
var attack_timer = null
var attack_started = false
Expand Down Expand Up @@ -61,7 +63,15 @@ func start_attack():
attack_timer.start()

func fireball_attack():
print("attack")
print("fireball attack")
for v in [300, 500, 700, 900, 1100]:
var fireball = fireball_scene.instantiate()
fireball.init(v)
fireball.position = position + Vector2(150, -50)
print(fireball.global_position)
get_parent().add_child(fireball)
get_parent().move_child(fireball, 4)

current_state = State.ATTACK
attack_timer = Timer.new()
attack_timer.set_wait_time(fireball_attack_time)
Expand Down
4 changes: 2 additions & 2 deletions dragons/fireball_dragon.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ disabled = true
wait_time = 5.0

[node name="InitialPosition" type="Marker2D" parent="."]
position = Vector2(-100, 200)
position = Vector2(-300, 200)

[node name="DefaultPosition" type="Marker2D" parent="."]
position = Vector2(100, 300)
Expand All @@ -72,4 +72,4 @@ position = Vector2(100, 300)
position = Vector2(120, 120)

[node name="ExitPosition" type="Marker2D" parent="."]
position = Vector2(1400, 100)
position = Vector2(1800, 100)
24 changes: 24 additions & 0 deletions dragons/laser.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
extends Area2D


# Called when the node enters the scene tree for the first time.
func _ready():
$Sprite2D.play("start")


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
position.y = get_parent().get_node("laser_dragon").position.y

#func synced_with_dragon():


func start_animation_finished():
$Sprite2D.play("cycle")


func _on_player_hit(area):
print("area_hit")
if area == get_parent().get_node("Player"):
area.player_hit(1.0)

Loading

0 comments on commit 3bc14d0

Please sign in to comment.