Added stuff & things

master
Nekojimi 3 years ago
parent e325ab0b21
commit 30287c6fc3
  1. 16
      DebugCanvas.gd
  2. 11
      Pickup.tscn
  3. 51
      Player.gd
  4. 5
      Player.gdns
  5. 13
      Player.tscn
  6. 74
      Scene.gd
  7. 93
      Scene.tscn
  8. 2
      default_env.tres
  9. 8
      icon.png.import
  10. 60
      project.godot
  11. BIN
      tiles.png
  12. 34
      tiles.png.import
  13. BIN
      tiles.xcf

@ -0,0 +1,16 @@
extends Node2D
const OFFSET: Vector2 = Vector2(16,16)
func _draw() -> void:
for cellGraphData in get_parent().cellGraph:
for link in cellGraphData.links:
var from: Vector2 = get_parent().map_pos(cellGraphData.cell) + OFFSET
var to: Vector2 = get_parent().map_pos(link) + OFFSET
from = from.move_toward(to,10)
draw_line(
from,
to,
Color.blueviolet,
2.0,
true)

@ -0,0 +1,11 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://tiles.png" type="Texture" id=1]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 32, 32, 32, 32 )
[node name="Pickup" type="Sprite"]
texture = SubResource( 1 )
offset = Vector2( 16, 16 )

@ -0,0 +1,51 @@
extends Node2D
# Declare member variables here. Examples:
# var a: int = 2
# var b: String = "text"
var gridPos: Vector2 = Vector2(0,0)
var lastPos: Vector2 = Vector2(0,0)
var anim : float = 0.0
const ANIM_SPEED : float = 0.02
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
gridPos = get_parent().world_to_map(position)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
var duration: float = (lastPos - gridPos).length() * ANIM_SPEED
if (duration <= 0):
anim = 1.0
if (anim < 1.0):
anim = min(anim + delta / duration, 1.0)
position = get_parent().map_pos(lerp(lastPos,gridPos,anim))
func _input(event: InputEvent) -> void:
if event.is_action_pressed("game_up"):
move(Vector2(0,-1))
elif event.is_action_pressed("game_up_left"):
move(Vector2(-1,-1))
elif event.is_action_pressed("game_left"):
move(Vector2(-1,0))
elif event.is_action_pressed("game_down_left"):
move(Vector2(-1,1))
elif event.is_action_pressed("game_down"):
move(Vector2(0,1))
elif event.is_action_pressed("game_down_right"):
move(Vector2(1,1))
elif event.is_action_pressed("game_right"):
move(Vector2(1,0))
elif event.is_action_pressed("game_up_right"):
move(Vector2(1,-1))
func move(dir: Vector2):
lastPos = gridPos
gridPos = get_parent().find_move(gridPos,dir)
anim = 0

@ -0,0 +1,5 @@
[gd_resource type="NativeScript" format=2]
[resource]
resource_name = "Player"
class_name = "Player"

@ -0,0 +1,13 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Player.gd" type="Script" id=1]
[ext_resource path="res://tiles.png" type="Texture" id=2]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 2 )
region = Rect2( 0, 0, 32, 32 )
[node name="Player" type="Sprite"]
texture = SubResource( 1 )
offset = Vector2( 16, 16 )
script = ExtResource( 1 )

