diff options
Diffstat (limited to 'demos/3d/platformer')
37 files changed, 0 insertions, 420 deletions
diff --git a/demos/3d/platformer/bullet.gd b/demos/3d/platformer/bullet.gd deleted file mode 100644 index 29219403bd..0000000000 --- a/demos/3d/platformer/bullet.gd +++ /dev/null @@ -1,5 +0,0 @@ - -extends RigidBody - -# Member variables -var disabled = false diff --git a/demos/3d/platformer/bullet.scn b/demos/3d/platformer/bullet.scn Binary files differdeleted file mode 100644 index 54ceb50488..0000000000 --- a/demos/3d/platformer/bullet.scn +++ /dev/null diff --git a/demos/3d/platformer/coin.gd b/demos/3d/platformer/coin.gd deleted file mode 100644 index bd2eea81e2..0000000000 --- a/demos/3d/platformer/coin.gd +++ /dev/null @@ -1,11 +0,0 @@ - -extends Area - -# Member variables -var taken = false - - -func _on_coin_body_enter(body): - if (not taken and body extends preload("res://player.gd")): - get_node("anim").play("take") - taken = true diff --git a/demos/3d/platformer/coin.scn b/demos/3d/platformer/coin.scn Binary files differdeleted file mode 100644 index 238150788b..0000000000 --- a/demos/3d/platformer/coin.scn +++ /dev/null diff --git a/demos/3d/platformer/cutout.png b/demos/3d/platformer/cutout.png Binary files differdeleted file mode 100644 index f88a25cbc2..0000000000 --- a/demos/3d/platformer/cutout.png +++ /dev/null diff --git a/demos/3d/platformer/enemy.gd b/demos/3d/platformer/enemy.gd deleted file mode 100644 index 55c79e4858..0000000000 --- a/demos/3d/platformer/enemy.gd +++ /dev/null @@ -1,78 +0,0 @@ - -extends RigidBody - -# Member variables -const STATE_WALKING = 0 -const STATE_DYING = 1 - -var prev_advance = false -var deaccel = 20.0 -var accel = 5 -var max_speed = 2 -var rot_dir = 4 -var rot_speed = 1 - -var dying = false - - -func _integrate_forces(state): - var delta = state.get_step() - var lv = state.get_linear_velocity() - var g = state.get_total_gravity() - - lv += g*delta # Apply gravity - var up = -g.normalized() - - if (dying): - state.set_linear_velocity(lv) - return - - for i in range(state.get_contact_count()): - var cc = state.get_contact_collider_object(i) - var dp = state.get_contact_local_normal(i) - - if (cc): - if (cc extends preload("res://bullet.gd") and not cc.disabled): - set_mode(MODE_RIGID) - dying = true - #lv = s.get_contact_local_normal(i)*400 - state.set_angular_velocity(-dp.cross(up).normalized()*33.0) - get_node("AnimationPlayer").play("impact") - get_node("AnimationPlayer").queue("explode") - set_friction(1) - cc.disabled = true - get_node("sound").play("hit") - return - - var col_floor = get_node("Armature/ray_floor").is_colliding() - var col_wall = get_node("Armature/ray_wall").is_colliding() - - var advance = not col_wall and col_floor - - var dir = get_node("Armature").get_transform().basis[2].normalized() - var deaccel_dir = dir - - if (advance): - if (dir.dot(lv) < max_speed): - lv += dir*accel*delta - deaccel_dir = dir.cross(g).normalized() - else: - if (prev_advance): - rot_dir = 1 # randf()*2.0 - 1.0 - - dir = Matrix3(up, rot_dir*rot_speed*delta).xform(dir) - get_node("Armature").set_transform(Transform().looking_at(-dir, up)) - - var dspeed = deaccel_dir.dot(lv) - dspeed -= deaccel*delta - if (dspeed < 0): - dspeed = 0 - - lv = lv - deaccel_dir*deaccel_dir.dot(lv) + deaccel_dir*dspeed - - state.set_linear_velocity(lv) - prev_advance = advance - - -func _die(): - queue_free() diff --git a/demos/3d/platformer/enemy.scn b/demos/3d/platformer/enemy.scn Binary files differdeleted file mode 100644 index dd62692b7f..0000000000 --- a/demos/3d/platformer/enemy.scn +++ /dev/null diff --git a/demos/3d/platformer/engine.cfg b/demos/3d/platformer/engine.cfg deleted file mode 100644 index 84a7e8f597..0000000000 --- a/demos/3d/platformer/engine.cfg +++ /dev/null @@ -1,28 +0,0 @@ -[application] - -name="Platformer 3D" -main_scene="res://stage.scn" -icon="res://icon.png" - -[display] - -height=720 -stretch_2d=true - -[input] - -move_forward=[key(Up)] -move_backwards=[key(Down)] -move_left=[key(Left)] -move_right=[key(Right)] -jump=[key(Space)] -shoot=[key(Z)] - -[rasterizer] - -max_shadow_buffer_size=1024 -framebuffer_shrink=1 -shadow_filter=3 -debug_shadow_maps=false -fp16_framebuffer=true -debug_hdr=false diff --git a/demos/3d/platformer/follow_camera.gd b/demos/3d/platformer/follow_camera.gd deleted file mode 100644 index d0d531b9a5..0000000000 --- a/demos/3d/platformer/follow_camera.gd +++ /dev/null @@ -1,80 +0,0 @@ - -extends Camera - -# Member variables -var collision_exception = [] -export var min_distance = 0.5 -export var max_distance = 4.0 -export var angle_v_adjust = 0.0 -export var autoturn_ray_aperture = 25 -export var autoturn_speed = 50 -var max_height = 2.0 -var min_height = 0 - -func _fixed_process(dt): - var target = get_parent().get_global_transform().origin - var pos = get_global_transform().origin - var up = Vector3(0, 1, 0) - - var delta = pos - target - - # Regular delta follow - - # Check ranges - if (delta.length() < min_distance): - delta = delta.normalized()*min_distance - elif (delta.length() > max_distance): - delta = delta.normalized()*max_distance - - # Check upper and lower height - if (delta.y > max_height): - delta.y = max_height - if (delta.y < min_height): - delta.y = min_height - - # Check autoturn - var ds = PhysicsServer.space_get_direct_state(get_world().get_space()) - - var col_left = ds.intersect_ray(target, target + Matrix3(up, deg2rad(autoturn_ray_aperture)).xform(delta), collision_exception) - var col = ds.intersect_ray(target, target + delta, collision_exception) - var col_right = ds.intersect_ray(target, target + Matrix3(up, deg2rad(-autoturn_ray_aperture)).xform(delta), collision_exception) - - if (!col.empty()): - # If main ray was occluded, get camera closer, this is the worst case scenario - delta = col.position - target - elif (!col_left.empty() and col_right.empty()): - # If only left ray is occluded, turn the camera around to the right - delta = Matrix3(up, deg2rad(-dt*autoturn_speed)).xform(delta) - elif (col_left.empty() and !col_right.empty()): - # If only right ray is occluded, turn the camera around to the left - delta = Matrix3(up, deg2rad(dt*autoturn_speed)).xform(delta) - else: - # Do nothing otherwise, left and right are occluded but center is not, so do not autoturn - pass - - # Apply lookat - if (delta == Vector3()): - delta = (pos - target).normalized()*0.0001 - - pos = target + delta - - look_at_from_pos(pos, target, up) - - # Turn a little up or down - var t = get_transform() - t.basis = Matrix3(t.basis[0], deg2rad(angle_v_adjust))*t.basis - set_transform(t) - - -func _ready(): - # Find collision exceptions for ray - var node = self - while(node): - if (node extends RigidBody): - collision_exception.append(node.get_rid()) - break - else: - node = node.get_parent() - set_fixed_process(true) - # This detaches the camera transform from the parent spatial node - set_as_toplevel(true) diff --git a/demos/3d/platformer/icon.png b/demos/3d/platformer/icon.png Binary files differdeleted file mode 100644 index b2206e4592..0000000000 --- a/demos/3d/platformer/icon.png +++ /dev/null diff --git a/demos/3d/platformer/osb_down.png b/demos/3d/platformer/osb_down.png Binary files differdeleted file mode 100644 index 9666832863..0000000000 --- a/demos/3d/platformer/osb_down.png +++ /dev/null diff --git a/demos/3d/platformer/osb_fire.png b/demos/3d/platformer/osb_fire.png Binary files differdeleted file mode 100644 index 6f914cfe49..0000000000 --- a/demos/3d/platformer/osb_fire.png +++ /dev/null diff --git a/demos/3d/platformer/osb_jump.png b/demos/3d/platformer/osb_jump.png Binary files differdeleted file mode 100644 index 72ba032daa..0000000000 --- a/demos/3d/platformer/osb_jump.png +++ /dev/null diff --git a/demos/3d/platformer/osb_left.png b/demos/3d/platformer/osb_left.png Binary files differdeleted file mode 100644 index b8e08c2ce7..0000000000 --- a/demos/3d/platformer/osb_left.png +++ /dev/null diff --git a/demos/3d/platformer/osb_right.png b/demos/3d/platformer/osb_right.png Binary files differdeleted file mode 100644 index 0e5cbb0d54..0000000000 --- a/demos/3d/platformer/osb_right.png +++ /dev/null diff --git a/demos/3d/platformer/osb_up.png b/demos/3d/platformer/osb_up.png Binary files differdeleted file mode 100644 index 5c229d30ee..0000000000 --- a/demos/3d/platformer/osb_up.png +++ /dev/null diff --git a/demos/3d/platformer/player.gd b/demos/3d/platformer/player.gd deleted file mode 100644 index 7471460538..0000000000 --- a/demos/3d/platformer/player.gd +++ /dev/null @@ -1,211 +0,0 @@ - -extends RigidBody - -# Member variables -const ANIM_FLOOR = 0 -const ANIM_AIR_UP = 1 -const ANIM_AIR_DOWN = 2 - -const SHOOT_TIME = 1.5 -const SHOOT_SCALE = 2 - -const CHAR_SCALE = Vector3(0.3, 0.3, 0.3) - -var facing_dir = Vector3(1, 0, 0) -var movement_dir = Vector3() - -var jumping = false - -var turn_speed = 40 -var keep_jump_inertia = true -var air_idle_deaccel = false -var accel = 19.0 -var deaccel = 14.0 -var sharp_turn_threshold = 140 - -var max_speed = 3.1 -var on_floor = false - -var prev_shoot = false - -var last_floor_velocity = Vector3() - -var shoot_blend = 0 - - -func adjust_facing(p_facing, p_target, p_step, p_adjust_rate, current_gn): - var n = p_target # Normal - var t = n.cross(current_gn).normalized() - - var x = n.dot(p_facing) - var y = t.dot(p_facing) - - var ang = atan2(y,x) - - if (abs(ang) < 0.001): # Too small - return p_facing - - var s = sign(ang) - ang = ang*s - var turn = ang*p_adjust_rate*p_step - var a - if (ang < turn): - a = ang - else: - a = turn - ang = (ang - a)*s - - return (n*cos(ang) + t*sin(ang))*p_facing.length() - - -func _integrate_forces(state): - var lv = state.get_linear_velocity() # Linear velocity - var g = state.get_total_gravity() - var delta = state.get_step() -# var d = 1.0 - delta*state.get_total_density() -# if (d < 0): -# d = 0 - lv += g*delta # Apply gravity - - var anim = ANIM_FLOOR - - var up = -g.normalized() # (up is against gravity) - var vv = up.dot(lv) # Vertical velocity - var hv = lv - up*vv # Horizontal velocity - - var hdir = hv.normalized() # Horizontal direction - var hspeed = hv.length() # Horizontal speed - - var floor_velocity - var onfloor = false - - if (state.get_contact_count() == 0): - floor_velocity = last_floor_velocity - else: - for i in range(state.get_contact_count()): - if (state.get_contact_local_shape(i) != 1): - continue - - onfloor = true - floor_velocity = state.get_contact_collider_velocity_at_pos(i) - break - - var dir = Vector3() # Where does the player intend to walk to - var cam_xform = get_node("target/camera").get_global_transform() - - if (Input.is_action_pressed("move_forward")): - dir += -cam_xform.basis[2] - if (Input.is_action_pressed("move_backwards")): - dir += cam_xform.basis[2] - if (Input.is_action_pressed("move_left")): - dir += -cam_xform.basis[0] - if (Input.is_action_pressed("move_right")): - dir += cam_xform.basis[0] - - var jump_attempt = Input.is_action_pressed("jump") - var shoot_attempt = Input.is_action_pressed("shoot") - - var target_dir = (dir - up*dir.dot(up)).normalized() - - if (onfloor): - var sharp_turn = hspeed > 0.1 and rad2deg(acos(target_dir.dot(hdir))) > sharp_turn_threshold - - if (dir.length() > 0.1 and !sharp_turn): - if (hspeed > 0.001): - #linear_dir = linear_h_velocity/linear_vel - #if (linear_vel > brake_velocity_limit and linear_dir.dot(ctarget_dir) < -cos(Math::deg2rad(brake_angular_limit))) - # brake = true - #else - hdir = adjust_facing(hdir, target_dir, delta, 1.0/hspeed*turn_speed, up) - facing_dir = hdir - else: - hdir = target_dir - - if (hspeed < max_speed): - hspeed += accel*delta - else: - hspeed -= deaccel*delta - if (hspeed < 0): - hspeed = 0 - - hv = hdir*hspeed - - var mesh_xform = get_node("Armature").get_transform() - var facing_mesh = -mesh_xform.basis[0].normalized() - facing_mesh = (facing_mesh - up*facing_mesh.dot(up)).normalized() - facing_mesh = adjust_facing(facing_mesh, target_dir, delta, 1.0/hspeed*turn_speed, up) - var m3 = Matrix3(-facing_mesh, up, -facing_mesh.cross(up).normalized()).scaled(CHAR_SCALE) - - get_node("Armature").set_transform(Transform(m3, mesh_xform.origin)) - - if (not jumping and jump_attempt): - vv = 7.0 - jumping = true - get_node("sfx").play("jump") - else: - if (vv > 0): - anim = ANIM_AIR_UP - else: - anim = ANIM_AIR_DOWN - - var hs - if (dir.length() > 0.1): - hv += target_dir*(accel*0.2)*delta - if (hv.length() > max_speed): - hv = hv.normalized()*max_speed - else: - if (air_idle_deaccel): - hspeed = hspeed - (deaccel*0.2)*delta - if (hspeed < 0): - hspeed = 0 - - hv = hdir*hspeed - - if (jumping and vv < 0): - jumping = false - - lv = hv + up*vv - - if (onfloor): - movement_dir = lv - #lv += floor_velocity - last_floor_velocity = floor_velocity - else: - if (on_floor): - #if (keep_jump_inertia): - # lv += last_floor_velocity - pass - - last_floor_velocity = Vector3() - movement_dir = lv - - on_floor = onfloor - - state.set_linear_velocity(lv) - - if (shoot_blend > 0): - shoot_blend -= delta*SHOOT_SCALE - if (shoot_blend < 0): - shoot_blend = 0 - - if (shoot_attempt and not prev_shoot): - shoot_blend = SHOOT_TIME - var bullet = preload("res://bullet.scn").instance() - bullet.set_transform(get_node("Armature/bullet").get_global_transform().orthonormalized()) - get_parent().add_child(bullet) - bullet.set_linear_velocity(get_node("Armature/bullet").get_global_transform().basis[2].normalized()*20) - PS.body_add_collision_exception(bullet.get_rid(), get_rid()) # Add it to bullet - get_node("sfx").play("shoot") - - prev_shoot = shoot_attempt - - if (onfloor): - get_node("AnimationTreePlayer").blend2_node_set_amount("walk", hspeed/max_speed) - - get_node("AnimationTreePlayer").transition_node_set_current("state", anim) - get_node("AnimationTreePlayer").blend2_node_set_amount("gun", min(shoot_blend, 1.0)) -# state.set_angular_velocity(Vector3()) - - -func _ready(): - get_node("AnimationTreePlayer").set_active(true) diff --git a/demos/3d/platformer/player.scn b/demos/3d/platformer/player.scn Binary files differdeleted file mode 100644 index 3b24da94ec..0000000000 --- a/demos/3d/platformer/player.scn +++ /dev/null diff --git a/demos/3d/platformer/robotrigged.scn b/demos/3d/platformer/robotrigged.scn Binary files differdeleted file mode 100644 index 68af0cfe47..0000000000 --- a/demos/3d/platformer/robotrigged.scn +++ /dev/null diff --git a/demos/3d/platformer/sb.cube b/demos/3d/platformer/sb.cube deleted file mode 100644 index c5e4acbcd4..0000000000 --- a/demos/3d/platformer/sb.cube +++ /dev/null @@ -1,7 +0,0 @@ -sb_left.png -sb_right.png -sb_bottom.png -sb_top.png -sb_back.png -sb_front.png - diff --git a/demos/3d/platformer/sb_back.png b/demos/3d/platformer/sb_back.png Binary files differdeleted file mode 100644 index 85ba234654..0000000000 --- a/demos/3d/platformer/sb_back.png +++ /dev/null diff --git a/demos/3d/platformer/sb_bottom.png b/demos/3d/platformer/sb_bottom.png Binary files differdeleted file mode 100644 index 46cb8fd765..0000000000 --- a/demos/3d/platformer/sb_bottom.png +++ /dev/null diff --git a/demos/3d/platformer/sb_front.png b/demos/3d/platformer/sb_front.png Binary files differdeleted file mode 100644 index 0ddaede187..0000000000 --- a/demos/3d/platformer/sb_front.png +++ /dev/null diff --git a/demos/3d/platformer/sb_left.png b/demos/3d/platformer/sb_left.png Binary files differdeleted file mode 100644 index a548d7ef13..0000000000 --- a/demos/3d/platformer/sb_left.png +++ /dev/null diff --git a/demos/3d/platformer/sb_right.png b/demos/3d/platformer/sb_right.png Binary files differdeleted file mode 100644 index 36ac03db3a..0000000000 --- a/demos/3d/platformer/sb_right.png +++ /dev/null diff --git a/demos/3d/platformer/sb_top.png b/demos/3d/platformer/sb_top.png Binary files differdeleted file mode 100644 index af7274447e..0000000000 --- a/demos/3d/platformer/sb_top.png +++ /dev/null diff --git a/demos/3d/platformer/shine.png b/demos/3d/platformer/shine.png Binary files differdeleted file mode 100644 index 5c722219ec..0000000000 --- a/demos/3d/platformer/shine.png +++ /dev/null diff --git a/demos/3d/platformer/sound_coin.wav b/demos/3d/platformer/sound_coin.wav Binary files differdeleted file mode 100644 index e78579f461..0000000000 --- a/demos/3d/platformer/sound_coin.wav +++ /dev/null diff --git a/demos/3d/platformer/sound_explode.wav b/demos/3d/platformer/sound_explode.wav Binary files differdeleted file mode 100644 index 229c85399c..0000000000 --- a/demos/3d/platformer/sound_explode.wav +++ /dev/null diff --git a/demos/3d/platformer/sound_hit.wav b/demos/3d/platformer/sound_hit.wav Binary files differdeleted file mode 100644 index 4fb3b13812..0000000000 --- a/demos/3d/platformer/sound_hit.wav +++ /dev/null diff --git a/demos/3d/platformer/sound_jump.wav b/demos/3d/platformer/sound_jump.wav Binary files differdeleted file mode 100644 index e9942e65e6..0000000000 --- a/demos/3d/platformer/sound_jump.wav +++ /dev/null diff --git a/demos/3d/platformer/sound_shoot.wav b/demos/3d/platformer/sound_shoot.wav Binary files differdeleted file mode 100644 index ad74f328cb..0000000000 --- a/demos/3d/platformer/sound_shoot.wav +++ /dev/null diff --git a/demos/3d/platformer/stage.scn b/demos/3d/platformer/stage.scn Binary files differdeleted file mode 100644 index 7eafda5888..0000000000 --- a/demos/3d/platformer/stage.scn +++ /dev/null diff --git a/demos/3d/platformer/texture.tex b/demos/3d/platformer/texture.tex Binary files differdeleted file mode 100644 index d9181b7ffa..0000000000 --- a/demos/3d/platformer/texture.tex +++ /dev/null diff --git a/demos/3d/platformer/tiles.res b/demos/3d/platformer/tiles.res Binary files differdeleted file mode 100644 index d4fb779ff1..0000000000 --- a/demos/3d/platformer/tiles.res +++ /dev/null diff --git a/demos/3d/platformer/tiles.scn b/demos/3d/platformer/tiles.scn Binary files differdeleted file mode 100644 index 4c3442dbeb..0000000000 --- a/demos/3d/platformer/tiles.scn +++ /dev/null diff --git a/demos/3d/platformer/tiles.xcf b/demos/3d/platformer/tiles.xcf Binary files differdeleted file mode 100644 index 1cf5197598..0000000000 --- a/demos/3d/platformer/tiles.xcf +++ /dev/null |