mirror of
https://port.numenaute.org/aleajactaest/khanat-client.git
synced 2024-12-19 07:58:43 +00:00
57 lines
1.7 KiB
GDScript
57 lines
1.7 KiB
GDScript
extends Spatial
|
|
|
|
var player_speed = 1.0
|
|
var player_rotation_speed = 0.1
|
|
|
|
var heightmap = null
|
|
|
|
#func _ready():
|
|
#
|
|
# self.heightmap = Image.new()
|
|
# self.heightmap.load( "res://assets/decors/terrains/dunes_heightmap.png" )
|
|
#
|
|
|
|
func _input( event ):
|
|
var movment = Vector3( 0.0, 0.0, 0.0 )
|
|
var rotation = Vector3( 0.0, 0.0, 0.0 )
|
|
if event.is_action( "move_forward" ):
|
|
movment.z += self.player_speed
|
|
elif event.is_action( "move_backward" ):
|
|
movment.z -= self.player_speed
|
|
elif event.is_action( "move_left" ):
|
|
movment.x += self.player_speed
|
|
elif event.is_action( "move_right" ):
|
|
movment.x -= self.player_speed
|
|
|
|
if event.is_action( "turn_left" ):
|
|
rotation.y += self.player_rotation_speed
|
|
elif event.is_action( "turn_right" ):
|
|
rotation.y -= self.player_rotation_speed
|
|
|
|
$creatures/player.turn( rotation )
|
|
$creatures/player.move( movment )
|
|
|
|
|
|
func _process( delta ):
|
|
pass
|
|
# if self.heightmap:
|
|
# self.heightmap.lock()
|
|
# print( $creatures/player.translation )
|
|
# print( $creatures/player/model.translation )
|
|
# print( $creatures/player/model/ra.translation )
|
|
# var pixel = self.heightmap.get_pixel( $creatures/player/model/ra.translation.x*2048.0, $creatures/player/model/ra.translation.z*2048.0 )
|
|
|
|
# var pixel = self.heightmap.get_pixel( 512, 512 )
|
|
# self.heightmap.unlock()
|
|
# print ( pixel )
|
|
# var movment = Vector3( 0.0, 0.0, 0.0 )
|
|
# $creatures/player/model/ra.translation.y = pixel.r*10.0
|
|
# movment.y = pixel.r - $creatures/player/model/ra.translation.y
|
|
#
|
|
# $creatures/player.move( movment )
|
|
# print( movment )
|
|
|
|
|
|
func load_player( filename ):
|
|
$creatures/player.load_creature( filename )
|
|
|