mirror of
https://github.com/bvanroll/pogo.git
synced 2025-08-28 11:32:43 +00:00
mmm
This commit is contained in:
22
node_3d.gdshader
Normal file
22
node_3d.gdshader
Normal file
@@ -0,0 +1,22 @@
|
||||
shader_type spatial;
|
||||
|
||||
uniform float u_time;
|
||||
|
||||
void vertex() {
|
||||
// Called for every vertex the material is visible on.
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
// Called for every pixel the material is visible on.
|
||||
vec2 st = FRAGCOORD.xy;
|
||||
float r = sin(st.x * .003 + TIME);
|
||||
float g = sin(st.y * .003 + TIME);
|
||||
float b = cos(r/g);
|
||||
|
||||
ALBEDO = vec3(r, g, b);
|
||||
}
|
||||
|
||||
//void light() {
|
||||
// Called for every pixel for every light affecting the material.
|
||||
// Uncomment to replace the default light processing function with this one.
|
||||
//}
|
25
node_3d.tscn
25
node_3d.tscn
@@ -1,17 +1,30 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://cet5x83r5jeyl"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://cet5x83r5jeyl"]
|
||||
|
||||
[ext_resource type="Script" path="res://player_move.gd" id="1_3w378"]
|
||||
[ext_resource type="Shader" path="res://node_3d.gdshader" id="1_bq3vy"]
|
||||
[ext_resource type="Script" path="res://player_cam.gd" id="2_cfjd0"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_xx3kl"]
|
||||
size = Vector3(100, 0.1, 100)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_syt8p"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_bq3vy")
|
||||
shader_parameter/u_time = null
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_lwlrc"]
|
||||
material = SubResource("ShaderMaterial_syt8p")
|
||||
size = Vector3(100, 0.1, 100)
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_fla64"]
|
||||
|
||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_hyrp0"]
|
||||
|
||||
[sub_resource type="ImageTexture" id="ImageTexture_bll23"]
|
||||
|
||||
[sub_resource type="ORMMaterial3D" id="ORMMaterial3D_y47wq"]
|
||||
albedo_texture = SubResource("ImageTexture_bll23")
|
||||
|
||||
[node name="Node3D" type="Node3D"]
|
||||
|
||||
[node name="ground" type="StaticBody3D" parent="."]
|
||||
@@ -22,19 +35,21 @@ shape = SubResource("BoxShape3D_xx3kl")
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="ground"]
|
||||
mesh = SubResource("BoxMesh_lwlrc")
|
||||
|
||||
[node name="CharacterBody3D" type="CharacterBody3D" parent="."]
|
||||
[node name="player" type="CharacterBody3D" parent="."]
|
||||
script = ExtResource("1_3w378")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="CharacterBody3D"]
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="player"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
|
||||
shape = SubResource("CapsuleShape3D_fla64")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="CharacterBody3D"]
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="player"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
|
||||
mesh = SubResource("CapsuleMesh_hyrp0")
|
||||
surface_material_override/0 = SubResource("ORMMaterial3D_y47wq")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.945194, 0.326509, 0, -0.326509, 0.945194, 0, 3.40972, 20.5085)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
|
||||
script = ExtResource("2_cfjd0")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(0.996617, -0.082182, 1.18574e-09, 0.0479042, 0.580931, 0.812542, -0.0667763, -0.809793, 0.582903, 0, 14.9801, 0)
|
||||
|
19
player_cam.gd
Normal file
19
player_cam.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
extends Camera3D
|
||||
@onready
|
||||
var player = $"../player"
|
||||
|
||||
const cam_speed = 20.0
|
||||
const cam_distance = 2.0
|
||||
const player_height = 2.0
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
position.y = move_toward(position.y, player.position.y + cam_distance + player_height/2., cam_speed * delta)
|
||||
position.z = move_toward(position.z, player.position.z + cam_distance, cam_speed*delta)
|
||||
position.x = move_toward(position.x, player.position.x, cam_speed* delta)
|
||||
look_at(player.position + Vector3(0., player_height, 0.))
|
||||
pass
|
@@ -4,8 +4,10 @@ extends CharacterBody3D
|
||||
const SPEED = 5.0
|
||||
const AIRSPEED = 8.0
|
||||
const MAXSPEED = 8.0
|
||||
const JUMP_VELOCITY = 3.5
|
||||
|
||||
const JUMP_VELOCITY = 8.5
|
||||
const BHOPDIFF = 8.0 #difficulty for bhops aka time before the rebounce height is reduced to 0
|
||||
const BHOPHEIGHTDIV = 3. #divides the rebounce height, 1 for perfect rebounce
|
||||
var max_neg_vel = 0.0
|
||||
# Get the gravity from the project settings to be synced with RigidBody nodes.
|
||||
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
||||
|
||||
@@ -14,7 +16,7 @@ func _physics_process(delta):
|
||||
# Add the gravity.
|
||||
|
||||
# Handle jump.
|
||||
var jv = JUMP_VELOCITY + abs(velocity.y)
|
||||
|
||||
#if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
# velocity.y = jv
|
||||
|
||||
@@ -22,24 +24,30 @@ func _physics_process(delta):
|
||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||
var input_dir = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||
|
||||
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
|
||||
var direction = (transform.basis * Vector3(0, 0, input_dir.y)).normalized()
|
||||
var rotation = input_dir.x;
|
||||
if is_on_floor():
|
||||
var jv = JUMP_VELOCITY + (abs(velocity.y) *2.)
|
||||
if direction:
|
||||
if abs(velocity.x) < MAXSPEED:
|
||||
velocity.x += direction.x * SPEED *3. * delta
|
||||
if abs(velocity.z) < MAXSPEED:
|
||||
velocity.z += direction.z * SPEED *3. * delta
|
||||
if Input.is_action_pressed("ui_accept"):
|
||||
velocity.y += jv
|
||||
if Input.is_action_just_pressed("ui_accept") or Input.is_action_just_pressed("jump"):
|
||||
velocity.y += jv + abs(max_neg_vel/BHOPHEIGHTDIV)
|
||||
|
||||
max_neg_vel = move_toward(max_neg_vel, 0, SPEED * (delta*BHOPDIFF))
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED * delta)
|
||||
velocity.z = move_toward(velocity.z, 0, SPEED * delta)
|
||||
|
||||
else:
|
||||
velocity.y -= gravity * delta
|
||||
if velocity.y < max_neg_vel:
|
||||
max_neg_vel = velocity.y
|
||||
if direction:
|
||||
velocity.x += direction.x * AIRSPEED *3. * delta
|
||||
velocity.z += direction.z * AIRSPEED *3. * delta
|
||||
rotate_y(input_dir.x)
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED * (delta/2.))
|
||||
velocity.z = move_toward(velocity.z, 0, SPEED * (delta/2.))
|
||||
log(1.)
|
||||
|
@@ -15,6 +15,14 @@ run/main_scene="res://node_3d.tscn"
|
||||
config/features=PackedStringArray("4.2", "GL Compatibility")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[input]
|
||||
|
||||
jump={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
|
Reference in New Issue
Block a user