Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
lamarmarshall / main.gd
Created March 3, 2025 04:14
godot, button, movement
extends Area2D
var direction : Vector2 = Vector2.ZERO
var speed: int = 350
var can_move : bool = true
var min_positions: Vector2 = Vector2(20, 176)
var max_positions: Vector2 = Vector2(520, 730)
func _process(delta: float) -> void:
if can_move:
@lamarmarshall
lamarmarshall / main.gd
Created March 2, 2025 16:46
godot, random, swipe, different random
extends Control
var pressed_position: Vector2
var release_position: Vector2
func _input(event: InputEvent) -> void:
if Input.is_action_just_pressed("click"):
pressed_position = event.position
if Input.is_action_just_released("click"):
@lamarmarshall
lamarmarshall / swipe.gd
Created March 2, 2025 16:04
godot, swipe detect
extends Control
var pressed_position: Vector2
var release_position: Vector2
func _input(event: InputEvent) -> void:
if Input.is_action_just_pressed("click"):
pressed_position = event.position
if Input.is_action_just_released("click"):
@lamarmarshall
lamarmarshall / res.txt
Created March 2, 2025 15:02
godot mobile resolution
540
960
@lamarmarshall
lamarmarshall / raycast.gd
Created March 2, 2025 12:59
godot, raycast
extends Camera3D
@onready var ray_cast_3d: RayCast3D = $RayCast3D
@export var grid_map: GridMap
@export var turret_manager: Node3D
@export var turret_cost := 100
@onready var bank := get_tree().get_first_node_in_group("Bank")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
@lamarmarshall
lamarmarshall / ts.cs
Created March 2, 2025 03:21
unity, touch screen
using UnityEngine;
using UnityEngine.InputSystem;
public class BallHandler : MonoBehaviour
{
private Camera mainCamera;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
mainCamera = Camera.main;
@lamarmarshall
lamarmarshall / turret.gd
Created March 1, 2025 19:44
godot 4, aim, shoot
extends Node3D
@export var projectile: PackedScene
@onready var turret_top: MeshInstance3D = $TurretBase/TurretTop
var enemy_path: Path3D
func _physics_process(delta: float) -> void:
var enemy = enemy_path.get_children().back()
look_at(enemy.global_position, Vector3.UP, true)
@lamarmarshall
lamarmarshall / bullet.gd
Created March 1, 2025 19:26
godot, projectile, bullet move
extends Area3D
var direction := Vector3.FORWARD
@export var speed := 30.0
func _physics_process(delta: float) -> void:
position += direction * speed * delta
@lamarmarshall
lamarmarshall / gun.gd
Created March 1, 2025 19:17
godot 4, spawn bullet
extends Node3D
@export var projectile: PackedScene
func _ready() -> void:
var shot = projectile.instantiate()
add_child(shot)
@lamarmarshall
lamarmarshall / turret.gd
Created March 1, 2025 17:18
godot, spawn
extends Node3D
@export var turret: PackedScene
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var new_turret = turret.instantiate()
add_child(new_turret)