better documentation, class 1
This commit is contained in:
parent
246bdf0e98
commit
19b2d654d6
week1
GodotSpeedRun
README.md@ -1,8 +1,8 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://y083suj12rld"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://y083suj12rld"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/gamecontroller.gd" id="1_77wyw"]
|
||||
[ext_resource type="Script" path="res://scripts/CharacterBody2D.gd" id="1_u4sui"]
|
||||
[ext_resource type="Script" path="res://scripts/Trigger.gd" id="2_nfj1w"]
|
||||
[ext_resource type="PackedScene" uid="uid://bqdsxxxm7gmj4" path="res://scenes/trigger.tscn" id="3_8dqk0"]
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_3u4a8"]
|
||||
|
||||
@ -15,9 +15,6 @@ size = Vector2(91, 20)
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_ubfw4"]
|
||||
radius = 13.0384
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_x8qck"]
|
||||
radius = 60.2993
|
||||
|
||||
[node name="Game" type="Node2D"]
|
||||
script = ExtResource("1_77wyw")
|
||||
|
||||
@ -90,14 +87,7 @@ metadata/_edit_group_ = true
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
|
||||
shape = SubResource("CircleShape2D_ubfw4")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
position = Vector2(624, 416)
|
||||
script = ExtResource("2_nfj1w")
|
||||
metadata/_edit_group_ = true
|
||||
[node name="Trigger" parent="." instance=ExtResource("3_8dqk0")]
|
||||
effect = "destroy"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource("CircleShape2D_x8qck")
|
||||
debug_color = Color(0.556863, 0.415686, 0.964706, 0.419608)
|
||||
|
||||
[connection signal="areatrigger" from="Area2D" to="." method="_on_area_2d_areatrigger"]
|
||||
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"]
|
||||
[connection signal="areatrigger" from="Trigger" to="." method="_on_area_2d_areatrigger"]
|
||||
|
17
week1/GodotSpeedRun/scenes/trigger.tscn
Normal file
17
week1/GodotSpeedRun/scenes/trigger.tscn
Normal file
@ -0,0 +1,17 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://bqdsxxxm7gmj4"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Trigger.gd" id="1_4rgu6"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_x8qck"]
|
||||
radius = 60.2993
|
||||
|
||||
[node name="Trigger" type="Area2D"]
|
||||
position = Vector2(624, 416)
|
||||
script = ExtResource("1_4rgu6")
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_x8qck")
|
||||
debug_color = Color(0.556863, 0.415686, 0.964706, 0.419608)
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
@ -10,11 +10,12 @@ var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
# Add the gravity.
|
||||
# Gravity applies any time character is not on floor
|
||||
if not is_on_floor():
|
||||
velocity.y += gravity * delta
|
||||
#eventually, gravity overcomes jump velocity (see below)
|
||||
|
||||
# Handle jump.
|
||||
# Only allow jump from starting on floor
|
||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
|
||||
@ -25,7 +26,8 @@ func _physics_process(delta):
|
||||
velocity.x = direction * SPEED
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
|
||||
|
||||
#movde_and_slide is the big function - calculates all the positions and collisions
|
||||
move_and_slide()
|
||||
for i in get_slide_collision_count():
|
||||
var c = get_slide_collision(i)
|
||||
|
@ -1,6 +1,11 @@
|
||||
extends Area2D
|
||||
|
||||
#an @export is a nice way to expose a variable in the IDE
|
||||
#this could be handy when working in a team, working with others
|
||||
@export var effect = "alert"
|
||||
|
||||
#a custom signal is a way for one object to communicate to another
|
||||
#other objects must assign a handler function to hear about the custom signal
|
||||
signal areatrigger(effect, Object)
|
||||
|
||||
func _on_body_entered(body):
|
||||
|
@ -1,7 +1,7 @@
|
||||
extends Node2D
|
||||
|
||||
var totalCrates = 2
|
||||
var cratesCollected = 0
|
||||
var totalCrates = 2 #This will be updated in the future, see SceneManager
|
||||
var cratesDestroyed = 0
|
||||
var timeLimit = 10
|
||||
var timer:= Timer.new()
|
||||
|
||||
@ -21,11 +21,15 @@ func secondCounter():
|
||||
|
||||
|
||||
func _on_area_2d_areatrigger(effect, body):
|
||||
print("Game Controller sees the trigger")
|
||||
# check to ensure the collision is with the crates (RigidBodies)
|
||||
# A CharacterBody2D should not trigger a reaction to the collision
|
||||
if body is RigidBody2D:
|
||||
print("a crate entered trigger")
|
||||
cratesCollected +=1
|
||||
body.queue_free()
|
||||
if cratesCollected>=totalCrates:
|
||||
print("You win baby!")
|
||||
get_tree().reload_current_scene()
|
||||
# crate entered trigger
|
||||
# handle effects
|
||||
match effect:
|
||||
"destroy":
|
||||
cratesDestroyed +=1
|
||||
body.queue_free() # destroy the crate - again will move to SceneManager
|
||||
if cratesDestroyed>=totalCrates:
|
||||
print("You win baby!")
|
||||
get_tree().reload_current_scene()
|
||||
|
@ -1,7 +1,7 @@
|
||||
## Week 1: Setting up the Environment, Major Concepts
|
||||
|
||||
### Description:
|
||||
Get familiar with the Godot game engine, and why we would use this engine. Become familiar with the interface and set up a first project in 2D and another one in 3D
|
||||
Get familiar with the Godot game engine, and why we would use this engine. Become familiar with the interface and set up a first project in 2D.
|
||||
|
||||
Install the Godot game engine
|
||||
Get familiar with the environment
|
||||
@ -16,8 +16,24 @@ Learn the main types of game objects and how they relate to game design:
|
||||
* Character Bodies
|
||||
* Area Triggers
|
||||
|
||||
Development Exercise - 2D/3D comparison
|
||||
Learn to create/import a 3D model, create a ground plane. Understand rigid bodies, gravity, and colliders. Create a keyboard based player controller to move around with.
|
||||
Development Exercise - Minimal Game
|
||||
Create a ground plane. Understand rigid bodies, gravity, and colliders. Create a keyboard based player controller to move around with.
|
||||
|
||||
### Create Walls
|
||||
|
||||
Using Static Bodies, create walls and boundaries to form some basic world interaction.
|
||||
|
||||
### Create Physics Based Objects
|
||||
|
||||
Using RigidBodies, create some elements of the world that use physics interactions. You can test these against your StaticBodies.
|
||||
|
||||
### Create AreaTrigger
|
||||
|
||||
Create a trigger via Area2D. Create in a way that it can be used to trigger multiple effects. Turn the AreaTrigger into its own Scene for reuse.
|
||||
|
||||
### Create Game Character
|
||||
|
||||
Make a playable character that uses the CharacterBody2D template.
|
||||
|
||||
-----------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user