Skip to content

Commit

Permalink
Flycam
Browse files Browse the repository at this point in the history
  • Loading branch information
TutorialDoctor committed Dec 12, 2015
1 parent 98955fb commit a67d2f7
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 36 deletions.
6 changes: 3 additions & 3 deletions FlyCam/.fscache
@@ -1,4 +1,4 @@
::res://::1448637685
flycam.gd::GDScript::1448637685::
flycam.xml::PackedScene::1448637600::
::res://::1449891710
flycam.gd::GDScript::1449891710::
flycam.xml::PackedScene::1449715551::
icon.png::ImageTexture::1448615258::
40 changes: 28 additions & 12 deletions FlyCam/flycam.gd
Expand Up @@ -10,18 +10,27 @@ var projection
var camera
var quad
export var move_speed = 2
var tex = preload('res://icon.png')
var direction = Vector3()
var aim


# SETUP
func _ready():
set_process(true)
set_process_input(true)

# The camera could have been added manually, but I wanted this to be plug n' play.
camera = Camera.new()
camera.make_current()
add_child(camera)

var sprite3d = Sprite3D.new()
sprite3d.set_texture(tex)
sprite3d.set_scale(Vector3(.05,.05,.05))
sprite3d.set_translation(get_translation()+ Vector3(0,0,-6))
camera.add_child(sprite3d)
var yaw2 = Spatial.new()
yaw2.set_name('yaw')
add_child(yaw2)

# EVENT DRIVEN
# This code makes the camera aim. It alone does the aiming.
Expand All @@ -39,23 +48,30 @@ func _input(event):
func _process(delta):
# Return a normal vector in worldspace, that is the result of projecting a point on the Viewport rectangle by the camera projection.
# Basically it converts the mouse position to a 3d location/vector
projection = camera.project_ray_normal(get_viewport().get_mouse_pos())
#projection = camera.project_ray_normal(get_viewport().get_mouse_pos())
# Now I can move in the direction of the mouse
walk()


if Input.is_action_pressed("ui_up"):
set_translation(Vector3(get_translation()+projection*delta*move_speed))
# multiplied by delta for smoother translation motion

if Input.is_action_pressed("ui_down"):
set_translation(Vector3(get_translation()-projection*delta*move_speed))

if Input.is_key_pressed(81) or Input.is_key_pressed(16777217): # Q and Escape
get_tree().quit()

if Input.is_key_pressed(82): # R
get_tree().reload_current_scene()

func walk():
aim = get_node("yaw").get_global_transform().basis
if Input.is_action_pressed("ui_up"):
direction -= aim[2]
if Input.is_action_pressed("ui_down"):
direction += aim[2]
if Input.is_action_pressed('ui_right'):
direction +=aim[0]
if Input.is_action_pressed('ui_left'):
direction -=aim[0]
set_translation(direction*view_sensitivity)




# OTHER BUILT-IN FUNCTIONS
func _enter_tree():
Expand All @@ -64,4 +80,4 @@ func _enter_tree():

