Tank files
This commit is contained in:
parent
97df1ed4d7
commit
07daa03e63
7 changed files with 181 additions and 0 deletions
24
Levels/Level01.tscn
Normal file
24
Levels/Level01.tscn
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Objects/Player-tank/player.tscn" type="PackedScene" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="PlaneMesh" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape" id=2]
|
||||||
|
|
||||||
|
[node name="Spatial" type="Spatial"]
|
||||||
|
|
||||||
|
[node name="PlayerTank" parent="." instance=ExtResource( 1 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -22.6472, 1.4303, 4.43473 )
|
||||||
|
|
||||||
|
[node name="StaticBody" type="StaticBody" parent="."]
|
||||||
|
transform = Transform( 50, 0, 0, 0, 1, 0, 0, 0, 50, 0, 0, 0 )
|
||||||
|
|
||||||
|
[node name="Plane" type="MeshInstance" parent="StaticBody"]
|
||||||
|
mesh = SubResource( 1 )
|
||||||
|
skeleton = NodePath("../..")
|
||||||
|
material/0 = null
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 0.0361063, 0, 0, 0, 1, 0, 0, 0 )
|
||||||
|
shape = SubResource( 2 )
|
38
Objects/Player-tank/Player.gd
Normal file
38
Objects/Player-tank/Player.gd
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
extends KinematicBody
|
||||||
|
|
||||||
|
onready var camera = get_node("Camera")
|
||||||
|
var rayOrigin = Vector3()
|
||||||
|
var rayEnd = Vector3()
|
||||||
|
var speed = 15
|
||||||
|
var gravity = 100
|
||||||
|
var velocity = Vector3.ZERO
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
var direction = Vector3.ZERO
|
||||||
|
|
||||||
|
if Input.is_action_pressed("move_right"):
|
||||||
|
direction.x += 1
|
||||||
|
if Input.is_action_pressed("move_left"):
|
||||||
|
direction.x -= 1
|
||||||
|
if Input.is_action_pressed("move_back"):
|
||||||
|
direction.z += 1
|
||||||
|
if Input.is_action_pressed("move_forward"):
|
||||||
|
direction.z -= 1
|
||||||
|
|
||||||
|
var space_state = get_world().direct_space_state
|
||||||
|
var mouse_position = get_viewport().get_mouse_position()
|
||||||
|
rayOrigin = camera.project_ray_origin(mouse_position)
|
||||||
|
rayEnd = rayOrigin + camera.project_ray_normal(mouse_position) * 2000 # Set cursor position to where the raycast hit
|
||||||
|
var intersection = space_state.intersect_ray(rayOrigin, rayEnd) # Set variable for cursor position
|
||||||
|
if not intersection.empty(): # Make sure there is a intersection with raycast
|
||||||
|
var pos = intersection.position
|
||||||
|
$Tank.look_at(Vector3(pos.x, pos.y, pos.z), Vector3(0,1,0))
|
||||||
|
|
||||||
|
if direction != Vector3.ZERO:
|
||||||
|
direction = direction.normalized()
|
||||||
|
# $Pivot.look_at(translation + direction, Vector3.UP)
|
||||||
|
|
||||||
|
velocity.x = direction.x * speed
|
||||||
|
velocity.z = direction.z * speed
|
||||||
|
velocity.y -= gravity * delta
|
||||||
|
velocity = move_and_slide(velocity, Vector3.UP)
|
25
Objects/Player-tank/player.tscn
Normal file
25
Objects/Player-tank/player.tscn
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Objects/Player-tank/Player.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="CubeMesh" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=3]
|
||||||
|
albedo_color = Color( 1, 0, 0, 1 )
|
||||||
|
|
||||||
|
[node name="PlayerTank" type="Spatial"]
|
||||||
|
|
||||||
|
[node name="KinematicBody" type="KinematicBody" parent="."]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="KinematicBody"]
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="Camera" type="Camera" parent="KinematicBody"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 20.7405, -7.28392e-07 )
|
||||||
|
|
||||||
|
[node name="Tank" type="MeshInstance" parent="KinematicBody"]
|
||||||
|
mesh = SubResource( 2 )
|
||||||
|
material/0 = SubResource( 3 )
|
7
default_env.tres
Normal file
7
default_env.tres
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_resource type="Environment" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[sub_resource type="ProceduralSky" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
background_mode = 2
|
||||||
|
background_sky = SubResource( 1 )
|
BIN
icon.png
Normal file
BIN
icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
35
icon.png.import
Normal file
35
icon.png.import
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://icon.png"
|
||||||
|
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=true
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
52
project.godot
Normal file
52
project.godot
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
; Engine configuration file.
|
||||||
|
; It's best edited using the editor UI and not directly,
|
||||||
|
; since the parameters that go here are not all obvious.
|
||||||
|
;
|
||||||
|
; Format:
|
||||||
|
; [section] ; section goes between []
|
||||||
|
; param=value ; assign values to parameters
|
||||||
|
|
||||||
|
config_version=4
|
||||||
|
|
||||||
|
[application]
|
||||||
|
|
||||||
|
config/name="Tank Blaster"
|
||||||
|
run/main_scene="res://Levels/Level01.tscn"
|
||||||
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/width=1920
|
||||||
|
window/size/height=1080
|
||||||
|
window/size/fullscreen=true
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
move_right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_back={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_forward={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
[physics]
|
||||||
|
|
||||||
|
common/enable_pause_aware_picking=true
|
||||||
|
|
||||||
|
[rendering]
|
||||||
|
|
||||||
|
environment/default_environment="res://default_env.tres"
|
Loading…
Reference in a new issue