temp for controller mouse move

This commit is contained in:
SyntaX 2019-11-24 13:17:53 +01:00
parent 42207cc1c8
commit d8830f0981
4 changed files with 66 additions and 19 deletions

View File

@ -15,6 +15,7 @@ const SPRINT_SPEED = 12
const ACCEL = 15.0
const MAX_SLOPE_ANGLE = 40
const MOUSE_SENSITIVITY = 0.05
const MAX_MOUSE_SPEED = 25
const INTERACT_DISTANCE = 4
const SPRINT_DEC = 0.01;
const SPRINT_ACC = 0.005;
@ -94,6 +95,14 @@ func _process_input():
_dir += -camera_transform.basis.z * input_movement_vector.y
_dir += camera_transform.basis.x * input_movement_vector.x
# look around with controller
#var look = Vector2()
#look.x = -Input.get_action_strength("cam_move_left") + Input.get_action_strength("cam_move_right")
#look.y = +Input.get_action_strength("cam_move_down") - Input.get_action_strength("cam_move_up")
##Logger.info("look at: " + String(look))
##Input.warp_mouse_position(look)
#look_at(Vector3(look.x, look.y, 1), Vector3.UP)
# jumping
if Input.is_action_just_pressed("move_jump") and is_on_floor():
_vel.y = JUMP_SPEED

View File

@ -1,20 +1,19 @@
extends Control
export(NodePath) var label_nodepath
export(NodePath) var popup_nodepath
export(NodePath) var gameover_sound_path
export(NodePath) var container_path
const SCORE = 100
var _labelScore: Label
var _popup: Popup
var _gameover_sound: AudioStreamPlayer
var _collectibles: GridContainer
var _score: int = 0
var _init: bool = false
var _texCrystal = preload("res://Images/crystal-unlit.png")
var _texCrystalLit = preload("res://Images/crystal.png")
func _ready():
_labelScore = get_node(label_nodepath) as Label
assert(null != _labelScore)
_popup = get_node(popup_nodepath) as Popup
assert(null != _popup)
@ -22,22 +21,53 @@ func _ready():
_gameover_sound = get_node(gameover_sound_path) as AudioStreamPlayer
assert(null != _gameover_sound)
_collectibles = get_node(container_path) as GridContainer
assert(null != _collectibles)
func _process(_delta):
if _init == false:
_init = true
# TODO: handle with signals
var count = Collector.getCount()
for i in count:
var rect = _createTexture(_texCrystal)
_collectibles.add_child(rect)
func _createTexture(texture):
var rect = TextureRect.new()
rect.texture = texture
rect.expand = true
rect.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT
rect.rect_min_size = Vector2(50, 50)
rect.rect_size = Vector2(50, 50)
return rect
func increaseScore():
_score += SCORE
_labelScore.text = "Score: " + String(_score)
Logger.info(String(_score) + " of " + String(Collector.getCount() * SCORE) + " possible points")
if (_score >= (Collector.getCount() * SCORE)):
Logger.info("YOU WON!")
_score += 1
Logger.info(String(_score) + " of " + String(Collector.getCount()) + " possible points")
var rect = _createTexture(_texCrystalLit)
#_collectibles.add_child(rect)
_collectibles.add_child_below_node(self, rect)
_collectibles.remove_child(_collectibles.get_child(0))
if (_score >= (Collector.getCount())):
success()
func gameOver():
Logger.info("YOU FAILED!")
_gameover_sound.play()
_endGame(false)
func success():
Logger.info("YOU WON!")
_endGame(true)

View File

@ -6,16 +6,9 @@
margin_right = 40.0
margin_bottom = 40.0
script = ExtResource( 1 )
label_nodepath = NodePath("../HUD/LabelScore")
popup_nodepath = NodePath("../HUD/Popup")
gameover_sound_path = NodePath("../GameOverSound")
[node name="LabelScore" type="Label" parent="."]
margin_left = 15.0
margin_top = 15.0
margin_right = 115.0
margin_bottom = 30.0
text = "Score: 0"
container_path = NodePath("GridContainer")
[node name="Popup" type="Popup" parent="."]
editor/display_folded = true
@ -71,4 +64,9 @@ margin_right = 614.651
margin_bottom = 582.551
step = 1.0
value = 100.0
[node name="GridContainer" type="GridContainer" parent="."]
margin_right = 250.0
margin_bottom = 150.0
columns = 15
[connection signal="pressed" from="Popup/Button" to="." method="_on_Button_pressed"]

View File

@ -118,6 +118,16 @@ cam_move_right={
"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
]
}
cam_move_up={
"deadzone": 0.5,
"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
]
}
cam_move_down={
"deadzone": 0.5,
"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
]
}
[rendering]