Skip to content

Instantly share code, notes, and snippets.

extends KinematicBody2D
var RISING_GRAVITY = 400
var FALLING_GRAVITY = 1200
var MAX_FLOOR_SPEED = 140
var FLOOR_RUN_FORCE = 600
var FLOOR_STOP_FORCE = 1600
var AIR_RUN_FORCE = 100
var AIR_STOP_FORCE = 160
extends Node
var map = AStar.new()
var BOUNDS
var floor_cells = []
# dirty cells made by blocking Objects
#{Vector2 cell: bool not_blocked}
var dirty_cells = {}
extends KinematicBody2D
const FLOOR_ANGLE = 0
const WALL_ANGLE = 90
const CEIL_ANGLE = 180
var GRAVITY = 360
var FALL_RATE = 3.0
extends Node
# Generate the Datamap
func Generate( map_size=Vector2(80,70), room_count=35, room_size=Vector2(5,16), wall_id=0, floor_id=1 ):
# Start generation timer
var S = OS.get_ticks_msec()
# Randomize
extends Node
# Generate the Datamap
func Generate( map_size=Vector2(80,70), room_count=35, room_size=Vector2(5,16), wall_id=0, floor_id=1 ):
# Randomize
randomize()
# Returns an array of datamap cells that lie
# under the from map cell to map cell
func get_line(from,to):
# setup
var x1 = from.x
var y1 = from.y
var x2 = to.x
var y2 = to.y
var dx = x2 - x1
# Cast a fov line, stopping at first blocking cell
func cast_fov_ray(data,wall_index,from,to):
var cells = []
var line = get_line(from,to)
for cell in line:
# Check for blocking cell
if not is_wall(data, wall_index, cell):
cells.append(cell)
else:
# include the blocking cell in the list
extends Node2D
var resolution = 256
var radius = 512
var force = 80
var force_falloff = 0.08
[gd_scene load_steps=2 format=1]
[ext_resource path="res://icon.png" type="Texture" id=1]
[node name="Control" type="VBoxContainer"]
anchor/right = 1
anchor/bottom = 1
focus/ignore_mouse = false
focus/stop_mouse = true
extends Node
# HEX GRID MATH FUNCTIONS
#
# for CELL(offset odd-q vertical), AXIAL, and CUBIC coordinates
var CUBE_DIRECTIONS = [
Cube.new(1, -1, 0), Cube.new(1, 0, -1), Cube.new( 0, 1, -1),\
Cube.new(-1, 1, 0), Cube.new(-1, 0, 1), Cube.new( 0, -1, 1)
]