first commit

This commit is contained in:
JayisonDevadas committed 2025-06-10 10:13:01 -04:00
commit cf94316dae
21 files changed
+363

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
class_name Bullet extends Area2D
var speed = 700
func _ready() -> void:
pass
pass
func setSpeed(value):
speed = value
func _physics_process(delta: float) -> void:
position += transform.x * speed * delta
+1
View File
@@ -0,0 +1 @@
uid://bayboh7t0ss7p
+80
View File
@@ -0,0 +1,80 @@
extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
@onready var right_cast: RayCast2D = $RightCast
@onready var left_cast: RayCast2D = $"Left cast"
@onready var right_spawn: Node2D = $RightSpawn
@onready var left_spawn: Node2D = $LeftSpawn
enum FaceDirection{LEFT, RIGHT}
var facing:FaceDirection = FaceDirection.RIGHT
var pushTarget
var pushEnable = false
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
if Input.is_action_just_pressed("shove") && pushEnable:
print("shove pressed")
if facing == FaceDirection.RIGHT:
pushTarget.apply_central_impulse(Vector2(1,-0.2)*700)
pushEnable = false
if facing == FaceDirection.LEFT:
pushTarget.apply_central_impulse(Vector2(-1,-0.2)*700)
pushEnable = false
if Input.is_action_just_pressed("shoot"):
print("shoot a bullet")
if facing == FaceDirection.RIGHT:
%SceneManager.makeBullet(right_spawn.global_transform, 700)
if facing == FaceDirection.LEFT:
%SceneManager.makeBullet(left_spawn.global_transform,-700)
# Handle jump.x
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
if direction <0:
facing = FaceDirection.LEFT
if direction >0:
facing = FaceDirection.RIGHT
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
for i in get_slide_collision_count():
var c = get_slide_collision(i)
if c.get_collider() is RigidBody2D:
c.get_collider().apply_central_impulse(-c.get_normal() * 100 )
if right_cast.is_colliding() && facing == FaceDirection.RIGHT:
print("right cast collision")
# get the thing i am colliding with
var collider = right_cast.get_collider()
if collider is Node && collider is RigidBody2D:
print("i can shove this right")
pushTarget = collider
pushEnable = true
if left_cast.is_colliding() && facing == FaceDirection.LEFT:
print("left cast collision")
var collider = left_cast.get_collider()
if collider is Node && collider is RigidBody2D:
print("i can shove this left")
pushTarget = collider
pushEnable = true
if not right_cast.is_colliding() && not left_cast.is_colliding():
pushEnable = false
+1
View File
@@ -0,0 +1 @@
uid://dmyw2bn6gnbbv
+21
View File
@@ -0,0 +1,21 @@
extends Node2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _on_areatrigger(effect, body) -> void:
print("Game controller knows about trigger")
if effect == "destroy":
print("Destroy this thing")
body.queue_free()
if effect == "powerup":
print("power up the player")
+1
View File
@@ -0,0 +1 @@
uid://dflv3rb4v8c0r
+27
View File
@@ -0,0 +1,27 @@
extends Node2D
#bullet factory
var bullet = preload("res://scenes/bullet.tscn")
var bulletArray = []
var totalAllowedBullets = 7
#makes bullets
func bulletFactory():
var mybullet
if bulletArray.size() < totalAllowedBullets:
mybullet = bullet.instantiate()
owner.add_child(mybullet)
else:
mybullet = bulletArray.pop_back()
bulletArray.push_front(mybullet)
return mybullet
#order desk
func makeBullet(position, speed):
print("scenemanager orders a bullet")
# ask the factory for a bullet
var mybullet = bulletFactory()
# set the speed for the bullet
mybullet.setSpeed(speed)
# position the bullet
mybullet.transform = position
+1
View File
@@ -0,0 +1 @@
uid://lbasdkinbtif
+19
View File
@@ -0,0 +1,19 @@
extends Area2D
@export var effect = "destroy"
signal areatrigger(effect, Object)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _on_body_entered(body: Node2D) -> void:
print("Trigger entered")
#broadcast to controller
areatrigger.emit(effect, body)
+1
View File
@@ -0,0 +1 @@
uid://ixnbwhm0ptg5