In-progress fixes

This commit is contained in:
archfan 2020-04-19 16:16:40 -04:00
parent 364fc7ea12
commit bb495c77ce
18 changed files with 91 additions and 57 deletions

3
Dirt.gd Normal file
View File

@ -0,0 +1,3 @@
extends Node2D
var type = "Dirt"

View File

@ -1,12 +1,14 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://textures/dirt.png" type="Texture" id=1]
[ext_resource path="res://Dirt.gd" type="Script" id=1]
[ext_resource path="res://textures/dirt.png" type="Texture" id=2]
[node name="Dirt" type="Node2D"]
script = ExtResource( 1 )
[node name="DirtTexture" type="TextureRect" parent="."]
margin_right = 40.0
margin_bottom = 40.0
texture = ExtResource( 1 )
texture = ExtResource( 2 )
expand = true

3
Empty.gd Normal file
View File

@ -0,0 +1,3 @@
extends Node2D
var type = "Empty"

View File

@ -1,4 +1,7 @@
[gd_scene format=2]
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Empty.gd" type="Script" id=1]
[node name="Empty" type="Node2D"]
script = ExtResource( 1 )

3
Enemy.gd Normal file
View File

@ -0,0 +1,3 @@
extends Node2D
var type = "Enemy"

View File

@ -1,12 +1,14 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://textures/enemy.png" type="Texture" id=1]
[ext_resource path="res://Enemy.gd" type="Script" id=1]
[ext_resource path="res://textures/enemy.png" type="Texture" id=2]
[node name="Enemy" type="Node2D"]
script = ExtResource( 1 )
[node name="EnemyTexture" type="TextureRect" parent="."]
margin_right = 40.0
margin_bottom = 40.0
texture = ExtResource( 1 )
texture = ExtResource( 2 )
expand = true

3
Goal.gd Normal file
View File

@ -0,0 +1,3 @@
extends Node2D
var type = "Goal"

View File

@ -1,12 +1,14 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://textures/goal.png" type="Texture" id=1]
[ext_resource path="res://Goal.gd" type="Script" id=1]
[ext_resource path="res://textures/goal.png" type="Texture" id=2]
[node name="Goal" type="Node2D"]
script = ExtResource( 1 )
[node name="GoalTexture" type="TextureRect" parent="."]
margin_right = 40.0
margin_bottom = 40.0
texture = ExtResource( 1 )
texture = ExtResource( 2 )
expand = true

View File

@ -36,8 +36,10 @@ func load_level_file(filename):
lvl_map.append(row)
var plr = Player.new()
state = State.new(lvl_map, plr)
OS.window_size = Vector2((len(lines)*SPACE)-BUFFER, (len(lines[0])*SPACE)-BUFFER)
OS.window_size = Vector2((len(lines)*SPACE)-BUFFER, (len(lines[0])*SPACE)-BUFFER)
# This doesn't seem to work, please fix.
func _ready():
load_level_file("test_level_2.txt")
func get_state():
return state

View File

@ -9,6 +9,6 @@ script = ExtResource( 1 )
margin_right = 1030.0
margin_bottom = 600.0
__meta__ = {
"_edit_group_": true,
"_edit_use_anchors_": false
"_edit_group_": true
}

View File

@ -1,7 +1,33 @@
extends KinematicBody2D
var speed = 50
var type = "Player"
func _physics_process(_delta):
var state = get_parent().state
state.move()
var state = get_parent().get_state()
var holding_ctrl = Input.is_action_just_pressed("dig")
if Input.is_action_just_pressed("up"):
var pos = self.get_pos()
pos = Vector2(pos.x, pos.y-1)
if state.get_type(pos) == "Empty":
self.translate(Vector2(0, -speed))
elif Input.is_action_just_pressed("down"):
var pos = self.get_pos()
pos = Vector2(pos.x, pos.y+1)
if state.get_type(pos) == "Empty":
self.translate(Vector2(0, speed))
elif Input.is_action_just_pressed("left"):
var pos = self.get_pos()
pos = Vector2(pos.x-1, pos.y)
if state.get_type(pos) == "Empty":
self.translate(Vector2(-speed, 0))
elif Input.is_action_just_pressed("right"):
var pos = self.get_pos()
pos = Vector2(pos.x+1, pos.y)
if state.get_type(pos) == "Empty":
self.translate(Vector2(speed, 0))
func get_pos():
var pos = self.global_position
pos = Vector2(pos.x/50, pos.y/50)
return pos

3
Rock.gd Normal file
View File

@ -0,0 +1,3 @@
extends Node2D
var type = "Rock"

View File

@ -1,12 +1,14 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://textures/rock.png" type="Texture" id=1]
[ext_resource path="res://Rock.gd" type="Script" id=1]
[ext_resource path="res://textures/rock.png" type="Texture" id=2]
[node name="Rock" type="Node2D"]
script = ExtResource( 1 )
[node name="RockTexture" type="TextureRect" parent="."]
margin_right = 40.0
margin_bottom = 40.0
texture = ExtResource( 1 )
texture = ExtResource( 2 )
expand = true

View File

@ -4,40 +4,10 @@ var level_map = null
var player = null
var player_speed = 50
# Broken, idk how to do this.
var empty_node = preload("res://Empty.tscn")
var dirt_node = preload("res://Dirt.tscn")
var rock_node = preload("res://Rock.tscn")
var wall_node = preload("res://Obstacle.tscn")
var goal_node = preload("res://Goal.tscn")
var enemy_node = preload("res://Enemy.tscn")
func _init(lvlmap, plr):
level_map = lvlmap
player = plr
func move():
# TODO Calculate player position.
var x = 0
var y = 0
var node_type = level_map[y][x]
# Broken.
if node_type is empty_node:
if Input.is_action_just_pressed("up"):
player.translate(Vector2(0, -player_speed))
elif Input.is_action_just_pressed("down"):
player.translate(Vector2(0, player_speed))
elif Input.is_action_just_pressed("left"):
player.translate(Vector2(-player_speed, 0))
elif Input.is_action_just_pressed("right"):
player.translate(Vector2(player_speed, 0))
elif node_type is dirt_node:
pass
elif node_type is rock_node:
pass
elif node_type is wall_node:
pass
elif node_type is goal_node:
pass
elif node_type is enemy_node:
pass
func get_type(pos):
print(level_map[pos.y][pos.x].type)
return level_map[pos.y][pos.x].type

3
Wall.gd Normal file
View File

@ -0,0 +1,3 @@
extends Node2D
var type = "Wall"

View File

@ -1,12 +1,14 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://textures/wall.png" type="Texture" id=1]
[ext_resource path="res://Wall.gd" type="Script" id=1]
[ext_resource path="res://textures/wall.png" type="Texture" id=2]
[node name="Wall" type="Node2D"]
script = ExtResource( 1 )
[node name="WallTexture" type="TextureRect" parent="."]
margin_right = 40.0
margin_bottom = 40.0
texture = ExtResource( 1 )
texture = ExtResource( 2 )
expand = true

View File

@ -5,3 +5,4 @@
[resource]
background_mode = 2
background_sky = SubResource( 1 )

View File

@ -16,7 +16,6 @@ _global_script_class_icons={
[application]
config/name="LD46"
run/main_scene="res://Level.tscn"
config/icon="res://icon.png"
[input]
@ -45,6 +44,11 @@ right={
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null)
]
}
dig={
"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":16777238,"unicode":0,"echo":false,"script":null)
]
}
[rendering]