Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
lamarmarshall / player.gd
Created February 27, 2025 22:47
godot, particle emitting
extends RigidBody3D
##how much vertical force
@export_range(750.0, 3000.0) var thrust: float = 1000.0
##how much horizntal force
@export var torque: float = 100.0
@onready var audio: AudioStreamPlayer = $Audio
@onready var audio_success: AudioStreamPlayer = $Audio_success
@onready var audio_rocket: AudioStreamPlayer3D = $Audio_rocket
@onready var booster_particles: GPUParticles3D = $BoosterParticles
@onready var explosion_particles: GPUParticles3D = $ExplosionParticles
@lamarmarshall
lamarmarshall / moving_hazard.gd
Last active February 27, 2025 13:26
godot, tween
extends AnimatableBody3D
@export var destination: Vector3
@export var duration: float = 1.0
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var tween = create_tween()
tween.set_loops()
tween.set_trans(tween.TRANS_SINE)
tween.tween_property(self, "global_position", global_position + destination, duration)
@lamarmarshall
lamarmarshall / player.gd
Last active February 26, 2025 05:37
godot, basis, move in direction
extends RigidBody3D
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta: float) -> void:
if Input.is_action_pressed("ui_accept"):
apply_central_force(basis.y * delta * 1000.0)
if Input.is_action_pressed("ui_left"):
apply_torque(Vector3(0.0, 0.0, 100.0 * delta))
@lamarmarshall
lamarmarshall / Player.cs
Created February 11, 2025 04:44
unity, touch move, move to mouse
using UnityEngine;
using UnityEngine.SceneManagement;
public class Player : MonoBehaviour
{
public float moveSpeed;
Rigidbody2D rb;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
@lamarmarshall
lamarmarshall / ArrayTest.lua
Created January 6, 2025 01:13
Roblox, lua, for loop, while loop, change color, random
local cubes = game.Workspace.ColorCubes:GetChildren()
for i = 1, #cubes do
cubes[i].Color = BrickColor.Random().Color
end
local function changeColor()
r1 = math.random(0.0, 1.0)
r2 = math.random(0.0, 1.0)
r3 = math.random(0.0, 1.0)
@lamarmarshall
lamarmarshall / ArrayTester.lua
Created January 6, 2025 01:02
Roblox, array, for loop, change brick color, random
local cubes = game.Workspace.ColorCubes:GetChildren()
for i = 1, #cubes do
cubes[i].Color = BrickColor.Random().Color
end
@lamarmarshall
lamarmarshall / tween.lua
Created January 6, 2025 00:28
Roblox, lua, tween
local part = script.Parent
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(3.0, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true, 0.2)
local tween = tweenService:Create(part, tweenInfo, {Position = part.Position + Vector3.new(0, 20, 0)})
tween:Play()
@lamarmarshall
lamarmarshall / world.gd
Created November 13, 2024 02:48
godot 4, lay down different sets of tiles
extends Node2D
@onready var tile_map_layer: TileMapLayer = $TileMapLayer
enum farming_modes{DIRT, SEEDS, WATER, HARVEST}
var farming_mode_states: farming_modes = farming_modes.DIRT
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
@lamarmarshall
lamarmarshall / world.gd
Created November 13, 2024 02:12
godot 4 set tiles on tile map layer
extends Node2D
@onready var tile_map_layer: TileMapLayer = $TileMapLayer
# 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.
@lamarmarshall
lamarmarshall / player.gd
Created November 13, 2024 01:56
godot 4, top down movement
extends CharacterBody2D
var speed: int = 100
var looking_left: bool = true
# 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.