func _exit_tree():
# Show mouse upon exiting the tree/level
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE);
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE);
15 changes: 4 additions & 11 deletions FlyCam/flycam.xml
Expand Up @@ -8,7 +8,7 @@
<string> "conns" </string>
<int_array len="0"> </int_array>
<string> "names" </string>
<string_array len="66">
<string_array len="61">
<string> "Spatial" </string>
<string> "_import_path" </string>
<string> "_import_transform" </string>
Expand Down Expand Up @@ -70,18 +70,13 @@
<string> "Head" </string>
<string> "script/script" </string>
<string> "move_speed" </string>
<string> "Quad" </string>
<string> "quad/axis" </string>
<string> "quad/size" </string>
<string> "quad/offset" </string>
<string> "quad/centered" </string>
</string_array>
<string> "node_count" </string>
<int> 7 </int>
<int> 6 </int>
<string> "nodes" </string>
<int_array len="263"> -1, -1, 0, 0, -1, 4, 1, 0, 2, 1, 3, 2, 4, 3, 0, 0, 0, 5, 5, -1, 18, 1, 0, 3, 2, 6, 4, 7, 4, 8, 5, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 8, 16, 2, 17, 9, 18, 9, 19, 4, 20, 2, 21, 10, 0, 0, 0, 23, 22, -1, 18, 1, 0, 2, 1, 24, 11, 3, 2, 25, 5, 26, 2, 27, 12, 28, 2, 29, 2, 30, 13, 31, 13, 32, 13, 33, 8, 34, 8, 35, 8, 36, 8, 37, 8, 38, 14, 0, 0, 0, 23, 23, -1, 17, 1, 0, 2, 1, 3, 2, 25, 5, 26, 2, 27, 12, 28, 2, 29, 2, 30, 13, 31, 13, 32, 13, 33, 8, 34, 8, 35, 8, 36, 8, 37, 8, 38, 14, 0, 0, 0, 39, 39, -1, 23, 1, 0, 2, 1, 24, 15, 3, 2, 25, 5, 40, 2, 41, 8, 42, 14, 43, 16, 44, 17, 45, 17, 46, 8, 47, 13, 48, 18, 49, 13, 50, 19, 51, 4, 52, 12, 53, 14, 54, 14, 55, 13, 56, 20, 57, 21, 0, 0, 0, 0, 58, -1, 6, 1, 0, 2, 1, 24, 22, 3, 2, 59, 23, 60, 24, 0, 5, 0, 61, 61, -1, 21, 1, 0, 2, 1, 3, 2, 25, 5, 26, 2, 27, 12, 28, 2, 29, 2, 30, 13, 31, 13, 32, 13, 33, 8, 34, 8, 35, 8, 36, 8, 37, 8, 38, 14, 62, 9, 63, 25, 64, 26, 65, 2, 0 </int_array>
<int_array len="214"> -1, -1, 0, 0, -1, 4, 1, 0, 2, 1, 3, 2, 4, 3, 0, 0, 0, 5, 5, -1, 18, 1, 0, 3, 2, 6, 4, 7, 4, 8, 5, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 8, 16, 2, 17, 9, 18, 9, 19, 4, 20, 2, 21, 10, 0, 0, 0, 23, 22, -1, 18, 1, 0, 2, 1, 24, 11, 3, 2, 25, 5, 26, 2, 27, 12, 28, 2, 29, 2, 30, 13, 31, 13, 32, 13, 33, 8, 34, 8, 35, 8, 36, 8, 37, 8, 38, 14, 0, 0, 0, 23, 23, -1, 17, 1, 0, 2, 1, 3, 2, 25, 5, 26, 2, 27, 12, 28, 2, 29, 2, 30, 13, 31, 13, 32, 13, 33, 8, 34, 8, 35, 8, 36, 8, 37, 8, 38, 14, 0, 0, 0, 39, 39, -1, 23, 1, 0, 2, 1, 24, 15, 3, 2, 25, 5, 40, 2, 41, 8, 42, 14, 43, 16, 44, 17, 45, 17, 46, 8, 47, 13, 48, 18, 49, 13, 50, 19, 51, 4, 52, 12, 53, 14, 54, 14, 55, 13, 56, 20, 57, 21, 0, 0, 0, 0, 58, -1, 6, 1, 0, 2, 1, 24, 22, 3, 2, 59, 23, 60, 24, 0 </int_array>
<string> "variants" </string>
<array len="27" shared="false">
<array len="25" shared="false">
<node_path> "" </node_path>
<transform> 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 </transform>
<bool> True </bool>
Expand Down Expand Up @@ -245,8 +240,6 @@
<transform> 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5.19473 </transform>
<resource resource_type="Script" path="res://flycam.gd"> </resource>
<int> 3 </int>
<vector2> 1, 1 </vector2>
<vector2> 0, 0 </vector2>
</array>
<string> "version" </string>
<int> 1 </int>
Expand Down
1 change: 0 additions & 1 deletion FlyCam/readme.md

This file was deleted.

21 changes: 12 additions & 9 deletions Piskel Game/.fscache
@@ -1,21 +1,22 @@
::res://::1449375880
::res://::1449521536
icon.png::ImageTexture::1448925517::
screenshot.png::ImageTexture::1448925517::
screenshot.png::ImageTexture::1449520895::
::res://Assets::1448925517
::res://Assets/Scripts::1449376208
anim.gd::GDScript::1449376208::
game.gd::GDScript::1449376208::
::res://Assets/Scripts::1449523766
anim.gd::GDScript::1449523766::
game.gd::GDScript::1449523766::
labels.gd::GDScript::1449523766::
loopSprite.gd::GDScript::1448925517::
::res://Assets/Sounds::1448925517
::res://Assets/Sounds/Music::1448925517
Vino.ogg::AudioStreamOGGVorbis::1448925517::
::res://Assets/Sounds/sfx::1449286168
::res://Assets/Sounds/sfx::1449454022
jump.wav::Sample::1448925517::
punch.wav::Sample::1370673508::
::res://Assets/Sprites::1449115397
chr_animal_walking_2.png::ImageTexture::1448925517::
large mountain.png::ImageTexture::1448925517::
::res://Assets/Sprites/Characters::1449449144
::res://Assets/Sprites/Characters::1449532229
::res://Assets/Sprites/Characters/chr_base_5_f::1448990523
::res://Assets/Sprites/Characters/chr_base_5_f/1024::1448990523
chr_base_5_f_1024.png::ImageTexture::1448990523::
Expand Down Expand Up @@ -114,6 +115,8 @@ chrs_blueHeros_1024.png::ImageTexture::1448990523::
chrs_blueHeros_256.png::ImageTexture::1448991238::
::res://Assets/Sprites/Characters/chrs_blueHeros/32::1448990523
chrs_blueHeros_32.png::ImageTexture::1448990523::
::res://Assets/Sprites/Characters/chrs_frozen::1449532206
chrs_frozen_256.png::ImageTexture::1449532202::
::res://Assets/Sprites/Characters/chrs_jackAndjill::1448990523
::res://Assets/Sprites/Characters/chrs_jackAndjill/1024::1448990523
chrs_jackAndjill_1024.png::ImageTexture::1448990523::
Expand Down Expand Up @@ -178,5 +181,5 @@ clouds2.png::ImageTexture::1448507088::
clouds3.png::ImageTexture::1448507088::
::res://Assets/Sprites/Props/props_studio::1449115368
props_studio_256.png::ImageTexture::1449115362::
::res://Levels::1449376045
level 1.xml::PackedScene::1449376045::
::res://Levels::1449521549
level 1.xml::PackedScene::1449521549::

0 comments on commit a67d2f7

Please sign in to comment.