@ -0,0 +1,74 @@
extends TileMap
enum TileType {WALL = 2, BLANK = 3, HOLE = 4, STOP = 5}
const tileTable: Array = [TileType.BLANK,TileType.BLANK,TileType.WALL,TileType.HOLE,TileType.STOP]
var cellGraph: Array
var nextRow: int = -1
func _ready() -> void:
generate(get_used_cells())
func generate(cells: Array):
for cell in cells:
var tile: int = tileTable[rand_range(0,tileTable.size())]
set_cellv(cell,tile)
for cell in cells:
var cellGraphData: CellGraphData = CellGraphData.new()
cellGraphData.cell = cell
for x in range(-1,2):
for y in range(-1,2):
if (x == 0 && y == 0):
continue
var tile: int = get_cellv(cell)
if (tile == TileType.WALL || tile == TileType.HOLE):
continue
var move: Vector2 = find_move(cell, Vector2(x,y))
if (move == cell):
continue
var moveTile: int = get_cellv(move)
if (moveTile == TileType.WALL || moveTile == TileType.HOLE):
continue
cellGraphData.links.append(move)
cellGraph.append(cellGraphData)
func map_pos(grid: Vector2) -> Vector2:
return cell_size * grid
func find_move(from: Vector2, dir: Vector2) -> Vector2:
var curPos: Vector2 = from
var cont: bool = true
while (cont):
var nextPos: Vector2 = curPos + dir
var nextCell: int = get_cellv(nextPos)
if (nextCell == TileType.WALL): # wall
return curPos
elif (nextCell == TileType.STOP || nextCell == TileType.HOLE): # stop or hole
return nextPos
elif (nextCell == TileMap.INVALID_CELL):
return nextPos
else:
curPos = nextPos
return Vector2(-1,-1)
func _process(delta: float) -> void:
position.y += delta * 3
if (position.y > (cell_size.y * abs(nextRow))):
print("Generating row " + String(nextRow))
nextRow += 1
var toGenerate: Array = []
for x in range(get_used_rect().size.x):
toGenerate.append(Vector2(x,-nextRow))
generate(toGenerate)
class CellGraphData:
var cell: Vector2
var links: Array

File diff suppressed because one or more lines are too long

@ -1,5 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2] [gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1] [sub_resource type="ProceduralSky" id=1]
[resource] [resource]
background_mode = 2 background_mode = 2
background_sky = SubResource( 1 ) background_sky = SubResource( 1 )

@ -2,16 +2,11 @@
importer="texture" importer="texture"
type="StreamTexture" type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" valid=false
metadata={
"vram_texture": false
}
[deps] [deps]
source_file="res://icon.png" source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
[params] [params]
compress/mode=0 compress/mode=0
@ -28,7 +23,6 @@ process/fix_alpha_border=true
process/premult_alpha=false process/premult_alpha=false
process/HDR_as_SRGB=false process/HDR_as_SRGB=false
process/invert_color=false process/invert_color=false
process/normal_map_invert_y=false
stream=false stream=false
size_limit=0 size_limit=0
detect_3d=true detect_3d=true

@ -20,17 +20,75 @@ _global_script_class_icons={
[application] [application]
config/name="${REPO_NAME}" config/name="Momentum"
run/main_scene="res://Scene.tscn"
config/icon="res://icon.png" config/icon="res://icon.png"
[debug]
settings/stdout/print_fps=true
gdscript/warnings/treat_warnings_as_errors=true
[gdnative] [gdnative]
singletons=[ "res://addons/godot-git-plugin/git_api.gdnlib" ] singletons=[ "res://addons/godot-git-plugin/git_api.gdnlib" ]
[input]
game_up={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777358,"unicode":0,"echo":false,"script":null)
]
}
game_up_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":81,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777357,"unicode":0,"echo":false,"script":null)
]
}
game_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777354,"unicode":0,"echo":false,"script":null)
]
}
game_down_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777351,"unicode":0,"echo":false,"script":null)
]
}
game_down={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":88,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777352,"unicode":0,"echo":false,"script":null)
]
}
game_down_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":67,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777353,"unicode":0,"echo":false,"script":null)
]
}
game_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777356,"unicode":0,"echo":false,"script":null)
]
}
game_up_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777359,"unicode":0,"echo":false,"script":null)
]
}
[physics] [physics]
common/enable_pause_aware_picking=true common/enable_pause_aware_picking=true
[rendering] [rendering]
quality/filters/msaa=2
environment/default_environment="res://default_env.tres" environment/default_environment="res://default_env.tres"

BIN
tiles.png (Stored with Git LFS)

Binary file not shown.

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/tiles.png-20e12ed313f9b52ca4483ea23302e684.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://tiles.png"
dest_files=[ "res://.import/tiles.png-20e12ed313f9b52ca4483ea23302e684.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.
Loading…
Cancel
Save