Add Player and BattleScene
This commit is contained in:
parent
e1d837a35d
commit
24cc1b8f04
3
Characters/Player.gd
Normal file
3
Characters/Player.gd
Normal file
@ -0,0 +1,3 @@
|
||||
extends Node2D
|
||||
|
||||
export var starting_pos : Vector2 = Vector2.ZERO
|
10
Characters/Player.tscn
Normal file
10
Characters/Player.tscn
Normal file
@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://icon.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Characters/Player.gd" type="Script" id=2]
|
||||
|
||||
[node name="Player" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
29
Scenes/BattleScene.gd
Normal file
29
Scenes/BattleScene.gd
Normal file
@ -0,0 +1,29 @@
|
||||
extends Node2D
|
||||
|
||||
var movement_queue = []
|
||||
|
||||
func _physics_process(delta):
|
||||
|
||||
if Input.is_action_just_pressed("ui_up"):
|
||||
movement_queue.append(Vector2.UP)
|
||||
if Input.is_action_just_pressed("ui_down"):
|
||||
movement_queue.append(Vector2.DOWN)
|
||||
if Input.is_action_just_pressed("ui_left"):
|
||||
movement_queue.append(Vector2.LEFT)
|
||||
if Input.is_action_just_pressed("ui_right"):
|
||||
movement_queue.append(Vector2.RIGHT)
|
||||
|
||||
#remove uneeded inputs from the queue
|
||||
for i in len(movement_queue) - 1:
|
||||
#remove if adjacent values are opposites
|
||||
if (movement_queue[i].x * movement_queue[i+1].x == -1 or
|
||||
movement_queue[i].y * movement_queue[i+1].y == -1):
|
||||
movement_queue[i] = Vector2.ZERO
|
||||
movement_queue[i+1] = Vector2.ZERO
|
||||
#remove null values
|
||||
for i in len(movement_queue):
|
||||
if movement_queue.find(Vector2.ZERO) != -1:
|
||||
movement_queue.remove(movement_queue.find(Vector2.ZERO))
|
||||
|
||||
|
||||
|
35
Scenes/BattleScene.tscn
Normal file
35
Scenes/BattleScene.tscn
Normal file
@ -0,0 +1,35 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://icon.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Characters/Player.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Scenes/BattleScene.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="TileSet" id=1]
|
||||
0/name = "icon.png 0"
|
||||
0/texture = ExtResource( 1 )
|
||||
0/tex_offset = Vector2( 0, 0 )
|
||||
0/modulate = Color( 1, 1, 1, 1 )
|
||||
0/region = Rect2( 8, 4, 51, 19 )
|
||||
0/tile_mode = 0
|
||||
0/occluder_offset = Vector2( 0, 0 )
|
||||
0/navigation_offset = Vector2( 0, 0 )
|
||||
0/shape_offset = Vector2( 0, 0 )
|
||||
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
0/shape_one_way = false
|
||||
0/shape_one_way_margin = 0.0
|
||||
0/shapes = [ ]
|
||||
0/z_index = 0
|
||||
|
||||
[node name="BattleScene" type="Node2D"]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="TileMap" type="TileMap" parent="."]
|
||||
mode = 2
|
||||
tile_set = SubResource( 1 )
|
||||
cell_size = Vector2( 128, 64 )
|
||||
cell_custom_transform = Transform2D( 128, 0, 32, 64, 0, 0 )
|
||||
centered_textures = true
|
||||
format = 1
|
||||
tile_data = PoolIntArray( 65540, 0, 0, 131074, 0, 0, 131075, 0, 0, 131076, 0, 0, 131077, 0, 0, 131078, 0, 0, 196610, 0, 0, 196611, 0, 0, 196612, 0, 0, 196613, 0, 0, 196614, 0, 0, 262144, 0, 0, 262145, 0, 0, 262146, 0, 0, 262147, 0, 0, 262148, 0, 0, 262149, 0, 0, 262150, 0, 0, 327681, 0, 0, 327682, 0, 0, 327683, 0, 0, 327684, 0, 0, 327685, 0, 0, 327686, 0, 0, 393217, 0, 0, 393218, 0, 0, 393219, 0, 0, 393220, 0, 0, 393221, 0, 0, 393222, 0, 0, 458754, 0, 0, 458755, 0, 0, 458756, 0, 0, 458757, 0, 0, 524291, 0, 0, 524292, 0, 0 )
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource( 2 )]
|
Loading…
x
Reference in New Issue
Block a user