Compare commits

..

No commits in common. "862fb41a326b44491b460028de7b42add49bbad3" and "12525b0095e1a8dd8cb24e8284f8c0bad75f01a9" have entirely different histories.

8 changed files with 11 additions and 59 deletions

View File

@ -2,32 +2,8 @@ extends Node2D
var movement_queue = [] var movement_queue = []
var player_to_move : bool = false
var player_original_position : Vector2 = Vector2.ZERO
var player_movement_range = 5
func _physics_process(delta): func _physics_process(delta):
# player should carry on queued movements no matter what
player_movement()
# note down the player position before moving
if not player_to_move:
player_original_position = $Player.map_position
# if the player needs to move, allow the input to be for the player
if player_to_move:
player_movement_input()
return
# select the card chooser if dice is selected
if (Input.is_action_just_pressed("ui_accept")
and $UI/DiceView.selected == true):
$UI/DiceView.selected = false
$UI/CardView.selected = true
func player_movement_input():
if Input.is_action_just_pressed("ui_up"): if Input.is_action_just_pressed("ui_up"):
movement_queue.append(Vector2.UP) movement_queue.append(Vector2.UP)
if Input.is_action_just_pressed("ui_down"): if Input.is_action_just_pressed("ui_down"):
@ -37,11 +13,6 @@ func player_movement_input():
if Input.is_action_just_pressed("ui_right"): if Input.is_action_just_pressed("ui_right"):
movement_queue.append(Vector2.RIGHT) movement_queue.append(Vector2.RIGHT)
if Input.is_action_just_pressed("ui_accept"):
player_to_move = false
func player_movement():
#remove uneeded inputs from the queue #remove uneeded inputs from the queue
for i in len(movement_queue) - 1: for i in len(movement_queue) - 1:
#remove if adjacent values are opposites #remove if adjacent values are opposites
@ -57,14 +28,8 @@ func player_movement():
if len(movement_queue) == 0: if len(movement_queue) == 0:
return return
if not $Player.moving:
#if the player is moving too far, cancel movement and empty queue
if (($Player.map_position + movement_queue[0]
- player_original_position).length() > player_movement_range):
movement_queue = []
return
#move the character once space in the queue if not moving #move the character once space in the queue if not moving
if not $Player.moving:
$Player.map_position += movement_queue.pop_front() $Player.map_position += movement_queue.pop_front()
$Player.target_position = $TileMap.map_to_world($Player.map_position) $Player.target_position = $TileMap.map_to_world($Player.map_position)
$Player.target_position += $TileMap.cell_size/2 $Player.target_position += $TileMap.cell_size/2

View File

@ -37,7 +37,6 @@ tile_data = PoolIntArray( 65540, 0, 0, 131074, 0, 0, 131075, 0, 0, 131076, 0, 0,
[node name="Player" parent="." instance=ExtResource( 2 )] [node name="Player" parent="." instance=ExtResource( 2 )]
[node name="Camera2D" type="Camera2D" parent="Player"] [node name="Camera2D" type="Camera2D" parent="Player"]
visible = false
offset = Vector2( 0, 200 ) offset = Vector2( 0, 200 )
current = true current = true
drag_margin_h_enabled = true drag_margin_h_enabled = true
@ -47,17 +46,13 @@ drag_margin_top = 0.05
drag_margin_right = 0.3 drag_margin_right = 0.3
editor_draw_drag_margin = true editor_draw_drag_margin = true
[node name="UI" type="CanvasLayer" parent="."] [node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="CardView" parent="UI" instance=ExtResource( 4 )] [node name="CardView" parent="CanvasLayer" instance=ExtResource( 4 )]
anchor_top = 0.509722 margin_top = 367.0
anchor_right = 0.754687 margin_right = -314.0
margin_top = -7.62939e-06
margin_right = 1.52588e-05
[node name="DiceView" parent="UI" instance=ExtResource( 5 )] [node name="DiceView" parent="CanvasLayer" instance=ExtResource( 5 )]
anchor_left = 0.754687 margin_left = 966.0
anchor_top = 0.509722 margin_top = 367.0
margin_left = 1.52588e-05
margin_top = -7.62939e-06
grow_horizontal = 0 grow_horizontal = 0

View File

@ -112,7 +112,7 @@ func run_card():
new_dice2 += 0.5 new_dice2 += 0.5
emit_signal("return_dice", new_dice1) emit_signal("return_dice", new_dice1)
emit_signal("return_dice", new_dice2) emit_signal("return_dice", new_dice1)
if card_info.EFFECT.DOUBLE in card_info.effects: if card_info.EFFECT.DOUBLE in card_info.effects:
var new_dice1 = dice_number * 2 var new_dice1 = dice_number * 2

View File

@ -1,3 +0,0 @@
extends Control
var selected : bool = false

View File

@ -1,15 +1,13 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=5 format=2]
[ext_resource path="res://UI/Card.tscn" type="PackedScene" id=1] [ext_resource path="res://UI/Card.tscn" type="PackedScene" id=1]
[ext_resource path="res://Assets/CardDB/Sprint.tres" type="Resource" id=2] [ext_resource path="res://Assets/CardDB/Sprint.tres" type="Resource" id=2]
[ext_resource path="res://Assets/CardDB/Poisonous apple.tres" type="Resource" id=3] [ext_resource path="res://Assets/CardDB/Poisonous apple.tres" type="Resource" id=3]
[ext_resource path="res://Assets/CardDB/Broadsword.tres" type="Resource" id=4] [ext_resource path="res://Assets/CardDB/Broadsword.tres" type="Resource" id=4]
[ext_resource path="res://UI/CardView.gd" type="Script" id=5]
[node name="CardView" type="Control"] [node name="CardView" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
script = ExtResource( 5 )
[node name="Margin" type="MarginContainer" parent="."] [node name="Margin" type="MarginContainer" parent="."]
anchor_right = 1.0 anchor_right = 1.0

View File

@ -13,4 +13,4 @@ func _set_dice_value(new_value):
func _ready(): func _ready():
randomize() randomize()
self.dice_value = int(round(rand_range(0.5, 6.49999999))) self.dice_value = round(rand_range(0.5, 6.49999999))

View File

@ -2,8 +2,6 @@ extends Control
const dice = preload("res://UI/Dice.tscn") const dice = preload("res://UI/Dice.tscn")
var selected : bool = true
var current_dice = [] var current_dice = []
func roll_dice(specific_value : int = 0): func roll_dice(specific_value : int = 0):

View File

@ -36,5 +36,4 @@ common/enable_pause_aware_picking=true
[rendering] [rendering]
quality/driver/fallback_to_gles2=true
environment/default_environment="res://default_env.tres" environment/default_environment="res://default_env.tres"