Compare commits
33 Commits
3.2-5bd2bb
...
2.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
238b5f001c | ||
|
|
9537d1fc99 | ||
|
|
0b47703fc4 | ||
|
|
c231e2abba | ||
|
|
b02987981b | ||
|
|
7dec39be19 | ||
|
|
1ef7c8defb | ||
|
|
238057d534 | ||
|
|
4221882f58 | ||
|
|
9587296412 | ||
|
|
5f65fcbca1 | ||
|
|
af5d7a1598 | ||
|
|
b6db599fa1 | ||
|
|
0eec5d704a | ||
|
|
864b185f51 | ||
|
|
35d4415184 | ||
|
|
951315dd26 | ||
|
|
71e832089d | ||
|
|
fdcdd2ea5b | ||
|
|
2666ea133b | ||
|
|
2ce07fd572 | ||
|
|
ff8052794b | ||
|
|
d88403cec1 | ||
|
|
b6390ebc4d | ||
|
|
5fe6147a34 | ||
|
|
4621cbd2d3 | ||
|
|
cbccc3a3da | ||
|
|
491aef3974 | ||
|
|
67313fc1be | ||
|
|
ed6ae9dc2f | ||
|
|
5260eeabc7 | ||
|
|
f18d5d02c3 | ||
|
|
ed9494f251 |
8
.editorconfig
Normal file
@@ -0,0 +1,8 @@
|
||||
# Top-most EditorConfig file.
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file.
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# Normalize EOL for all files that Git considers text files.
|
||||
* text=auto eol=lf
|
||||
19
.github/workflows/static_checks.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
name: Static Checks
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
format:
|
||||
name: File formatting (file_format.sh)
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -qq dos2unix recode
|
||||
|
||||
- name: File formatting checks (file_format.sh)
|
||||
run: |
|
||||
bash ./file_format.sh
|
||||
22
.gitignore
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
|
||||
# Godot-specific ignores
|
||||
.import/
|
||||
export.cfg
|
||||
export_presets.cfg
|
||||
# Dummy HTML5 export presets file for continuous integration
|
||||
!.github/dist/export_presets.cfg
|
||||
|
||||
# Imported translations (automatically generated from CSV files)
|
||||
*.translation
|
||||
|
||||
# Mono-specific ignores
|
||||
.mono/
|
||||
data_*/
|
||||
mono_crash.*.json
|
||||
|
||||
# System/tool-specific ignores
|
||||
.directory
|
||||
.DS_Store
|
||||
*~
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Area2D
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends RigidBody2D
|
||||
|
||||
# Member variables
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Node2D
|
||||
|
||||
# Member variables
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends TileMap
|
||||
|
||||
# Member variables
|
||||
@@ -30,7 +29,7 @@ var l = range(2, 5)
|
||||
# Process that runs in realtime
|
||||
func _fixed_process(delta):
|
||||
position = get_node("../troll").get_pos()
|
||||
|
||||
|
||||
# Calculate the corresponding tile
|
||||
# from the players position
|
||||
x = int(position.x/get_cell_size().x)
|
||||
@@ -38,11 +37,11 @@ func _fixed_process(delta):
|
||||
# causes problems because of rounding problems
|
||||
if position.x < 0:
|
||||
x -= 1 # Correct negative values
|
||||
|
||||
|
||||
y = int(position.y/get_cell_size().y)
|
||||
if (position.y < 0):
|
||||
y -= 1
|
||||
|
||||
|
||||
# Check if the player moved one tile further
|
||||
if ((x_old != x) or (y_old != y)):
|
||||
# Create the transparent part (visited area)
|
||||
@@ -55,7 +54,7 @@ func _fixed_process(delta):
|
||||
set_cell(m, n, 1, 0, 0)
|
||||
end -= 1
|
||||
start += 1
|
||||
|
||||
|
||||
# Create the actual and active visible part
|
||||
var end = l.size() - 1
|
||||
var start = 0
|
||||
@@ -65,7 +64,7 @@ func _fixed_process(delta):
|
||||
set_cell(m, n, -1)
|
||||
end -= 1
|
||||
start += 1
|
||||
|
||||
|
||||
x_old = x
|
||||
y_old = y
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends KinematicBody2D
|
||||
|
||||
# This is a simple collision demo showing how
|
||||
@@ -13,7 +12,7 @@ const MOTION_SPEED = 160 # Pixels/second
|
||||
|
||||
func _fixed_process(delta):
|
||||
var motion = Vector2()
|
||||
|
||||
|
||||
if (Input.is_action_pressed("move_up")):
|
||||
motion += Vector2(0, -1)
|
||||
if (Input.is_action_pressed("move_bottom")):
|
||||
@@ -22,10 +21,10 @@ func _fixed_process(delta):
|
||||
motion += Vector2(-1, 0)
|
||||
if (Input.is_action_pressed("move_right")):
|
||||
motion += Vector2(1, 0)
|
||||
|
||||
|
||||
motion = motion.normalized()*MOTION_SPEED*delta
|
||||
motion = move(motion)
|
||||
|
||||
|
||||
# Make character slide nicely through the world
|
||||
var slide_attempts = 4
|
||||
while(is_colliding() and slide_attempts > 0):
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Node2D
|
||||
|
||||
# Member variables
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
extends KinematicBody2D
|
||||
|
||||
# This is a simple collision demo showing how
|
||||
# the kinematic controller works.
|
||||
# move() will allow to move the node, and will
|
||||
# always move it to a non-colliding spot,
|
||||
# always move it to a non-colliding spot,
|
||||
# as long as it starts from a non-colliding spot too.
|
||||
|
||||
# Member variables
|
||||
@@ -13,7 +12,7 @@ const MOTION_SPEED = 160 # Pixels/second
|
||||
|
||||
func _fixed_process(delta):
|
||||
var motion = Vector2()
|
||||
|
||||
|
||||
if (Input.is_action_pressed("move_up")):
|
||||
motion += Vector2(0, -1)
|
||||
if (Input.is_action_pressed("move_bottom")):
|
||||
@@ -22,10 +21,10 @@ func _fixed_process(delta):
|
||||
motion += Vector2(-1, 0)
|
||||
if (Input.is_action_pressed("move_right")):
|
||||
motion += Vector2(1, 0)
|
||||
|
||||
|
||||
motion = motion.normalized()*MOTION_SPEED*delta
|
||||
motion = move(motion)
|
||||
|
||||
|
||||
# Make character slide nicely through the world
|
||||
var slide_attempts = 4
|
||||
while(is_colliding() and slide_attempts > 0):
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
extends KinematicBody2D
|
||||
|
||||
# This is a simple collision demo showing how
|
||||
# the kinematic controller works.
|
||||
# move() will allow to move the node, and will
|
||||
# always move it to a non-colliding spot,
|
||||
# always move it to a non-colliding spot,
|
||||
# as long as it starts from a non-colliding spot too.
|
||||
|
||||
# Member variables
|
||||
@@ -13,7 +12,7 @@ const MOTION_SPEED = 160 # Pixels/seconds
|
||||
|
||||
func _fixed_process(delta):
|
||||
var motion = Vector2()
|
||||
|
||||
|
||||
if (Input.is_action_pressed("move_up")):
|
||||
motion += Vector2(0, -1)
|
||||
if (Input.is_action_pressed("move_bottom")):
|
||||
@@ -22,10 +21,10 @@ func _fixed_process(delta):
|
||||
motion += Vector2(-1, 0)
|
||||
if (Input.is_action_pressed("move_right")):
|
||||
motion += Vector2(1, 0)
|
||||
|
||||
|
||||
motion = motion.normalized()*MOTION_SPEED*delta
|
||||
motion = move(motion)
|
||||
|
||||
|
||||
# Make character slide nicely through the world
|
||||
var slide_attempts = 4
|
||||
while(is_colliding() and slide_attempts > 0):
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends KinematicBody2D
|
||||
|
||||
# Member variables
|
||||
@@ -37,14 +36,14 @@ func _fixed_process(delta):
|
||||
dir += Vector2(-1, 0)
|
||||
if (Input.is_action_pressed("right")):
|
||||
dir += Vector2(1, 0)
|
||||
|
||||
|
||||
if (dir != Vector2()):
|
||||
dir = dir.normalized()
|
||||
speed = speed.linear_interpolate(dir*MAX_SPEED, delta*ACCEL)
|
||||
var motion = speed*delta
|
||||
motion.y *= VSCALE
|
||||
motion = move(motion)
|
||||
|
||||
|
||||
if (is_colliding()):
|
||||
var n = get_collision_normal()
|
||||
motion = n.slide(motion)
|
||||
@@ -52,13 +51,13 @@ func _fixed_process(delta):
|
||||
|
||||
var next_anim = ""
|
||||
var next_mirror = false
|
||||
|
||||
|
||||
if (dir == Vector2() and speed.length() < IDLE_SPEED):
|
||||
next_anim = "idle"
|
||||
next_mirror = false
|
||||
elif (speed.length() > IDLE_SPEED*0.1):
|
||||
var angle = atan2(abs(speed.x), speed.y)
|
||||
|
||||
|
||||
next_mirror = speed.x > 0
|
||||
if (angle < PI/8):
|
||||
next_anim = "bottom"
|
||||
@@ -72,7 +71,7 @@ func _fixed_process(delta):
|
||||
else:
|
||||
next_anim = "top"
|
||||
next_mirror = false
|
||||
|
||||
|
||||
if (next_anim != current_anim or next_mirror != current_mirror):
|
||||
get_node("frames").set_flip_h(next_mirror)
|
||||
get_node("anim").play(next_anim)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Node2D
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends KinematicBody2D
|
||||
|
||||
# Member variables
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Node2D
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends KinematicBody2D
|
||||
|
||||
# This is a simple collision demo showing how
|
||||
@@ -32,13 +31,13 @@ var prev_jump_pressed = false
|
||||
func _fixed_process(delta):
|
||||
# Create forces
|
||||
var force = Vector2(0, GRAVITY)
|
||||
|
||||
|
||||
var walk_left = Input.is_action_pressed("move_left")
|
||||
var walk_right = Input.is_action_pressed("move_right")
|
||||
var jump = Input.is_action_pressed("jump")
|
||||
|
||||
|
||||
var stop = true
|
||||
|
||||
|
||||
if (walk_left):
|
||||
if (velocity.x <= WALK_MIN_SPEED and velocity.x > -WALK_MAX_SPEED):
|
||||
force.x -= WALK_FORCE
|
||||
@@ -47,50 +46,50 @@ func _fixed_process(delta):
|
||||
if (velocity.x >= -WALK_MIN_SPEED and velocity.x < WALK_MAX_SPEED):
|
||||
force.x += WALK_FORCE
|
||||
stop = false
|
||||
|
||||
|
||||
if (stop):
|
||||
var vsign = sign(velocity.x)
|
||||
var vlen = abs(velocity.x)
|
||||
|
||||
|
||||
vlen -= STOP_FORCE*delta
|
||||
if (vlen < 0):
|
||||
vlen = 0
|
||||
|
||||
|
||||
velocity.x = vlen*vsign
|
||||
|
||||
|
||||
# Integrate forces to velocity
|
||||
velocity += force*delta
|
||||
|
||||
|
||||
# Integrate velocity into motion and move
|
||||
var motion = velocity*delta
|
||||
|
||||
|
||||
# Move and consume motion
|
||||
motion = move(motion)
|
||||
|
||||
|
||||
var floor_velocity = Vector2()
|
||||
|
||||
|
||||
if (is_colliding()):
|
||||
# You can check which tile was collision against with this
|
||||
# print(get_collider_metadata())
|
||||
|
||||
|
||||
# Ran against something, is it the floor? Get normal
|
||||
var n = get_collision_normal()
|
||||
|
||||
|
||||
if (rad2deg(acos(n.dot(Vector2(0, -1)))) < FLOOR_ANGLE_TOLERANCE):
|
||||
# If angle to the "up" vectors is < angle tolerance
|
||||
# char is on floor
|
||||
on_air_time = 0
|
||||
floor_velocity = get_collider_velocity()
|
||||
|
||||
|
||||
if (on_air_time == 0 and force.x == 0 and get_travel().length() < SLIDE_STOP_MIN_TRAVEL and abs(velocity.x) < SLIDE_STOP_VELOCITY and get_collider_velocity() == Vector2()):
|
||||
# Since this formula will always slide the character around,
|
||||
# a special case must be considered to to stop it from moving
|
||||
# Since this formula will always slide the character around,
|
||||
# a special case must be considered to to stop it from moving
|
||||
# if standing on an inclined floor. Conditions are:
|
||||
# 1) Standing on floor (on_air_time == 0)
|
||||
# 2) Did not move more than one pixel (get_travel().length() < SLIDE_STOP_MIN_TRAVEL)
|
||||
# 3) Not moving horizontally (abs(velocity.x) < SLIDE_STOP_VELOCITY)
|
||||
# 4) Collider is not moving
|
||||
|
||||
|
||||
revert_motion()
|
||||
velocity.y = 0.0
|
||||
else:
|
||||
@@ -100,21 +99,21 @@ func _fixed_process(delta):
|
||||
velocity = n.slide(velocity)
|
||||
# Then move again
|
||||
move(motion)
|
||||
|
||||
|
||||
if (floor_velocity != Vector2()):
|
||||
# If floor moves, move with floor
|
||||
move(floor_velocity*delta)
|
||||
|
||||
|
||||
if (jumping and velocity.y > 0):
|
||||
# If falling, no longer jumping
|
||||
jumping = false
|
||||
|
||||
|
||||
if (on_air_time < JUMP_MAX_AIRBORNE_TIME and jump and not prev_jump_pressed and not jumping):
|
||||
# Jump must also be allowed to happen if the character left the floor a little bit ago.
|
||||
# Makes controls more snappy.
|
||||
velocity.y = -JUMP_SPEED
|
||||
jumping = true
|
||||
|
||||
|
||||
on_air_time += delta
|
||||
prev_jump_pressed = jump
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
extends KinematicBody2D
|
||||
|
||||
# This is a simple collision demo showing how
|
||||
# the kinematic controller works.
|
||||
# move() will allow to move the node, and will
|
||||
# always move it to a non-colliding spot,
|
||||
# always move it to a non-colliding spot,
|
||||
# as long as it starts from a non-colliding spot too.
|
||||
|
||||
# Member variables
|
||||
@@ -13,7 +12,7 @@ const MOTION_SPEED = 160 # Pixels/second
|
||||
|
||||
func _fixed_process(delta):
|
||||
var motion = Vector2()
|
||||
|
||||
|
||||
if (Input.is_action_pressed("move_up")):
|
||||
motion += Vector2(0, -1)
|
||||
if (Input.is_action_pressed("move_bottom")):
|
||||
@@ -22,7 +21,7 @@ func _fixed_process(delta):
|
||||
motion += Vector2(-1, 0)
|
||||
if (Input.is_action_pressed("move_right")):
|
||||
motion += Vector2(1, 0)
|
||||
|
||||
|
||||
motion = motion.normalized()*MOTION_SPEED*delta
|
||||
move(motion)
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Sprite
|
||||
|
||||
# Member variables
|
||||
@@ -14,18 +13,18 @@ export(int, "Direct", "Constant", "Smooth") var mode = MODE_DIRECT
|
||||
|
||||
func _process(delta):
|
||||
var mpos = get_viewport().get_mouse_pos()
|
||||
|
||||
|
||||
if (mode == MODE_DIRECT):
|
||||
look_at(mpos)
|
||||
elif (mode == MODE_CONSTANT):
|
||||
var ang = get_angle_to(mpos)
|
||||
var s = sign(ang)
|
||||
ang = abs(ang)
|
||||
|
||||
|
||||
rotate(min(ang, ROTATION_SPEED*delta)*s)
|
||||
elif (mode == MODE_SMOOTH):
|
||||
var ang = get_angle_to(mpos)
|
||||
|
||||
|
||||
rotate(ang*delta*SMOOTH_SPEED)
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Sprite
|
||||
|
||||
# Member variables
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Navigation2D
|
||||
|
||||
# Member variables
|
||||
@@ -22,10 +21,10 @@ func _process(delta):
|
||||
else:
|
||||
path[path.size() - 1] = pfrom.linear_interpolate(pto, to_walk/d)
|
||||
to_walk = 0
|
||||
|
||||
|
||||
var atpos = path[path.size() - 1]
|
||||
get_node("agent").set_pos(atpos)
|
||||
|
||||
|
||||
if (path.size() < 2):
|
||||
path = []
|
||||
set_process(false)
|
||||
@@ -37,7 +36,7 @@ func _update_path():
|
||||
var p = get_simple_path(begin, end, true)
|
||||
path = Array(p) # Vector2array too complex to use, convert to regular array
|
||||
path.invert()
|
||||
|
||||
|
||||
set_process(true)
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends RigidBody2D
|
||||
|
||||
# Member variables
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Area2D
|
||||
|
||||
# Member variables
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends RigidBody2D
|
||||
|
||||
# Member variables
|
||||
@@ -36,13 +35,13 @@ func _integrate_forces(s):
|
||||
new_anim = "explode"
|
||||
elif (state == STATE_WALKING):
|
||||
new_anim = "walk"
|
||||
|
||||
|
||||
var wall_side = 0.0
|
||||
|
||||
|
||||
for i in range(s.get_contact_count()):
|
||||
var cc = s.get_contact_collider_object(i)
|
||||
var dp = s.get_contact_local_normal(i)
|
||||
|
||||
|
||||
if (cc):
|
||||
if (cc extends bullet_class and not cc.disabled):
|
||||
set_mode(MODE_RIGID)
|
||||
@@ -53,12 +52,12 @@ func _integrate_forces(s):
|
||||
cc.disable()
|
||||
get_node("sound").play("hit")
|
||||
break
|
||||
|
||||
|
||||
if (dp.x > 0.9):
|
||||
wall_side = 1.0
|
||||
elif (dp.x < -0.9):
|
||||
wall_side = -1.0
|
||||
|
||||
|
||||
if (wall_side != 0 and wall_side != direction):
|
||||
direction = -direction
|
||||
get_node("sprite").set_scale(Vector2(-direction, 1))
|
||||
@@ -68,13 +67,13 @@ func _integrate_forces(s):
|
||||
elif (direction > 0 and not rc_right.is_colliding() and rc_left.is_colliding()):
|
||||
direction = -direction
|
||||
get_node("sprite").set_scale(Vector2(-direction, 1))
|
||||
|
||||
|
||||
lv.x = direction*WALK_SPEED
|
||||
|
||||
|
||||
if(anim != new_anim):
|
||||
anim = new_anim
|
||||
get_node("anim").play(anim)
|
||||
|
||||
|
||||
s.set_linear_velocity(lv)
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Node2D
|
||||
|
||||
# Member variables
|
||||
@@ -12,7 +11,7 @@ func _fixed_process(delta):
|
||||
accum = fmod(accum, PI*2.0)
|
||||
var d = sin(accum)
|
||||
var xf = Matrix32()
|
||||
xf[2]= motion*d
|
||||
xf[2]= motion*d
|
||||
get_node("platform").set_transform(xf)
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends RigidBody2D
|
||||
|
||||
# Character Demo, written by Juan Linietsky.
|
||||
@@ -14,12 +13,12 @@ extends RigidBody2D
|
||||
# -Interaction with other physics-based objects is free
|
||||
# -Only have to deal with the object linear velocity, not position
|
||||
# -All collision/area framework available
|
||||
#
|
||||
#
|
||||
# But also has the following disadvantages:
|
||||
#
|
||||
#
|
||||
# -Objects may bounce a little bit sometimes
|
||||
# -Going up ramps sends the chracter flying up, small hack is needed.
|
||||
# -A ray collider is needed to avoid sliding down on ramps and
|
||||
# -A ray collider is needed to avoid sliding down on ramps and
|
||||
# undesiderd bumps, small steps and rare numerical precision errors.
|
||||
# (another alternative may be to turn on friction when the character is not moving).
|
||||
# -Friction cant be used, so floor velocity must be considered
|
||||
@@ -56,38 +55,38 @@ var enemy
|
||||
func _integrate_forces(s):
|
||||
var lv = s.get_linear_velocity()
|
||||
var step = s.get_step()
|
||||
|
||||
|
||||
var new_anim = anim
|
||||
var new_siding_left = siding_left
|
||||
|
||||
|
||||
# Get the controls
|
||||
var move_left = Input.is_action_pressed("move_left")
|
||||
var move_right = Input.is_action_pressed("move_right")
|
||||
var jump = Input.is_action_pressed("jump")
|
||||
var shoot = Input.is_action_pressed("shoot")
|
||||
var spawn = Input.is_action_pressed("spawn")
|
||||
|
||||
|
||||
if spawn:
|
||||
var e = enemy.instance()
|
||||
var p = get_pos()
|
||||
p.y = p.y - 100
|
||||
e.set_pos(p)
|
||||
get_parent().add_child(e)
|
||||
|
||||
|
||||
# Deapply prev floor velocity
|
||||
lv.x -= floor_h_velocity
|
||||
floor_h_velocity = 0.0
|
||||
|
||||
|
||||
# Find the floor (a contact with upwards facing collision normal)
|
||||
var found_floor = false
|
||||
var floor_index = -1
|
||||
|
||||
|
||||
for x in range(s.get_contact_count()):
|
||||
var ci = s.get_contact_local_normal(x)
|
||||
if (ci.dot(Vector2(0, -1)) > 0.6):
|
||||
found_floor = true
|
||||
floor_index = x
|
||||
|
||||
|
||||
# A good idea when impementing characters of all kinds,
|
||||
# compensates for physics imprecission, as well as human reaction delay.
|
||||
if (shoot and not shooting):
|
||||
@@ -99,35 +98,43 @@ func _integrate_forces(s):
|
||||
else:
|
||||
ss = 1.0
|
||||
var pos = get_pos() + get_node("bullet_shoot").get_pos()*Vector2(ss, 1.0)
|
||||
|
||||
|
||||
bi.set_pos(pos)
|
||||
get_parent().add_child(bi)
|
||||
|
||||
|
||||
bi.set_linear_velocity(Vector2(800.0*ss, -80))
|
||||
get_node("sprite/smoke").set_emitting(true)
|
||||
get_node("sound").play("shoot")
|
||||
PS2D.body_add_collision_exception(bi.get_rid(), get_rid()) # Make bullet and this not collide
|
||||
else:
|
||||
shoot_time += step
|
||||
|
||||
|
||||
if (found_floor):
|
||||
airborne_time = 0.0
|
||||
else:
|
||||
airborne_time += step # Time it spent in the air
|
||||
|
||||
|
||||
var on_floor = airborne_time < MAX_FLOOR_AIRBORNE_TIME
|
||||
|
||||
# Process jump
|
||||
if (jumping):
|
||||
# We want the character to immediately change facing side when the player
|
||||
# tries to change direction, during air control.
|
||||
# This allows for example the player to shoot quickly left then right.
|
||||
if (move_left and not move_right):
|
||||
get_node("sprite").set_scale(Vector2(-1, 1))
|
||||
if (move_right and not move_left):
|
||||
get_node("sprite").set_scale(Vector2(1, 1))
|
||||
|
||||
if (lv.y > 0):
|
||||
# Set off the jumping flag if going down
|
||||
jumping = false
|
||||
elif (not jump):
|
||||
stopping_jump = true
|
||||
|
||||
|
||||
if (stopping_jump):
|
||||
lv.y += STOP_JUMP_FORCE*step
|
||||
|
||||
|
||||
if (on_floor):
|
||||
# Process logic when character is on floor
|
||||
if (move_left and not move_right):
|
||||
@@ -142,14 +149,14 @@ func _integrate_forces(s):
|
||||
if (xv < 0):
|
||||
xv = 0
|
||||
lv.x = sign(lv.x)*xv
|
||||
|
||||
|
||||
# Check jump
|
||||
if (not jumping and jump):
|
||||
lv.y = -JUMP_VELOCITY
|
||||
jumping = true
|
||||
stopping_jump = false
|
||||
get_node("sound").play("jump")
|
||||
|
||||
|
||||
# Check siding
|
||||
if (lv.x < 0 and move_left):
|
||||
new_siding_left = true
|
||||
@@ -181,7 +188,7 @@ func _integrate_forces(s):
|
||||
if (xv < 0):
|
||||
xv = 0
|
||||
lv.x = sign(lv.x)*xv
|
||||
|
||||
|
||||
if (lv.y < 0):
|
||||
if (shoot_time < MAX_SHOOT_POSE_TIME):
|
||||
new_anim = "jumping_weapon"
|
||||
@@ -192,28 +199,28 @@ func _integrate_forces(s):
|
||||
new_anim = "falling_weapon"
|
||||
else:
|
||||
new_anim = "falling"
|
||||
|
||||
|
||||
# Update siding
|
||||
if (new_siding_left != siding_left):
|
||||
if (new_siding_left):
|
||||
get_node("sprite").set_scale(Vector2(-1, 1))
|
||||
else:
|
||||
get_node("sprite").set_scale(Vector2(1, 1))
|
||||
|
||||
|
||||
siding_left = new_siding_left
|
||||
|
||||
|
||||
# Change animation
|
||||
if (new_anim != anim):
|
||||
anim = new_anim
|
||||
get_node("anim").play(anim)
|
||||
|
||||
|
||||
shooting = shoot
|
||||
|
||||
|
||||
# Apply floor velocity
|
||||
if (found_floor):
|
||||
floor_h_velocity = s.get_contact_collider_velocity_at_pos(floor_index).x
|
||||
lv.x += floor_h_velocity
|
||||
|
||||
|
||||
# Finally, apply gravity and set back the linear velocity
|
||||
lv += s.get_total_gravity()*step
|
||||
s.set_linear_velocity(lv)
|
||||
@@ -221,7 +228,7 @@ func _integrate_forces(s):
|
||||
|
||||
func _ready():
|
||||
enemy = ResourceLoader.load("res://enemy.tscn")
|
||||
|
||||
|
||||
# if !Globals.has_singleton("Facebook"):
|
||||
# return
|
||||
# var Facebook = Globals.get_singleton("Facebook")
|
||||
|
||||
8
2d/platformer_kcc/bullet.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
extends RigidBody2D
|
||||
|
||||
func _on_bullet_body_enter( body ):
|
||||
if (body.has_method("hit_by_bullet")):
|
||||
body.call("hit_by_bullet")
|
||||
|
||||
func _on_Timer_timeout():
|
||||
get_node("anim").play("shutdown")
|
||||
BIN
2d/platformer_kcc/bullet.png
Normal file
|
After Width: | Height: | Size: 319 B |
120
2d/platformer_kcc/bullet.tscn
Normal file
@@ -0,0 +1,120 @@
|
||||
[gd_scene load_steps=6 format=1]
|
||||
|
||||
[ext_resource path="res://bullet.gd" type="Script" id=1]
|
||||
[ext_resource path="res://bullet.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
radius = 10.0
|
||||
|
||||
[sub_resource type="ColorRamp" id=2]
|
||||
|
||||
offsets = FloatArray( 0, 1 )
|
||||
colors = ColorArray( 1, 1, 1, 1, 1, 0, 0, 0 )
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
|
||||
length = 1.5
|
||||
loop = false
|
||||
step = 0.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("particles:config/emitting")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = { "times":FloatArray( 0 ), "transitions":FloatArray( 1 ), "update":1, "values":[ false ] }
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("sprite:visibility/self_opacity")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/imported = false
|
||||
tracks/1/keys = { "times":FloatArray( 0, 1.00394 ), "transitions":FloatArray( 1, 1 ), "update":0, "values":[ 1.0, 0.0 ] }
|
||||
tracks/2/type = "method"
|
||||
tracks/2/path = NodePath(".")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/imported = false
|
||||
tracks/2/keys = { "times":FloatArray( 1.31 ), "transitions":FloatArray( 1 ), "values":[ { "args":[ ], "method":"queue_free" } ] }
|
||||
|
||||
[node name="bullet" type="RigidBody2D"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 1 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
mode = 0
|
||||
mass = 1.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
gravity_scale = 1.0
|
||||
custom_integrator = false
|
||||
continuous_cd = 2
|
||||
contacts_reported = 3
|
||||
contact_monitor = true
|
||||
sleeping = false
|
||||
can_sleep = true
|
||||
velocity/linear = Vector2( 0, 0 )
|
||||
velocity/angular = 0.0
|
||||
damp_override/linear = -1.0
|
||||
damp_override/angular = -1.0
|
||||
script/script = ExtResource( 1 )
|
||||
|
||||
[node name="particles" type="Particles2D" parent="."]
|
||||
|
||||
visibility/opacity = 0.559322
|
||||
visibility/blend_mode = 1
|
||||
config/amount = 24
|
||||
config/lifetime = 0.1
|
||||
config/local_space = false
|
||||
config/texture = ExtResource( 2 )
|
||||
params/direction = 0.0
|
||||
params/spread = 10.0
|
||||
params/linear_velocity = 0.0
|
||||
params/spin_velocity = 0.0
|
||||
params/orbit_velocity = 0.0
|
||||
params/gravity_direction = 0.0
|
||||
params/gravity_strength = 0.0
|
||||
params/radial_accel = 0.0
|
||||
params/tangential_accel = 0.0
|
||||
params/damping = 0.0
|
||||
params/initial_angle = 0.0
|
||||
params/initial_size = 1.0
|
||||
params/final_size = 0.0
|
||||
params/hue_variation = 0.0
|
||||
params/anim_speed_scale = 1.0
|
||||
params/anim_initial_pos = 0.0
|
||||
color/color_ramp = SubResource( 2 )
|
||||
|
||||
[node name="sprite" type="Sprite" parent="."]
|
||||
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
|
||||
shape = SubResource( 1 )
|
||||
trigger = false
|
||||
_update_shape_index = -1
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
|
||||
process_mode = 1
|
||||
wait_time = 1.0
|
||||
one_shot = true
|
||||
autostart = true
|
||||
|
||||
[node name="anim" type="AnimationPlayer" parent="."]
|
||||
|
||||
playback/process_mode = 1
|
||||
playback/default_blend_time = 0.0
|
||||
root/root = NodePath("..")
|
||||
anims/shutdown = SubResource( 3 )
|
||||
playback/active = true
|
||||
playback/speed = 1.0
|
||||
blend_times = [ ]
|
||||
autoplay = ""
|
||||
|
||||
[connection signal="body_enter" from="." to="." method="_on_bullet_body_enter"]
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||
|
||||
|
||||
10
2d/platformer_kcc/coin.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
extends Area2D
|
||||
|
||||
var taken=false
|
||||
|
||||
func _on_coin_body_enter( body ):
|
||||
|
||||
if (not taken and body extends preload("res://player.gd")):
|
||||
get_node("anim").play("taken")
|
||||
taken=true
|
||||
|
||||
BIN
2d/platformer_kcc/coin.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
154
2d/platformer_kcc/coin.tscn
Normal file
@@ -0,0 +1,154 @@
|
||||
[gd_scene load_steps=10 format=1]
|
||||
|
||||
[ext_resource path="res://coin.gd" type="Script" id=1]
|
||||
[ext_resource path="res://coin.png" type="Texture" id=2]
|
||||
[ext_resource path="res://sound_coin.wav" type="Sample" id=3]
|
||||
[ext_resource path="res://bullet.png" type="Texture" id=4]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
radius = 10.0
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
|
||||
resource/name = "spin"
|
||||
length = 1.5
|
||||
loop = true
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = { "times":FloatArray( 0, 0.25, 0.5, 0.75, 1, 1.25, 1.5 ), "transitions":FloatArray( 1, 1, 1, 1, 1, 1, 1 ), "update":1, "values":[ 0, 1, 2, 3, 2, 1, 0 ] }
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
|
||||
length = 8.0
|
||||
loop = false
|
||||
step = 0.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = { "times":FloatArray( 0 ), "transitions":FloatArray( 1 ), "update":0, "values":[ 0 ] }
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("sound:play/play")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/imported = false
|
||||
tracks/1/keys = { "times":FloatArray( 0 ), "transitions":FloatArray( 1 ), "update":1, "values":[ "coin" ] }
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("particles:visibility/self_opacity")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/imported = false
|
||||
tracks/2/keys = { "times":FloatArray( 0, 1.66 ), "transitions":FloatArray( 1, 1 ), "update":0, "values":[ 1.0, 0.0 ] }
|
||||
tracks/3/type = "value"
|
||||
tracks/3/path = NodePath("sprite:visibility/self_opacity")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/imported = false
|
||||
tracks/3/keys = { "times":FloatArray( 0, 0.4 ), "transitions":FloatArray( 1, 1 ), "update":0, "values":[ 1.0, 0.0 ] }
|
||||
tracks/4/type = "value"
|
||||
tracks/4/path = NodePath("particles:config/emitting")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/imported = false
|
||||
tracks/4/keys = { "times":FloatArray( 0 ), "transitions":FloatArray( 1 ), "update":1, "values":[ true ] }
|
||||
tracks/5/type = "method"
|
||||
tracks/5/path = NodePath(".")
|
||||
tracks/5/interp = 1
|
||||
tracks/5/imported = false
|
||||
tracks/5/keys = { "times":FloatArray( 2.7 ), "transitions":FloatArray( 1 ), "values":[ { "args":[ ], "method":"queue_free" } ] }
|
||||
|
||||
[sub_resource type="SampleLibrary" id=4]
|
||||
|
||||
samples/coin = { "db":0.0, "pitch":1.0, "sample":ExtResource( 3 ) }
|
||||
|
||||
[sub_resource type="ColorRamp" id=5]
|
||||
|
||||
offsets = FloatArray( 0, 1 )
|
||||
colors = ColorArray( 1, 1, 1, 1, 0, 0, 0, 1 )
|
||||
|
||||
[node name="coin" type="Area2D"]
|
||||
|
||||
input/pickable = true
|
||||
shapes/0/shape = SubResource( 1 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
gravity_vec = Vector2( 0, 1 )
|
||||
gravity = 98.0
|
||||
linear_damp = 0.1
|
||||
angular_damp = 1.0
|
||||
script/script = ExtResource( 1 )
|
||||
|
||||
[node name="sprite" type="Sprite" parent="."]
|
||||
|
||||
texture = ExtResource( 2 )
|
||||
hframes = 4
|
||||
|
||||
[node name="anim" type="AnimationPlayer" parent="."]
|
||||
|
||||
playback/process_mode = 1
|
||||
playback/default_blend_time = 0.0
|
||||
root/root = NodePath("..")
|
||||
anims/spin = SubResource( 2 )
|
||||
anims/taken = SubResource( 3 )
|
||||
playback/active = true
|
||||
playback/speed = 3.0
|
||||
blend_times = [ ]
|
||||
autoplay = "spin"
|
||||
|
||||
[node name="collision" type="CollisionShape2D" parent="."]
|
||||
|
||||
shape = SubResource( 1 )
|
||||
trigger = false
|
||||
_update_shape_index = -1
|
||||
|
||||
[node name="sound" type="SamplePlayer2D" parent="."]
|
||||
|
||||
params/volume_db = 0.0
|
||||
params/pitch_scale = 1.0
|
||||
params/attenuation/min_distance = 1.0
|
||||
params/attenuation/max_distance = 2048.0
|
||||
params/attenuation/distance_exp = 1.0
|
||||
config/polyphony = 1
|
||||
config/samples = SubResource( 4 )
|
||||
config/pitch_random = 0.0
|
||||
|
||||
[node name="particles" type="Particles2D" parent="."]
|
||||
|
||||
visibility/blend_mode = 1
|
||||
config/amount = 8
|
||||
config/lifetime = 0.4
|
||||
config/emitting = false
|
||||
config/half_extents = Vector2( 5, 5 )
|
||||
config/texture = ExtResource( 4 )
|
||||
params/direction = 0.0
|
||||
params/spread = 10.0
|
||||
params/linear_velocity = 0.0
|
||||
params/spin_velocity = 0.0
|
||||
params/orbit_velocity = 0.0
|
||||
params/gravity_direction = 0.0
|
||||
params/gravity_strength = 0.0
|
||||
params/radial_accel = 0.0
|
||||
params/tangential_accel = 0.0
|
||||
params/damping = 0.0
|
||||
params/initial_angle = 0.0
|
||||
params/initial_size = 0.2
|
||||
params/final_size = 0.2
|
||||
params/hue_variation = 0.0
|
||||
params/anim_speed_scale = 1.0
|
||||
params/anim_initial_pos = 0.0
|
||||
color/color_ramp = SubResource( 5 )
|
||||
|
||||
[node name="enabler" type="VisibilityEnabler2D" parent="."]
|
||||
|
||||
rect = Rect2( -10, -10, 20, 20 )
|
||||
enabler/pause_animations = true
|
||||
enabler/freeze_bodies = true
|
||||
enabler/pause_particles = true
|
||||
enabler/pause_animated_sprites = true
|
||||
enabler/process_parent = false
|
||||
enabler/fixed_process_parent = false
|
||||
|
||||
[connection signal="body_enter" from="." to="." method="_on_coin_body_enter"]
|
||||
|
||||
|
||||
57
2d/platformer_kcc/enemy.gd
Normal file
@@ -0,0 +1,57 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
|
||||
const GRAVITY_VEC = Vector2(0,900)
|
||||
const FLOOR_NORMAL = Vector2(1,-1)
|
||||
|
||||
const WALK_SPEED = 70
|
||||
const STATE_WALKING = 0
|
||||
const STATE_KILLED = 1
|
||||
|
||||
var linear_velocity = Vector2()
|
||||
var direction = -1
|
||||
var anim=""
|
||||
|
||||
var state = STATE_WALKING
|
||||
|
||||
onready var detect_floor_left = get_node("detect_floor_left")
|
||||
onready var detect_wall_left = get_node("detect_wall_left")
|
||||
onready var detect_floor_right = get_node("detect_floor_right")
|
||||
onready var detect_wall_right = get_node("detect_wall_right")
|
||||
onready var sprite = get_node("sprite")
|
||||
|
||||
func _fixed_process(delta):
|
||||
|
||||
var new_anim="idle"
|
||||
|
||||
if (state==STATE_WALKING):
|
||||
|
||||
linear_velocity+= GRAVITY_VEC*delta
|
||||
linear_velocity.x = direction * WALK_SPEED
|
||||
linear_velocity = move_and_slide( linear_velocity, FLOOR_NORMAL )
|
||||
|
||||
if (not detect_floor_left.is_colliding() or detect_wall_left.is_colliding()):
|
||||
direction=1.0
|
||||
|
||||
if (not detect_floor_right.is_colliding() or detect_wall_right.is_colliding()):
|
||||
direction=-1.0
|
||||
|
||||
sprite.set_scale( Vector2(direction,1.0) )
|
||||
|
||||
new_anim="walk"
|
||||
else:
|
||||
new_anim="explode"
|
||||
|
||||
if (anim!=new_anim):
|
||||
anim=new_anim
|
||||
get_node("anim").play(anim)
|
||||
|
||||
|
||||
|
||||
func hit_by_bullet():
|
||||
state=STATE_KILLED
|
||||
|
||||
func _ready():
|
||||
set_fixed_process(true)
|
||||
|
||||
|
||||
BIN
2d/platformer_kcc/enemy.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
263
2d/platformer_kcc/enemy.tscn
Normal file
@@ -0,0 +1,263 @@
|
||||
[gd_scene load_steps=12 format=1]
|
||||
|
||||
[ext_resource path="res://enemy.gd" type="Script" id=1]
|
||||
[ext_resource path="res://enemy.png" type="Texture" id=2]
|
||||
[ext_resource path="res://bullet.png" type="Texture" id=3]
|
||||
[ext_resource path="res://sound_explode.wav" type="Sample" id=4]
|
||||
[ext_resource path="res://sound_hit.wav" type="Sample" id=5]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
radius = 13.4556
|
||||
height = 14.2002
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
|
||||
resource/name = "explode"
|
||||
length = 2.0
|
||||
loop = false
|
||||
step = 0.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:visibility/self_opacity")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = {
|
||||
"times": FloatArray( 0.99422, 1.12851 ),
|
||||
"transitions": FloatArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ 1.0, 0.0 ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("sprite:frame")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/imported = false
|
||||
tracks/1/keys = {
|
||||
"times": FloatArray( 0 ),
|
||||
"transitions": FloatArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ 4 ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("Particles2D:config/emitting")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/imported = false
|
||||
tracks/2/keys = {
|
||||
"times": FloatArray( 1.19394 ),
|
||||
"transitions": FloatArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ true ]
|
||||
}
|
||||
tracks/3/type = "method"
|
||||
tracks/3/path = NodePath(".")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/imported = false
|
||||
tracks/3/keys = {
|
||||
"times": FloatArray( 2.01305 ),
|
||||
"transitions": FloatArray( 1 ),
|
||||
"values": [ {
|
||||
"args": [ ],
|
||||
"method": "queue_free"
|
||||
} ]
|
||||
}
|
||||
tracks/4/type = "value"
|
||||
tracks/4/path = NodePath("sprite:transform/rot")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/imported = false
|
||||
tracks/4/keys = {
|
||||
"times": FloatArray( 0, 0.99 ),
|
||||
"transitions": FloatArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ 0.0, 360.0 ]
|
||||
}
|
||||
tracks/5/type = "value"
|
||||
tracks/5/path = NodePath("sound:play/play")
|
||||
tracks/5/interp = 1
|
||||
tracks/5/imported = false
|
||||
tracks/5/keys = {
|
||||
"times": FloatArray( 1.2 ),
|
||||
"transitions": FloatArray( 1 ),
|
||||
"update": 2,
|
||||
"values": [ "explode" ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
|
||||
length = 6.75
|
||||
loop = true
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = {
|
||||
"times": FloatArray( 0, 0.75, 1.5, 2.25, 3, 3.75, 4.5, 5.25, 6, 6.75 ),
|
||||
"transitions": FloatArray( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 5, 6, 5, 6, 5, 6, 7, 6, 7, 5 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
|
||||
resource/name = "walk"
|
||||
length = 1.25
|
||||
loop = true
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = {
|
||||
"times": FloatArray( 0, 0.25, 0.5, 0.75, 1, 1.25 ),
|
||||
"transitions": FloatArray( 1, 1, 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 0, 1, 2, 3, 4, 0 ]
|
||||
}
|
||||
|
||||
[sub_resource type="ColorRamp" id=5]
|
||||
|
||||
offsets = FloatArray( 0, 1 )
|
||||
colors = ColorArray( 1, 0.884956, 0.823009, 1, 0.768627, 0.389381, 0, 0 )
|
||||
|
||||
[sub_resource type="SampleLibrary" id=6]
|
||||
|
||||
samples/explode = {
|
||||
"db": 0.0,
|
||||
"pitch": 1.0,
|
||||
"priority": 0,
|
||||
"sample": ExtResource( 4 )
|
||||
}
|
||||
samples/hit = {
|
||||
"db": 0.0,
|
||||
"pitch": 1.0,
|
||||
"priority": 0,
|
||||
"sample": ExtResource( 5 )
|
||||
}
|
||||
|
||||
[node name="enemy" type="KinematicBody2D"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 1 )
|
||||
shapes/0/transform = Matrix32( -4.37114e-08, -1, 1, -4.37114e-08, -0.00525069, -0.727495 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
collision/margin = 0.08
|
||||
script/script = ExtResource( 1 )
|
||||
|
||||
[node name="enabler" type="VisibilityEnabler2D" parent="."]
|
||||
|
||||
transform/pos = Vector2( 16.2569, 11.0034 )
|
||||
transform/scale = Vector2( 23.5056, 10.8629 )
|
||||
rect = Rect2( -10, -10, 20, 20 )
|
||||
enabler/pause_animations = true
|
||||
enabler/freeze_bodies = true
|
||||
enabler/pause_particles = true
|
||||
enabler/pause_animated_sprites = true
|
||||
enabler/process_parent = false
|
||||
enabler/fixed_process_parent = false
|
||||
|
||||
[node name="anim" type="AnimationPlayer" parent="."]
|
||||
|
||||
playback/process_mode = 1
|
||||
playback/default_blend_time = 0.0
|
||||
root/root = NodePath("..")
|
||||
anims/explode = SubResource( 2 )
|
||||
anims/idle = SubResource( 3 )
|
||||
anims/walk = SubResource( 4 )
|
||||
playback/active = true
|
||||
playback/speed = 3.0
|
||||
blend_times = [ ]
|
||||
autoplay = ""
|
||||
|
||||
[node name="sprite" type="Sprite" parent="."]
|
||||
|
||||
texture = ExtResource( 2 )
|
||||
flip_h = true
|
||||
hframes = 8
|
||||
frame = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
|
||||
transform/pos = Vector2( -0.00525069, -0.727495 )
|
||||
transform/rot = 90.0
|
||||
shape = SubResource( 1 )
|
||||
trigger = false
|
||||
_update_shape_index = 0
|
||||
|
||||
[node name="detect_floor_left" type="RayCast2D" parent="."]
|
||||
|
||||
transform/pos = Vector2( -33.2868, -9.34363 )
|
||||
enabled = true
|
||||
cast_to = Vector2( 0, 45 )
|
||||
layer_mask = 1
|
||||
type_mask = 15
|
||||
|
||||
[node name="detect_wall_left" type="RayCast2D" parent="."]
|
||||
|
||||
transform/pos = Vector2( -22.1361, -0.739978 )
|
||||
transform/rot = -90.0
|
||||
enabled = true
|
||||
cast_to = Vector2( 0, 10 )
|
||||
layer_mask = 1
|
||||
type_mask = 3
|
||||
|
||||
[node name="detect_wall_right" type="RayCast2D" parent="."]
|
||||
|
||||
transform/pos = Vector2( 21.2788, -0.381489 )
|
||||
transform/rot = 90.0
|
||||
enabled = true
|
||||
cast_to = Vector2( 0, 10 )
|
||||
layer_mask = 1
|
||||
type_mask = 15
|
||||
|
||||
[node name="detect_floor_right" type="RayCast2D" parent="."]
|
||||
|
||||
transform/pos = Vector2( 29.1987, -9.34363 )
|
||||
enabled = true
|
||||
cast_to = Vector2( 0, 45 )
|
||||
layer_mask = 1
|
||||
type_mask = 15
|
||||
|
||||
[node name="Particles2D" type="Particles2D" parent="."]
|
||||
|
||||
visibility/self_opacity = 0.121212
|
||||
visibility/blend_mode = 1
|
||||
config/amount = 32
|
||||
config/lifetime = 0.5
|
||||
config/emit_timeout = 0.5
|
||||
config/emitting = false
|
||||
config/process_mode = 1
|
||||
config/explosiveness = 0.1
|
||||
config/texture = ExtResource( 3 )
|
||||
params/direction = 0.0
|
||||
params/spread = 180.0
|
||||
params/linear_velocity = 90.0
|
||||
params/spin_velocity = 2.0
|
||||
params/orbit_velocity = 0.0
|
||||
params/gravity_direction = 0.0
|
||||
params/gravity_strength = 9.8
|
||||
params/radial_accel = 0.0
|
||||
params/tangential_accel = 0.0
|
||||
params/damping = 0.0
|
||||
params/initial_angle = 0.0
|
||||
params/initial_size = 2.0
|
||||
params/final_size = 3.0
|
||||
params/hue_variation = 0.0
|
||||
params/anim_speed_scale = 1.0
|
||||
params/anim_initial_pos = 0.0
|
||||
randomness/spin_velocity = 1.0
|
||||
color/color_ramp = SubResource( 5 )
|
||||
|
||||
[node name="sound" type="SamplePlayer2D" parent="."]
|
||||
|
||||
params/volume_db = 0.0
|
||||
params/pitch_scale = 1.0
|
||||
params/attenuation/min_distance = 1.0
|
||||
params/attenuation/max_distance = 2048.0
|
||||
params/attenuation/distance_exp = 1.0
|
||||
config/polyphony = 3
|
||||
config/samples = SubResource( 6 )
|
||||
config/pitch_random = 0.0
|
||||
|
||||
|
||||
42
2d/platformer_kcc/engine.cfg
Normal file
@@ -0,0 +1,42 @@
|
||||
[application]
|
||||
|
||||
name="Platformer (Kinematic character controller)"
|
||||
main_scene="res://stage.tscn"
|
||||
icon="res://icon.png"
|
||||
name_es="Plataformero"
|
||||
target_fps="60"
|
||||
|
||||
[display]
|
||||
|
||||
width=800
|
||||
height=480
|
||||
stretch_mode="2d"
|
||||
stretch_aspect="keep_height"
|
||||
|
||||
[image_loader]
|
||||
|
||||
repeat=false
|
||||
|
||||
[input]
|
||||
|
||||
move_left=[key(Left), jbutton(0, 14)]
|
||||
move_right=[key(Right), jbutton(0, 15)]
|
||||
jump=[key(Up), jbutton(0, 0)]
|
||||
shoot=[key(Space), jbutton(0, 2)]
|
||||
spawn=[key(F1), jbutton(0, 11)]
|
||||
|
||||
[physics_2d]
|
||||
|
||||
default_gravity=700
|
||||
|
||||
[rasterizer]
|
||||
|
||||
use_pixel_snap=true
|
||||
|
||||
[render]
|
||||
|
||||
mipmap_policy=1
|
||||
|
||||
[texture_import]
|
||||
|
||||
filter=false
|
||||
BIN
2d/platformer_kcc/icon.png
Normal file
|
After Width: | Height: | Size: 1002 B |
19
2d/platformer_kcc/moving_platform.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
extends Node2D
|
||||
|
||||
# Member variables
|
||||
export var motion = Vector2()
|
||||
export var cycle = 1.0
|
||||
var accum = 0.0
|
||||
|
||||
|
||||
func _fixed_process(delta):
|
||||
accum += delta*(1.0/cycle)*PI*2.0
|
||||
accum = fmod(accum, PI*2.0)
|
||||
var d = sin(accum)
|
||||
var xf = Matrix32()
|
||||
xf[2]= motion*d
|
||||
get_node("platform").set_transform(xf)
|
||||
|
||||
|
||||
func _ready():
|
||||
set_fixed_process(true)
|
||||
BIN
2d/platformer_kcc/moving_platform.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
52
2d/platformer_kcc/moving_platform.tscn
Normal file
@@ -0,0 +1,52 @@
|
||||
[gd_scene load_steps=4 format=1]
|
||||
|
||||
[ext_resource path="res://moving_platform.gd" type="Script" id=1]
|
||||
[ext_resource path="res://moving_platform.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=1]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -88, 24, -88, -24, 88, -24, 88, 24 )
|
||||
|
||||
[node name="moving_platform" type="Node2D"]
|
||||
|
||||
script/script = ExtResource( 1 )
|
||||
motion = Vector2( 0, 0 )
|
||||
cycle = 1.0
|
||||
|
||||
[node name="platform" type="RigidBody2D" parent="."]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 1 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
mode = 3
|
||||
mass = 1.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
gravity_scale = 1.0
|
||||
custom_integrator = false
|
||||
continuous_cd = 0
|
||||
contacts_reported = 0
|
||||
contact_monitor = false
|
||||
sleeping = false
|
||||
can_sleep = true
|
||||
velocity/linear = Vector2( 0, 0 )
|
||||
velocity/angular = 0.0
|
||||
damp_override/linear = -1.0
|
||||
damp_override/angular = -1.0
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="platform"]
|
||||
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="platform"]
|
||||
|
||||
build_mode = 0
|
||||
polygon = Vector2Array( -88, -24, 88, -24, 88, 24, -88, 24 )
|
||||
shape_range = Vector2( -1, -1 )
|
||||
trigger = false
|
||||
|
||||
|
||||
BIN
2d/platformer_kcc/music.ogg
Normal file
BIN
2d/platformer_kcc/one_way_platform.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
36
2d/platformer_kcc/one_way_platform.tscn
Normal file
@@ -0,0 +1,36 @@
|
||||
[gd_scene load_steps=3 format=1]
|
||||
|
||||
[ext_resource path="res://one_way_platform.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
extents = Vector2( 100, 10 )
|
||||
|
||||
[node name="one_way_platform" type="StaticBody2D"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 1 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 1.46304, -13.1672 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
one_way_collision/direction = Vector2( 0, 1 )
|
||||
one_way_collision/max_depth = 20.0
|
||||
constant_linear_velocity = Vector2( 0, 0 )
|
||||
constant_angular_velocity = 0.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
|
||||
[node name="sprite" type="Sprite" parent="."]
|
||||
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
|
||||
transform/pos = Vector2( 1.46304, -13.1672 )
|
||||
shape = SubResource( 1 )
|
||||
trigger = false
|
||||
_update_shape_index = -1
|
||||
|
||||
|
||||
BIN
2d/platformer_kcc/osb_fire.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
2d/platformer_kcc/osb_jump.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
2d/platformer_kcc/osb_left.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
2d/platformer_kcc/osb_right.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
101
2d/platformer_kcc/parallax_bg.tscn
Normal file
@@ -0,0 +1,101 @@
|
||||
[gd_scene load_steps=7 format=1]
|
||||
|
||||
[ext_resource path="res://scroll_bg_sky.png" type="Texture" id=1]
|
||||
[ext_resource path="res://scroll_bg_cloud_1.png" type="Texture" id=2]
|
||||
[ext_resource path="res://scroll_bg_cloud_2.png" type="Texture" id=3]
|
||||
[ext_resource path="res://scroll_bg_cloud_3.png" type="Texture" id=4]
|
||||
[ext_resource path="res://scroll_bg_fg_2.png" type="Texture" id=5]
|
||||
[ext_resource path="res://scroll_bg_fg_1.png" type="Texture" id=6]
|
||||
|
||||
[node name="parallax_bg" type="ParallaxBackground"]
|
||||
|
||||
layer = -1
|
||||
offset = Vector2( 0, 0 )
|
||||
rotation = 0.0
|
||||
scale = Vector2( 1, 1 )
|
||||
scroll/offset = Vector2( 0, 0 )
|
||||
scroll/base_offset = Vector2( 0, 0 )
|
||||
scroll/base_scale = Vector2( 0.7, 0 )
|
||||
scroll/limit_begin = Vector2( 0, 0 )
|
||||
scroll/limit_end = Vector2( 0, 0 )
|
||||
scroll/ignore_camera_zoom = false
|
||||
|
||||
[node name="sky" type="ParallaxLayer" parent="."]
|
||||
|
||||
motion/scale = Vector2( 1, 1 )
|
||||
motion/mirroring = Vector2( 800, 0 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="sky"]
|
||||
|
||||
transform/scale = Vector2( 32, 0.94 )
|
||||
texture = ExtResource( 1 )
|
||||
centered = false
|
||||
|
||||
[node name="clouds" type="ParallaxLayer" parent="."]
|
||||
|
||||
motion/scale = Vector2( 0.1, 1 )
|
||||
motion/mirroring = Vector2( 800, 0 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="clouds"]
|
||||
|
||||
transform/pos = Vector2( 28, 127 )
|
||||
texture = ExtResource( 2 )
|
||||
centered = false
|
||||
|
||||
[node name="Sprite 2" type="Sprite" parent="clouds"]
|
||||
|
||||
transform/pos = Vector2( 404, 24 )
|
||||
texture = ExtResource( 2 )
|
||||
centered = false
|
||||
|
||||
[node name="Sprite 3" type="Sprite" parent="clouds"]
|
||||
|
||||
transform/pos = Vector2( 154, 46 )
|
||||
texture = ExtResource( 3 )
|
||||
centered = false
|
||||
|
||||
[node name="Sprite 4" type="Sprite" parent="clouds"]
|
||||
|
||||
transform/pos = Vector2( 525, 130 )
|
||||
texture = ExtResource( 3 )
|
||||
centered = false
|
||||
|
||||
[node name="Sprite 5" type="Sprite" parent="clouds"]
|
||||
|
||||
transform/pos = Vector2( 255, 158 )
|
||||
texture = ExtResource( 4 )
|
||||
centered = false
|
||||
|
||||
[node name="Sprite 6" type="Sprite" parent="clouds"]
|
||||
|
||||
transform/pos = Vector2( 674, 70 )
|
||||
texture = ExtResource( 4 )
|
||||
centered = false
|
||||
|
||||
[node name="mount_ 2" type="ParallaxLayer" parent="."]
|
||||
|
||||
motion/scale = Vector2( 0.2, 1 )
|
||||
motion/mirroring = Vector2( 800, 0 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="mount_ 2"]
|
||||
|
||||
transform/pos = Vector2( 0, 225 )
|
||||
texture = ExtResource( 5 )
|
||||
centered = false
|
||||
region = true
|
||||
region_rect = Rect2( 0, 0, 800, 256 )
|
||||
|
||||
[node name="mount_1" type="ParallaxLayer" parent="."]
|
||||
|
||||
motion/scale = Vector2( 0.4, 1 )
|
||||
motion/mirroring = Vector2( 800, 0 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="mount_1"]
|
||||
|
||||
transform/pos = Vector2( 0, 225 )
|
||||
texture = ExtResource( 6 )
|
||||
centered = false
|
||||
region = true
|
||||
region_rect = Rect2( 0, 0, 800, 256 )
|
||||
|
||||
|
||||
113
2d/platformer_kcc/player.gd
Normal file
@@ -0,0 +1,113 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
const GRAVITY_VEC = Vector2(0,900)
|
||||
const FLOOR_NORMAL = Vector2(0,-1)
|
||||
const SLOPE_SLIDE_STOP = 25.0
|
||||
const MIN_ONAIR_TIME = 0.01
|
||||
const WALK_SPEED = 250 # pixels/sec
|
||||
const JUMP_SPEED = 480
|
||||
const SIDING_CHANGE_SPEED = 10
|
||||
const BULLET_VELOCITY = 1000
|
||||
const SHOOT_TIME_SHOW_WEAPON = 0.2
|
||||
|
||||
var linear_vel = Vector2()
|
||||
var onair_time = 0 #
|
||||
var on_floor = false
|
||||
var shoot_time=99999 #time since last shot
|
||||
var shooting = false
|
||||
|
||||
var anim=""
|
||||
|
||||
#cache the sprite here for fast access (we will set scale to flip it often)
|
||||
onready var sprite = get_node("sprite")
|
||||
|
||||
func _fixed_process(delta):
|
||||
|
||||
#increment counters
|
||||
|
||||
onair_time+=delta
|
||||
shoot_time+=delta
|
||||
|
||||
|
||||
### MOVEMENT ###
|
||||
|
||||
# Apply Gravity
|
||||
linear_vel += delta * GRAVITY_VEC
|
||||
# Move and Slide
|
||||
linear_vel = move_and_slide( linear_vel, FLOOR_NORMAL, SLOPE_SLIDE_STOP )
|
||||
# Detect Floor
|
||||
if (is_move_and_slide_on_floor()):
|
||||
onair_time=0
|
||||
|
||||
on_floor = onair_time < MIN_ONAIR_TIME
|
||||
|
||||
### CONTROL ###
|
||||
|
||||
# Horizontal Movement
|
||||
var target_speed = 0
|
||||
if (Input.is_action_pressed("move_left")):
|
||||
target_speed += -1
|
||||
if (Input.is_action_pressed("move_right")):
|
||||
target_speed += 1
|
||||
|
||||
target_speed *= WALK_SPEED
|
||||
linear_vel.x = lerp( linear_vel.x, target_speed, 0.1 )
|
||||
|
||||
# Jumping
|
||||
if (on_floor and Input.is_action_pressed("jump")):
|
||||
linear_vel.y=-JUMP_SPEED
|
||||
get_node("sound").play("jump")
|
||||
|
||||
# Shooting
|
||||
|
||||
var shoot = Input.is_action_pressed("shoot")
|
||||
|
||||
if (shoot and not shooting):
|
||||
|
||||
var bullet = preload("res://bullet.tscn").instance()
|
||||
bullet.set_pos( get_node("sprite/bullet_shoot").get_global_pos() ) #use node for shoot position
|
||||
bullet.set_linear_velocity( Vector2( sprite.get_scale().x * BULLET_VELOCITY,0 ) )
|
||||
bullet.add_collision_exception_with(self) # don't want player to collide with bullet
|
||||
get_parent().add_child( bullet ) #don't want bullet to move with me, so add it as child of parent
|
||||
get_node("sound").play("shoot")
|
||||
shoot_time=0
|
||||
|
||||
### ANIMATION ###
|
||||
|
||||
var new_anim="idle"
|
||||
|
||||
if (on_floor):
|
||||
if (linear_vel.x < -SIDING_CHANGE_SPEED):
|
||||
sprite.set_scale( Vector2( -1, 1 ) )
|
||||
new_anim="run"
|
||||
|
||||
if (linear_vel.x > SIDING_CHANGE_SPEED):
|
||||
sprite.set_scale( Vector2( 1, 1 ) )
|
||||
new_anim="run"
|
||||
|
||||
else:
|
||||
# We want the character to immediately change facing side when the player
|
||||
# tries to change direction, during air control.
|
||||
# This allows for example the player to shoot quickly left then right.
|
||||
if (Input.is_action_pressed("move_left") and not Input.is_action_pressed("move_right")):
|
||||
sprite.set_scale( Vector2( -1, 1 ) )
|
||||
if (Input.is_action_pressed("move_right") and not Input.is_action_pressed("move_left")):
|
||||
sprite.set_scale( Vector2( 1, 1 ) )
|
||||
|
||||
if (linear_vel.y < 0 ):
|
||||
new_anim="jumping"
|
||||
else:
|
||||
new_anim="falling"
|
||||
|
||||
if (shoot_time < SHOOT_TIME_SHOW_WEAPON):
|
||||
new_anim+="_weapon"
|
||||
|
||||
if (new_anim!=anim):
|
||||
anim=new_anim
|
||||
get_node("anim").play(anim)
|
||||
|
||||
shooting = shoot
|
||||
|
||||
func _ready():
|
||||
set_fixed_process(true)
|
||||
|
||||
313
2d/platformer_kcc/player.tscn
Normal file
@@ -0,0 +1,313 @@
|
||||
[gd_scene load_steps=24 format=1]
|
||||
|
||||
[ext_resource path="res://player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://robot_demo.png" type="Texture" id=2]
|
||||
[ext_resource path="res://bullet.png" type="Texture" id=3]
|
||||
[ext_resource path="res://sound_coin.wav" type="Sample" id=4]
|
||||
[ext_resource path="res://sound_jump.wav" type="Sample" id=5]
|
||||
[ext_resource path="res://sound_shoot.wav" type="Sample" id=6]
|
||||
[ext_resource path="res://osb_left.png" type="Texture" id=7]
|
||||
[ext_resource path="res://osb_right.png" type="Texture" id=8]
|
||||
[ext_resource path="res://osb_jump.png" type="Texture" id=9]
|
||||
[ext_resource path="res://osb_fire.png" type="Texture" id=10]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
radius = 10.0
|
||||
height = 44.4787
|
||||
|
||||
[sub_resource type="ColorRamp" id=2]
|
||||
|
||||
offsets = FloatArray( 0, 1 )
|
||||
colors = ColorArray( 1, 1, 1, 1, 0, 0, 0, 0.0442478 )
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
|
||||
resource/name = "crouch"
|
||||
length = 0.01
|
||||
loop = true
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = { "times":FloatArray( 0 ), "transitions":FloatArray( 1 ), "update":1, "values":[ 22 ] }
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
|
||||
resource/name = "falling"
|
||||
length = 0.01
|
||||
loop = true
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = { "times":FloatArray( 0 ), "transitions":FloatArray( 1 ), "update":1, "values":[ 21 ] }
|
||||
|
||||
[sub_resource type="Animation" id=5]
|
||||
|
||||
resource/name = "falling_weapon"
|
||||
length = 0.5
|
||||
loop = true
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = { "times":FloatArray( 0 ), "transitions":FloatArray( 1 ), "update":1, "values":[ 26 ] }
|
||||
|
||||
[sub_resource type="Animation" id=6]
|
||||
|
||||
length = 7.0
|
||||
loop = true
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = { "times":FloatArray( 0, 1.25, 1.5, 2, 4.5, 4.75, 5, 5.25 ), "transitions":FloatArray( 1, 1, 1, 1, 1, 1, 1, 1 ), "update":1, "values":[ 16, 17, 18, 16, 19, 20, 19, 16 ] }
|
||||
|
||||
[sub_resource type="Animation" id=7]
|
||||
|
||||
length = 0.5
|
||||
loop = true
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = { "times":FloatArray( 0 ), "transitions":FloatArray( 1 ), "update":1, "values":[ 25 ] }
|
||||
|
||||
[sub_resource type="Animation" id=8]
|
||||
|
||||
length = 0.5
|
||||
loop = true
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = { "times":FloatArray( 0, 0.25, 0.5 ), "transitions":FloatArray( 1, 1, 1 ), "update":1, "values":[ 23, 24, 23 ] }
|
||||
|
||||
[sub_resource type="Animation" id=9]
|
||||
|
||||
length = 0.5
|
||||
loop = true
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = { "times":FloatArray( 0 ), "transitions":FloatArray( 1 ), "update":1, "values":[ 26 ] }
|
||||
|
||||
[sub_resource type="Animation" id=10]
|
||||
|
||||
length = 1.25
|
||||
loop = true
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = { "times":FloatArray( 0, 0.25, 0.5, 0.75, 1, 1.25 ), "transitions":FloatArray( 1, 1, 1, 1, 1, 1 ), "update":1, "values":[ 0, 1, 2, 3, 4, 0 ] }
|
||||
|
||||
[sub_resource type="Animation" id=11]
|
||||
|
||||
length = 1.25
|
||||
loop = true
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = { "times":FloatArray( 0, 0.25, 0.5, 0.75, 1, 1.25 ), "transitions":FloatArray( 1, 1, 1, 1, 1, 1 ), "update":1, "values":[ 5, 6, 7, 8, 9, 5 ] }
|
||||
|
||||
[sub_resource type="Animation" id=12]
|
||||
|
||||
length = 1.25
|
||||
loop = true
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = { "times":FloatArray( 0, 0.25, 0.5, 0.75, 1, 1.25 ), "transitions":FloatArray( 1, 1, 1, 1, 1, 1 ), "update":1, "values":[ 10, 11, 12, 13, 14, 5 ] }
|
||||
|
||||
[sub_resource type="SampleLibrary" id=13]
|
||||
|
||||
samples/coin = { "db":0.0, "pitch":1.0, "sample":ExtResource( 4 ) }
|
||||
samples/jump = { "db":0.0, "pitch":1.0, "sample":ExtResource( 5 ) }
|
||||
samples/shoot = { "db":0.0, "pitch":1.0, "sample":ExtResource( 6 ) }
|
||||
|
||||
[node name="player" type="KinematicBody2D"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 1 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0.291992, -0.835023 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
collision/margin = 0.08
|
||||
script/script = ExtResource( 1 )
|
||||
|
||||
[node name="sprite" type="Sprite" parent="."]
|
||||
|
||||
texture = ExtResource( 2 )
|
||||
vframes = 2
|
||||
hframes = 16
|
||||
frame = 22
|
||||
|
||||
[node name="smoke" type="Particles2D" parent="sprite"]
|
||||
|
||||
visibility/self_opacity = 0.363636
|
||||
visibility/blend_mode = 1
|
||||
transform/pos = Vector2( 20.7312, 3.21187 )
|
||||
transform/rot = 83.4504
|
||||
config/amount = 4
|
||||
config/lifetime = 0.3
|
||||
config/emit_timeout = 0.3
|
||||
config/emitting = false
|
||||
config/local_space = false
|
||||
config/explosiveness = 0.1
|
||||
config/texture = ExtResource( 3 )
|
||||
params/direction = 0.0
|
||||
params/spread = 180.0
|
||||
params/linear_velocity = 20.0
|
||||
params/spin_velocity = 1.0
|
||||
params/orbit_velocity = 0.0
|
||||
params/gravity_direction = 0.0
|
||||
params/gravity_strength = 9.8
|
||||
params/radial_accel = 0.0
|
||||
params/tangential_accel = 0.0
|
||||
params/damping = 0.0
|
||||
params/initial_angle = 0.0
|
||||
params/initial_size = 2.0
|
||||
params/final_size = 2.0
|
||||
params/hue_variation = 0.0
|
||||
params/anim_speed_scale = 1.0
|
||||
params/anim_initial_pos = 0.0
|
||||
randomness/spin_velocity = 2.0
|
||||
color/color_ramp = SubResource( 2 )
|
||||
|
||||
[node name="bullet_shoot" type="Position2D" parent="sprite"]
|
||||
|
||||
transform/pos = Vector2( 30.6589, 6.13176 )
|
||||
|
||||
[node name="anim" type="AnimationPlayer" parent="."]
|
||||
|
||||
playback/process_mode = 1
|
||||
playback/default_blend_time = 0.0
|
||||
root/root = NodePath("..")
|
||||
anims/crouch = SubResource( 3 )
|
||||
anims/falling = SubResource( 4 )
|
||||
anims/falling_weapon = SubResource( 5 )
|
||||
anims/idle = SubResource( 6 )
|
||||
anims/idle_weapon = SubResource( 7 )
|
||||
anims/jumping = SubResource( 8 )
|
||||
anims/jumping_weapon = SubResource( 9 )
|
||||
anims/run = SubResource( 10 )
|
||||
anims/run_weapon = SubResource( 11 )
|
||||
anims/standing_weapon_ready = SubResource( 12 )
|
||||
playback/active = true
|
||||
playback/speed = 2.0
|
||||
blend_times = [ ]
|
||||
autoplay = ""
|
||||
|
||||
[node name="camera" type="Camera2D" parent="."]
|
||||
|
||||
anchor_mode = 1
|
||||
rotating = false
|
||||
current = true
|
||||
zoom = Vector2( 1, 1 )
|
||||
limit/left = 0
|
||||
limit/top = 0
|
||||
limit/right = 10000000
|
||||
limit/bottom = 10000000
|
||||
limit/smoothed = false
|
||||
drag_margin/h_enabled = true
|
||||
drag_margin/v_enabled = true
|
||||
smoothing/enable = false
|
||||
smoothing/speed = 5.0
|
||||
drag_margin/left = 0.2
|
||||
drag_margin/top = 0.2
|
||||
drag_margin/right = 0.2
|
||||
drag_margin/bottom = 0.2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
|
||||
transform/pos = Vector2( 0.291992, -0.835023 )
|
||||
shape = SubResource( 1 )
|
||||
trigger = false
|
||||
_update_shape_index = 0
|
||||
|
||||
[node name="sound" type="SamplePlayer" parent="."]
|
||||
|
||||
config/polyphony = 1
|
||||
config/samples = SubResource( 13 )
|
||||
default/volume_db = 0.0
|
||||
default/pitch_scale = 1.0
|
||||
default/pan = 0.0
|
||||
default/depth = 0.0
|
||||
default/height = 0.0
|
||||
default/filter/type = 0
|
||||
default/filter/cutoff = 0.0
|
||||
default/filter/resonance = 0.0
|
||||
default/filter/gain = 0.0
|
||||
default/reverb_room = 2
|
||||
default/reverb_send = 0.0
|
||||
default/chorus_send = 0.0
|
||||
|
||||
[node name="ui" type="CanvasLayer" parent="."]
|
||||
|
||||
layer = 0
|
||||
offset = Vector2( 0, 0 )
|
||||
rotation = 0.0
|
||||
scale = Vector2( 1, 1 )
|
||||
|
||||
[node name="left" type="TouchScreenButton" parent="ui"]
|
||||
|
||||
transform/pos = Vector2( 27.7593, 360.87 )
|
||||
transform/scale = Vector2( 1.49157, 1.46265 )
|
||||
normal = ExtResource( 7 )
|
||||
pressed = null
|
||||
bitmask = null
|
||||
passby_press = true
|
||||
action = "move_left"
|
||||
visibility_mode = 1
|
||||
|
||||
[node name="right" type="TouchScreenButton" parent="ui"]
|
||||
|
||||
transform/pos = Vector2( 121.542, 361.415 )
|
||||
transform/scale = Vector2( 1.49157, 1.46265 )
|
||||
normal = ExtResource( 8 )
|
||||
pressed = null
|
||||
bitmask = null
|
||||
passby_press = true
|
||||
action = "move_right"
|
||||
visibility_mode = 1
|
||||
|
||||
[node name="jump" type="TouchScreenButton" parent="ui"]
|
||||
|
||||
transform/pos = Vector2( 666.224, 359.02 )
|
||||
transform/scale = Vector2( 1.49157, 1.46265 )
|
||||
normal = ExtResource( 9 )
|
||||
pressed = null
|
||||
bitmask = null
|
||||
passby_press = false
|
||||
action = "jump"
|
||||
visibility_mode = 1
|
||||
|
||||
[node name="fire" type="TouchScreenButton" parent="ui"]
|
||||
|
||||
transform/pos = Vector2( 668.073, 262.788 )
|
||||
transform/scale = Vector2( 1.49157, 1.46265 )
|
||||
normal = ExtResource( 10 )
|
||||
pressed = null
|
||||
bitmask = null
|
||||
passby_press = false
|
||||
action = "shoot"
|
||||
visibility_mode = 1
|
||||
|
||||
|
||||
BIN
2d/platformer_kcc/robot_demo.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
2d/platformer_kcc/scroll_bg_cloud_1.png
Normal file
|
After Width: | Height: | Size: 531 B |
BIN
2d/platformer_kcc/scroll_bg_cloud_2.png
Normal file
|
After Width: | Height: | Size: 719 B |
BIN
2d/platformer_kcc/scroll_bg_cloud_3.png
Normal file
|
After Width: | Height: | Size: 394 B |
BIN
2d/platformer_kcc/scroll_bg_fg_1.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
2d/platformer_kcc/scroll_bg_fg_2.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
2d/platformer_kcc/scroll_bg_sky.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
2d/platformer_kcc/sound_coin.wav
Normal file
BIN
2d/platformer_kcc/sound_hit.wav
Normal file
BIN
2d/platformer_kcc/sound_jump.wav
Normal file
373
2d/platformer_kcc/stage.tscn
Normal file
BIN
2d/platformer_kcc/tiles_demo.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
1
2d/platformer_kcc/tiles_demo.png.flags
Normal file
@@ -0,0 +1 @@
|
||||
filter=false
|
||||
243
2d/platformer_kcc/tileset.tres
Normal file
@@ -0,0 +1,243 @@
|
||||
[gd_resource type="TileSet" load_steps=14 format=1]
|
||||
|
||||
[ext_resource path="res://tiles_demo.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=1]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, -24, 32, -24, 32, 32, -32, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=2]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, 32, -32, -24, 24, -24, 24, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=3]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, -32, 32, -32, 32, 32, -32, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=4]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, -56, 32, 8, 32, 64, -32, 64 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=5]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, 32, -32, -32, 24, -32, 24, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=6]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, -24, 32, -24, 32, 24, -32, 24 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=7]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, -24, 24, -24, 24, 24, -32, 24 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=8]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, 32, -32, -32, 24, -32, 24, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=9]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -64, 32, -64, -32, -8, -32, -8, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=10]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, 32, -32, -32, 24, -32, 32, -24, 32, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=11]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, 32, -32, -24, 32, -24, 32, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=12]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, 32, -32, -24, 32, -24, 32, 32 )
|
||||
|
||||
[resource]
|
||||
|
||||
0/name = "floor"
|
||||
0/texture = ExtResource( 1 )
|
||||
0/tex_offset = Vector2( 0, 0 )
|
||||
0/modulate = Color( 1, 1, 1, 1 )
|
||||
0/region = Rect2( 0, 0, 64, 64 )
|
||||
0/occluder_offset = Vector2( 32, 32 )
|
||||
0/navigation_offset = Vector2( 32, 32 )
|
||||
0/shape_offset = Vector2( 32, 32 )
|
||||
0/shapes = [ SubResource( 1 ) ]
|
||||
0/one_way_collision_direction = Vector2( 0, 0 )
|
||||
0/one_way_collision_max_depth = 0.0
|
||||
1/name = "edge"
|
||||
1/texture = ExtResource( 1 )
|
||||
1/tex_offset = Vector2( 0, 0 )
|
||||
1/modulate = Color( 1, 1, 1, 1 )
|
||||
1/region = Rect2( 64, 0, 64, 64 )
|
||||
1/occluder_offset = Vector2( 32, 32 )
|
||||
1/navigation_offset = Vector2( 32, 32 )
|
||||
1/shape_offset = Vector2( 32, 32 )
|
||||
1/shapes = [ SubResource( 2 ) ]
|
||||
1/one_way_collision_direction = Vector2( 0, 0 )
|
||||
1/one_way_collision_max_depth = 0.0
|
||||
2/name = "wall"
|
||||
2/texture = ExtResource( 1 )
|
||||
2/tex_offset = Vector2( 0, 0 )
|
||||
2/modulate = Color( 1, 1, 1, 1 )
|
||||
2/region = Rect2( 64, 64, 64, 64 )
|
||||
2/occluder_offset = Vector2( 32, 32 )
|
||||
2/navigation_offset = Vector2( 32, 32 )
|
||||
2/shape_offset = Vector2( 32, 32 )
|
||||
2/shapes = [ SubResource( 8 ) ]
|
||||
2/one_way_collision_direction = Vector2( 0, 0 )
|
||||
2/one_way_collision_max_depth = 0.0
|
||||
3/name = "wall_deco"
|
||||
3/texture = ExtResource( 1 )
|
||||
3/tex_offset = Vector2( 0, 0 )
|
||||
3/modulate = Color( 1, 1, 1, 1 )
|
||||
3/region = Rect2( 320, 128, 128, 64 )
|
||||
3/occluder_offset = Vector2( 64, 32 )
|
||||
3/navigation_offset = Vector2( 64, 32 )
|
||||
3/shape_offset = Vector2( 64, 32 )
|
||||
3/shapes = [ SubResource( 9 ) ]
|
||||
3/one_way_collision_direction = Vector2( 0, 0 )
|
||||
3/one_way_collision_max_depth = 0.0
|
||||
4/name = "corner"
|
||||
4/texture = ExtResource( 1 )
|
||||
4/tex_offset = Vector2( 0, 0 )
|
||||
4/modulate = Color( 1, 1, 1, 1 )
|
||||
4/region = Rect2( 64, 128, 64, 64 )
|
||||
4/occluder_offset = Vector2( 32, 32 )
|
||||
4/navigation_offset = Vector2( 32, 32 )
|
||||
4/shape_offset = Vector2( 32, 32 )
|
||||
4/shapes = [ SubResource( 10 ) ]
|
||||
4/one_way_collision_direction = Vector2( 0, 0 )
|
||||
4/one_way_collision_max_depth = 0.0
|
||||
5/name = "flowers"
|
||||
5/texture = ExtResource( 1 )
|
||||
5/tex_offset = Vector2( 0, 0 )
|
||||
5/modulate = Color( 1, 1, 1, 1 )
|
||||
5/region = Rect2( 192, 192, 64, 64 )
|
||||
5/occluder_offset = Vector2( 32, 32 )
|
||||
5/navigation_offset = Vector2( 32, 32 )
|
||||
5/shape_offset = Vector2( 32, 32 )
|
||||
5/shapes = [ SubResource( 11 ) ]
|
||||
5/one_way_collision_direction = Vector2( 0, 0 )
|
||||
5/one_way_collision_max_depth = 0.0
|
||||
6/name = "tree_base"
|
||||
6/texture = ExtResource( 1 )
|
||||
6/tex_offset = Vector2( 0, 0 )
|
||||
6/modulate = Color( 1, 1, 1, 1 )
|
||||
6/region = Rect2( 256, 192, 64, 64 )
|
||||
6/occluder_offset = Vector2( 32, 32 )
|
||||
6/navigation_offset = Vector2( 32, 32 )
|
||||
6/shape_offset = Vector2( 32, 32 )
|
||||
6/shapes = [ SubResource( 12 ) ]
|
||||
6/one_way_collision_direction = Vector2( 0, 0 )
|
||||
6/one_way_collision_max_depth = 0.0
|
||||
7/name = "tree_mid"
|
||||
7/texture = ExtResource( 1 )
|
||||
7/tex_offset = Vector2( 0, 0 )
|
||||
7/modulate = Color( 1, 1, 1, 1 )
|
||||
7/region = Rect2( 256, 128, 64, 64 )
|
||||
7/occluder_offset = Vector2( 32, 32 )
|
||||
7/navigation_offset = Vector2( 32, 32 )
|
||||
7/shape_offset = Vector2( 0, 0 )
|
||||
7/shapes = [ ]
|
||||
7/one_way_collision_direction = Vector2( 0, 0 )
|
||||
7/one_way_collision_max_depth = 0.0
|
||||
8/name = "tree_mid 2"
|
||||
8/texture = ExtResource( 1 )
|
||||
8/tex_offset = Vector2( 0, 0 )
|
||||
8/modulate = Color( 1, 1, 1, 1 )
|
||||
8/region = Rect2( 256, 64, 64, 64 )
|
||||
8/occluder_offset = Vector2( 32, 32 )
|
||||
8/navigation_offset = Vector2( 32, 32 )
|
||||
8/shape_offset = Vector2( 0, 0 )
|
||||
8/shapes = [ ]
|
||||
8/one_way_collision_direction = Vector2( 0, 0 )
|
||||
8/one_way_collision_max_depth = 0.0
|
||||
9/name = "tree_top"
|
||||
9/texture = ExtResource( 1 )
|
||||
9/tex_offset = Vector2( 0, 0 )
|
||||
9/modulate = Color( 1, 1, 1, 1 )
|
||||
9/region = Rect2( 256, 0, 64, 64 )
|
||||
9/occluder_offset = Vector2( 32, 32 )
|
||||
9/navigation_offset = Vector2( 32, 32 )
|
||||
9/shape_offset = Vector2( 0, 0 )
|
||||
9/shapes = [ ]
|
||||
9/one_way_collision_direction = Vector2( 0, 0 )
|
||||
9/one_way_collision_max_depth = 0.0
|
||||
10/name = "solid"
|
||||
10/texture = ExtResource( 1 )
|
||||
10/tex_offset = Vector2( 0, 0 )
|
||||
10/modulate = Color( 1, 1, 1, 1 )
|
||||
10/region = Rect2( 0, 64, 64, 64 )
|
||||
10/occluder_offset = Vector2( 32, 32 )
|
||||
10/navigation_offset = Vector2( 32, 32 )
|
||||
10/shape_offset = Vector2( 0, 0 )
|
||||
10/shapes = [ ]
|
||||
10/one_way_collision_direction = Vector2( 0, 0 )
|
||||
10/one_way_collision_max_depth = 0.0
|
||||
11/name = "ceiling"
|
||||
11/texture = ExtResource( 1 )
|
||||
11/tex_offset = Vector2( 0, 0 )
|
||||
11/modulate = Color( 1, 1, 1, 1 )
|
||||
11/region = Rect2( 384, 64, 64, 64 )
|
||||
11/occluder_offset = Vector2( 32, 32 )
|
||||
11/navigation_offset = Vector2( 32, 32 )
|
||||
11/shape_offset = Vector2( 32, 32 )
|
||||
11/shapes = [ SubResource( 3 ) ]
|
||||
11/one_way_collision_direction = Vector2( 0, 0 )
|
||||
11/one_way_collision_max_depth = 0.0
|
||||
12/name = "ramp"
|
||||
12/texture = ExtResource( 1 )
|
||||
12/tex_offset = Vector2( 0, 0 )
|
||||
12/modulate = Color( 1, 1, 1, 1 )
|
||||
12/region = Rect2( 128, 128, 64, 128 )
|
||||
12/occluder_offset = Vector2( 32, 64 )
|
||||
12/navigation_offset = Vector2( 32, 64 )
|
||||
12/shape_offset = Vector2( 32, 64 )
|
||||
12/shapes = [ SubResource( 4 ) ]
|
||||
12/one_way_collision_direction = Vector2( 0, 0 )
|
||||
12/one_way_collision_max_depth = 0.0
|
||||
13/name = "ceiling2wall"
|
||||
13/texture = ExtResource( 1 )
|
||||
13/tex_offset = Vector2( 0, 0 )
|
||||
13/modulate = Color( 1, 1, 1, 1 )
|
||||
13/region = Rect2( 448, 64, 64, 64 )
|
||||
13/occluder_offset = Vector2( 32, 32 )
|
||||
13/navigation_offset = Vector2( 32, 32 )
|
||||
13/shape_offset = Vector2( 32, 32 )
|
||||
13/shapes = [ SubResource( 5 ) ]
|
||||
13/one_way_collision_direction = Vector2( 0, 0 )
|
||||
13/one_way_collision_max_depth = 0.0
|
||||
14/name = "platform_floor"
|
||||
14/texture = ExtResource( 1 )
|
||||
14/tex_offset = Vector2( 0, 0 )
|
||||
14/modulate = Color( 1, 1, 1, 1 )
|
||||
14/region = Rect2( 128, 0, 64, 64 )
|
||||
14/occluder_offset = Vector2( 32, 32 )
|
||||
14/navigation_offset = Vector2( 32, 32 )
|
||||
14/shape_offset = Vector2( 32, 32 )
|
||||
14/shapes = [ SubResource( 6 ) ]
|
||||
14/one_way_collision_direction = Vector2( 0, 0 )
|
||||
14/one_way_collision_max_depth = 0.0
|
||||
15/name = "platform_edge"
|
||||
15/texture = ExtResource( 1 )
|
||||
15/tex_offset = Vector2( 0, 0 )
|
||||
15/modulate = Color( 1, 1, 1, 1 )
|
||||
15/region = Rect2( 192, 0, 64, 64 )
|
||||
15/occluder_offset = Vector2( 32, 32 )
|
||||
15/navigation_offset = Vector2( 32, 32 )
|
||||
15/shape_offset = Vector2( 32, 32 )
|
||||
15/shapes = [ SubResource( 7 ) ]
|
||||
15/one_way_collision_direction = Vector2( 0, 0 )
|
||||
15/one_way_collision_max_depth = 0.0
|
||||
|
||||
432
2d/platformer_kcc/tileset_edit.tscn
Normal file
@@ -0,0 +1,432 @@
|
||||
[gd_scene load_steps=14 format=1]
|
||||
|
||||
[ext_resource path="res://tiles_demo.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=1]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, -24, 32, -24, 32, 32, -32, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=2]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, 32, -32, -24, 24, -24, 24, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=3]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, 32, -32, -32, 24, -32, 24, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=4]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -64, 32, -64, -32, -8, -32, -8, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=5]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, 32, -32, -32, 24, -32, 32, -24, 32, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=6]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, 32, -32, -24, 32, -24, 32, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=7]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, 32, -32, -24, 32, -24, 32, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=8]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, -32, 32, -32, 32, 32, -32, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=9]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, -56, 32, 8, 32, 64, -32, 64 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=10]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, 32, -32, -32, 24, -32, 24, 32 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=11]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, -24, 32, -24, 32, 24, -32, 24 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=12]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
points = Vector2Array( -32, -24, 24, -24, 24, 24, -32, 24 )
|
||||
|
||||
[node name="Node" type="Node"]
|
||||
|
||||
[node name="floor" type="Sprite" parent="."]
|
||||
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 0, 0, 64, 64 )
|
||||
|
||||
[node name="collision" type="StaticBody2D" parent="floor"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 1 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
constant_linear_velocity = Vector2( 0, 0 )
|
||||
constant_angular_velocity = 0.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="floor/collision"]
|
||||
|
||||
build_mode = 0
|
||||
polygon = Vector2Array( 32, -24, 32, 32, -32, 32, -32, -24 )
|
||||
shape_range = Vector2( -1, -1 )
|
||||
trigger = false
|
||||
|
||||
[node name="edge" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 64, 0 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 64, 0, 64, 64 )
|
||||
|
||||
[node name="collision" type="StaticBody2D" parent="edge"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 2 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
constant_linear_velocity = Vector2( 0, 0 )
|
||||
constant_angular_velocity = 0.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="edge/collision"]
|
||||
|
||||
build_mode = 0
|
||||
polygon = Vector2Array( -32, -24, 24, -24, 24, 32, -32, 32 )
|
||||
shape_range = Vector2( -1, -1 )
|
||||
trigger = false
|
||||
|
||||
[node name="wall" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 64, 64 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 64, 64, 64, 64 )
|
||||
|
||||
[node name="collision" type="StaticBody2D" parent="wall"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 3 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
constant_linear_velocity = Vector2( 0, 0 )
|
||||
constant_angular_velocity = 0.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="wall/collision"]
|
||||
|
||||
build_mode = 0
|
||||
polygon = Vector2Array( -32, -32, 24, -32, 24, 32, -32, 32 )
|
||||
shape_range = Vector2( -1, -1 )
|
||||
trigger = false
|
||||
|
||||
[node name="wall_deco" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 96, 128 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 320, 128, 128, 64 )
|
||||
|
||||
[node name="collision" type="StaticBody2D" parent="wall_deco"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 4 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
constant_linear_velocity = Vector2( 0, 0 )
|
||||
constant_angular_velocity = 0.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="wall_deco/collision"]
|
||||
|
||||
build_mode = 0
|
||||
polygon = Vector2Array( -64, -32, -8, -32, -8, 32, -64, 32 )
|
||||
shape_range = Vector2( -1, -1 )
|
||||
trigger = false
|
||||
|
||||
[node name="corner" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 64, 192 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 64, 128, 64, 64 )
|
||||
|
||||
[node name="collision" type="StaticBody2D" parent="corner"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 5 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
constant_linear_velocity = Vector2( 0, 0 )
|
||||
constant_angular_velocity = 0.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="corner/collision"]
|
||||
|
||||
build_mode = 0
|
||||
polygon = Vector2Array( -32, -32, 24, -32, 32, -24, 32, 32, -32, 32 )
|
||||
shape_range = Vector2( -1, -1 )
|
||||
trigger = false
|
||||
|
||||
[node name="flowers" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 128, 192 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 192, 192, 64, 64 )
|
||||
|
||||
[node name="collision" type="StaticBody2D" parent="flowers"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 6 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
constant_linear_velocity = Vector2( 0, 0 )
|
||||
constant_angular_velocity = 0.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="flowers/collision"]
|
||||
|
||||
build_mode = 0
|
||||
polygon = Vector2Array( -32, 32, 32, 32, 32, -24, -32, -24 )
|
||||
shape_range = Vector2( -1, -1 )
|
||||
trigger = false
|
||||
|
||||
[node name="tree_base" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 192, 192 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 256, 192, 64, 64 )
|
||||
|
||||
[node name="collision" type="StaticBody2D" parent="tree_base"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 7 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
constant_linear_velocity = Vector2( 0, 0 )
|
||||
constant_angular_velocity = 0.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="tree_base/collision"]
|
||||
|
||||
build_mode = 0
|
||||
polygon = Vector2Array( -32, 32, 32, 32, 32, -24, -32, -24 )
|
||||
shape_range = Vector2( -1, -1 )
|
||||
trigger = false
|
||||
|
||||
[node name="tree_mid" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 192, 128 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 256, 128, 64, 64 )
|
||||
|
||||
[node name="tree_mid 2" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 192, 64 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 256, 64, 64, 64 )
|
||||
|
||||
[node name="tree_top" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 192, 0 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 256, 0, 64, 64 )
|
||||
|
||||
[node name="solid" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 0, 64 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 0, 64, 64, 64 )
|
||||
|
||||
[node name="ceiling" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 0, 128 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 384, 64, 64, 64 )
|
||||
|
||||
[node name="collision" type="StaticBody2D" parent="ceiling"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 8 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
constant_linear_velocity = Vector2( 0, 0 )
|
||||
constant_angular_velocity = 0.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="ceiling/collision"]
|
||||
|
||||
build_mode = 0
|
||||
polygon = Vector2Array( 32, -32, 32, 32, -32, 32, -32, -32 )
|
||||
shape_range = Vector2( -1, -1 )
|
||||
trigger = false
|
||||
|
||||
[node name="ramp" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 256, 224 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 128, 128, 64, 128 )
|
||||
|
||||
[node name="collision" type="StaticBody2D" parent="ramp"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 9 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
constant_linear_velocity = Vector2( 0, 0 )
|
||||
constant_angular_velocity = 0.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="ramp/collision"]
|
||||
|
||||
build_mode = 0
|
||||
polygon = Vector2Array( -32, -56, 32, 8, 32, 64, -32, 64 )
|
||||
shape_range = Vector2( -1, -1 )
|
||||
trigger = false
|
||||
|
||||
[node name="ceiling2wall" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 0, 192 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 448, 64, 64, 64 )
|
||||
|
||||
[node name="collision" type="StaticBody2D" parent="ceiling2wall"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 10 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
constant_linear_velocity = Vector2( 0, 0 )
|
||||
constant_angular_velocity = 0.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="ceiling2wall/collision"]
|
||||
|
||||
build_mode = 0
|
||||
polygon = Vector2Array( -32, -32, 24, -32, 24, 32, -32, 32 )
|
||||
shape_range = Vector2( -1, -1 )
|
||||
trigger = false
|
||||
|
||||
[node name="platform_floor" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 0, 256 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 128, 0, 64, 64 )
|
||||
|
||||
[node name="collision" type="StaticBody2D" parent="platform_floor"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 11 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
constant_linear_velocity = Vector2( 0, 0 )
|
||||
constant_angular_velocity = 0.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="platform_floor/collision"]
|
||||
|
||||
build_mode = 0
|
||||
polygon = Vector2Array( 32, -24, 32, 24, -32, 24, -32, -24 )
|
||||
shape_range = Vector2( -1, -1 )
|
||||
trigger = false
|
||||
|
||||
[node name="platform_edge" type="Sprite" parent="."]
|
||||
|
||||
transform/pos = Vector2( 64, 256 )
|
||||
texture = ExtResource( 1 )
|
||||
region = true
|
||||
region_rect = Rect2( 192, 0, 64, 64 )
|
||||
|
||||
[node name="collision" type="StaticBody2D" parent="platform_edge"]
|
||||
|
||||
input/pickable = false
|
||||
shapes/0/shape = SubResource( 12 )
|
||||
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||
shapes/0/trigger = false
|
||||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
constant_linear_velocity = Vector2( 0, 0 )
|
||||
constant_angular_velocity = 0.0
|
||||
friction = 1.0
|
||||
bounce = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="platform_edge/collision"]
|
||||
|
||||
build_mode = 0
|
||||
polygon = Vector2Array( 24, -24, 24, 24, -32, 24, -32, -24 )
|
||||
shape_range = Vector2( -1, -1 )
|
||||
trigger = false
|
||||
|
||||
[node name="help" type="Label" parent="."]
|
||||
|
||||
focus/ignore_mouse = true
|
||||
focus/stop_mouse = true
|
||||
size_flags/horizontal = 2
|
||||
margin/left = 1.0
|
||||
margin/top = 331.0
|
||||
margin/right = 727.0
|
||||
margin/bottom = 422.0
|
||||
text = "This scene serves as a tool for editing the tileset.\nNodes (sprites) and their respective collisionsare edited here.\n\nTo create a tileset from this, a \"TileSet\" resoucre must be created. Use the helper in: Scene -> Convert To -> TileSet.\nThis will save a tileset. Saving over it will merge your changes.\n\nFinally, the saved tileset resource (tileset.tres in this case), can be opened to be used into a TileMap node for editing a tile map."
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Node2D
|
||||
|
||||
# Member variables
|
||||
@@ -17,47 +16,47 @@ func _process(delta):
|
||||
var ball_pos = get_node("ball").get_pos()
|
||||
var left_rect = Rect2(get_node("left").get_pos() - pad_size*0.5, pad_size)
|
||||
var right_rect = Rect2(get_node("right").get_pos() - pad_size*0.5, pad_size)
|
||||
|
||||
|
||||
# Integrate new ball postion
|
||||
ball_pos += direction*ball_speed*delta
|
||||
|
||||
|
||||
# Flip when touching roof or floor
|
||||
if ((ball_pos.y < 0 and direction.y < 0) or (ball_pos.y > screen_size.y and direction.y > 0)):
|
||||
direction.y = -direction.y
|
||||
|
||||
|
||||
# Flip, change direction and increase speed when touching pads
|
||||
if ((left_rect.has_point(ball_pos) and direction.x < 0) or (right_rect.has_point(ball_pos) and direction.x > 0)):
|
||||
direction.x = -direction.x
|
||||
ball_speed *= 1.1
|
||||
direction.y = randf()*2.0 - 1
|
||||
direction = direction.normalized()
|
||||
|
||||
|
||||
# Check gameover
|
||||
if (ball_pos.x < 0 or ball_pos.x > screen_size.x):
|
||||
ball_pos = screen_size*0.5
|
||||
ball_speed = INITIAL_BALL_SPEED
|
||||
direction = Vector2(-1, 0)
|
||||
|
||||
|
||||
get_node("ball").set_pos(ball_pos)
|
||||
|
||||
|
||||
# Move left pad
|
||||
var left_pos = get_node("left").get_pos()
|
||||
|
||||
|
||||
if (left_pos.y > 0 and Input.is_action_pressed("left_move_up")):
|
||||
left_pos.y += -PAD_SPEED*delta
|
||||
if (left_pos.y < screen_size.y and Input.is_action_pressed("left_move_down")):
|
||||
left_pos.y += PAD_SPEED*delta
|
||||
|
||||
|
||||
get_node("left").set_pos(left_pos)
|
||||
|
||||
|
||||
# Move right pad
|
||||
var right_pos = get_node("right").get_pos()
|
||||
|
||||
|
||||
if (right_pos.y > 0 and Input.is_action_pressed("right_move_up")):
|
||||
right_pos.y += -PAD_SPEED*delta
|
||||
if (right_pos.y < screen_size.y and Input.is_action_pressed("right_move_down")):
|
||||
right_pos.y += PAD_SPEED*delta
|
||||
|
||||
|
||||
get_node("right").set_pos(right_pos)
|
||||
|
||||
|
||||
|
||||
@@ -7,4 +7,4 @@ icon="res://icon.png"
|
||||
[physics_2d]
|
||||
|
||||
default_gravity=500
|
||||
default_density=0.01
|
||||
default_linear_damp=0.01
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Control
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Node2D
|
||||
|
||||
# This demo is an example of controling a high number of 2D objects with logic and collision without using scene nodes.
|
||||
@@ -35,37 +34,37 @@ func _process(delta):
|
||||
if (b.pos.x < -30):
|
||||
b.pos.x += width
|
||||
mat.o = b.pos
|
||||
|
||||
|
||||
Physics2DServer.body_set_state(b.body, Physics2DServer.BODY_STATE_TRANSFORM, mat)
|
||||
|
||||
|
||||
update()
|
||||
|
||||
|
||||
func _ready():
|
||||
shape = Physics2DServer.shape_create(Physics2DServer.SHAPE_CIRCLE)
|
||||
Physics2DServer.shape_set_data(shape, 8) # Radius
|
||||
|
||||
|
||||
for i in range(BULLET_COUNT):
|
||||
var b = Bullet.new()
|
||||
b.speed = rand_range(SPEED_MIN, SPEED_MAX)
|
||||
b.body = Physics2DServer.body_create(Physics2DServer.BODY_MODE_KINEMATIC)
|
||||
Physics2DServer.body_set_space(b.body, get_world_2d().get_space())
|
||||
Physics2DServer.body_add_shape(b.body, shape)
|
||||
|
||||
|
||||
b.pos = Vector2(get_viewport_rect().size * Vector2(randf()*2.0, randf())) # Twice as long
|
||||
b.pos.x += get_viewport_rect().size.x # Start outside
|
||||
var mat = Matrix32()
|
||||
mat.o = b.pos
|
||||
Physics2DServer.body_set_state(b.body, Physics2DServer.BODY_STATE_TRANSFORM, mat)
|
||||
|
||||
|
||||
bullets.append(b)
|
||||
|
||||
|
||||
set_process(true)
|
||||
|
||||
|
||||
func _exit_tree():
|
||||
for b in bullets:
|
||||
Physics2DServer.free_rid(b.body)
|
||||
|
||||
|
||||
Physics2DServer.free_rid(shape)
|
||||
bullets.clear()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Node2D
|
||||
|
||||
# Member variables
|
||||
|
||||
39
2d/space_shooter/README.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Space Shooter
|
||||
|
||||
## Introduction
|
||||
In this on-rails shoot-em-up demo, the player gets to control a Space ship flying through a 2D version of Space, while firing their lasers by hitting the Space bar.
|
||||
Various enemies will enter the screen from the right and try their hardest to destroy the player's ship.
|
||||
Shooting these enemies will award points and the highest score achieved is kept in a one-entry leaderboard.
|
||||
Avoiding the blocky obstacles and the enemies is key to survival and high scores, so good luck and have fun!
|
||||
|
||||
## Controls
|
||||
* WSAD or Arrow Keys to move the ship
|
||||
* Space to fire lasers
|
||||
* Escape / ESC to stop playing and return to the main menu
|
||||
|
||||
---
|
||||
## Godot Concepts presented in the demo
|
||||
### Editor Workflow
|
||||
* Importing assets (images, sounds)
|
||||
* Using Scenes to group Nodes into small, mostly self-contained units of functionality
|
||||
* Using a TileMap and TileSet to place obstacles in the level
|
||||
* Use of AnimationPlayer nodes to both animate properties (position, rotation) as well as trigger functions
|
||||
* Using a Parallax Background to give an impression of speed and distance traveled
|
||||
|
||||
### Scripting
|
||||
* Using signals to communicate between Nodes that are created in different Scenes
|
||||
* Using groups to tag and identify Nodes
|
||||
* Interactions between KinematicBody2D and Area2D nodes for hit detection / collision
|
||||
* Use of VisibilityNotifier2D to remove Nodes that move off screen
|
||||
* Dynamically instancing loaded Scenes as Nodes
|
||||
|
||||
### GUI
|
||||
* GUI Containers for organization and positioning
|
||||
* GUI Controls to start and stop gameplay
|
||||
* Use of a CanvasLayer to keep GUI always on top of the gameplay screen
|
||||
|
||||
### Miscellaneous
|
||||
* Persisting a "savegame" in the user directory for the highscore
|
||||
|
||||
### Interactivity
|
||||
* Player input for movement and firing
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=3 format=1]
|
||||
|
||||
[ext_resource path="res://tile.png" type="Texture" id=1]
|
||||
[ext_resource path="res://game_screen/level/tile.png" type="Texture" id=1]
|
||||
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
|
||||
extends Area2D
|
||||
|
||||
# Member variables
|
||||
const SPEED = -200
|
||||
const Y_RANDOM = 10
|
||||
|
||||
var points = 1
|
||||
var speed_y = 0.0
|
||||
var destroyed = false
|
||||
|
||||
|
||||
func _fixed_process(delta):
|
||||
translate(Vector2(SPEED, speed_y)*delta)
|
||||
|
||||
|
||||
func _ready():
|
||||
speed_y = rand_range(-Y_RANDOM, Y_RANDOM)
|
||||
|
||||
|
||||
func destroy():
|
||||
if (destroyed):
|
||||
return
|
||||
destroyed = true
|
||||
get_node("anim").play("explode")
|
||||
set_fixed_process(false)
|
||||
get_node("sfx").play("sound_explode")
|
||||
# Accumulate points
|
||||
get_node("/root/game_state").points += 1
|
||||
|
||||
|
||||
func is_enemy():
|
||||
return not destroyed
|
||||
|
||||
|
||||
func _on_visibility_enter_screen():
|
||||
set_fixed_process(true)
|
||||
# Make it spin!
|
||||
get_node("anim").play("spin")
|
||||
|
||||
|
||||
func _on_visibility_exit_screen():
|
||||
queue_free()
|
||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,2 @@
|
||||
filter=false
|
||||
gen_mipmaps=false
|
||||
|
Before Width: | Height: | Size: 275 B After Width: | Height: | Size: 275 B |
2
2d/space_shooter/effects/background/big_star.png.flags
Normal file
@@ -0,0 +1,2 @@
|
||||
filter=false
|
||||
gen_mipmaps=false
|
||||
@@ -1,8 +1,8 @@
|
||||
[gd_scene load_steps=4 format=1]
|
||||
|
||||
[ext_resource path="res://bg_gradient.png" type="Texture" id=1]
|
||||
[ext_resource path="res://small_star.png" type="Texture" id=2]
|
||||
[ext_resource path="res://big_star.png" type="Texture" id=3]
|
||||
[ext_resource path="res://effects/background/bg_gradient.png" type="Texture" id=1]
|
||||
[ext_resource path="res://effects/background/small_star.png" type="Texture" id=2]
|
||||
[ext_resource path="res://effects/background/big_star.png" type="Texture" id=3]
|
||||
|
||||
[node name="parallax" type="ParallaxBackground"]
|
||||
|
||||
@@ -20,6 +20,7 @@ scroll/ignore_camera_zoom = true
|
||||
[node name="bg_layer" type="ParallaxLayer" parent="."]
|
||||
|
||||
motion/scale = Vector2( 0.2, 1 )
|
||||
motion/offset = Vector2( 0, 0 )
|
||||
motion/mirroring = Vector2( 1024, 0 )
|
||||
|
||||
[node name="gradient" type="Sprite" parent="bg_layer"]
|
||||
@@ -136,6 +137,7 @@ texture = ExtResource( 2 )
|
||||
[node name="bg_layer2" type="ParallaxLayer" parent="."]
|
||||
|
||||
motion/scale = Vector2( 0.5, 1 )
|
||||
motion/offset = Vector2( 0, 0 )
|
||||
motion/mirroring = Vector2( 1024, 0 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="bg_layer2"]
|
||||
|
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 90 B |
2
2d/space_shooter/effects/background/small_star.png.flags
Normal file
@@ -0,0 +1,2 @@
|
||||
filter=false
|
||||
gen_mipmaps=false
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=3 format=1]
|
||||
|
||||
[ext_resource path="res://fire.png" type="Texture" id=1]
|
||||
[ext_resource path="res://effects/particles/fire.png" type="Texture" id=1]
|
||||
|
||||
|
||||
[sub_resource type="ColorRamp" id=1]
|
||||
|
||||
|
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 357 B |
2
2d/space_shooter/effects/particles/fire.png.flags
Normal file
@@ -0,0 +1,2 @@
|
||||
filter=false
|
||||
gen_mipmaps=false
|
||||
BIN
2d/space_shooter/effects/sounds/sound_explode.wav
Normal file
BIN
2d/space_shooter/effects/sounds/sound_shoot.wav
Normal file
59
2d/space_shooter/enemies/asteroid/asteroid.gd
Normal file
@@ -0,0 +1,59 @@
|
||||
extends Area2D
|
||||
|
||||
# horizontal movement speed
|
||||
const SPEED = -200
|
||||
|
||||
# how many points does the player get for destroying this enemy type?
|
||||
const POINTS = 1
|
||||
|
||||
# used for a slight vertical drift, defines the range
|
||||
const Y_RANDOM = 10
|
||||
|
||||
# vertical movement for this asteroid instance
|
||||
var speed_y = 0.0
|
||||
|
||||
# used to store this asteroid's motion direction
|
||||
var motion = Vector2()
|
||||
|
||||
var destroyed = false
|
||||
|
||||
# notifies listeners about death and sends the point value along with it
|
||||
signal enemy_died(score)
|
||||
|
||||
func _fixed_process(delta):
|
||||
# constant movement
|
||||
translate(motion * delta)
|
||||
|
||||
func _ready():
|
||||
# determine this asteroid's vertical drift
|
||||
speed_y = rand_range(-Y_RANDOM, Y_RANDOM)
|
||||
# store the movement direction because it doesn't change for this asteroid
|
||||
motion = Vector2(SPEED, speed_y)
|
||||
|
||||
func destroy():
|
||||
# skip if already destroyed
|
||||
if (destroyed):
|
||||
return
|
||||
|
||||
# set the state to destroyed
|
||||
destroyed = true
|
||||
# stop processing
|
||||
set_fixed_process(false)
|
||||
# play on-death effects
|
||||
get_node("anim").play("explode")
|
||||
get_node("sfx").play("sound_explode")
|
||||
# inform listeners about death, while sending the point value along with it
|
||||
emit_signal("enemy_died", POINTS)
|
||||
# disable physics interactions
|
||||
call_deferred("set_enable_monitoring", false)
|
||||
call_deferred("set_monitorable", false)
|
||||
|
||||
func _on_visibility_enter_screen():
|
||||
# start moving once the asteroid enters the screen
|
||||
set_fixed_process(true)
|
||||
# Make it spin!
|
||||
get_node("anim").play("spin")
|
||||
|
||||
func _on_visibility_exit_screen():
|
||||
# remove the asteroid when it leaves the screen
|
||||
queue_free()
|
||||
@@ -1,8 +1,11 @@
|
||||
[gd_scene load_steps=9 format=1]
|
||||
|
||||
[ext_resource path="res://asteroid.gd" type="Script" id=1]
|
||||
[ext_resource path="res://meteorite.png" type="Texture" id=2]
|
||||
[ext_resource path="res://sound_explode.wav" type="Sample" id=3]
|
||||
[ext_resource path="res://enemies/asteroid/asteroid.gd" type="Script" id=1]
|
||||
[ext_resource path="res://enemies/asteroid/meteorite.png" type="Texture" id=2]
|
||||
[ext_resource path="res://effects/sounds/sound_explode.wav" type="Sample" id=3]
|
||||
|
||||
|
||||
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
|
||||
@@ -18,15 +21,35 @@ step = 0.1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("particles:config/emitting")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/keys = { "cont":false, "times":FloatArray( 0, 0.1 ), "transitions":FloatArray( 1, 1 ), "values":[ true, false ] }
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = {
|
||||
"times": FloatArray( 0, 0.1 ),
|
||||
"transitions": FloatArray( 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ true, false ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("sprite:visibility/visible")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/keys = { "cont":false, "times":FloatArray( 0 ), "transitions":FloatArray( 1 ), "values":[ false ] }
|
||||
tracks/1/imported = false
|
||||
tracks/1/keys = {
|
||||
"times": FloatArray( 0 ),
|
||||
"transitions": FloatArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ false ]
|
||||
}
|
||||
tracks/2/type = "method"
|
||||
tracks/2/path = NodePath(".")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/keys = { "times":FloatArray( 0.7 ), "transitions":FloatArray( 1 ), "values":[ { "args":[ ], "method":"queue_free" } ] }
|
||||
tracks/2/imported = false
|
||||
tracks/2/keys = {
|
||||
"times": FloatArray( 0.7 ),
|
||||
"transitions": FloatArray( 1 ),
|
||||
"values": [ {
|
||||
"args": [ ],
|
||||
"method": "queue_free"
|
||||
} ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
|
||||
@@ -36,7 +59,13 @@ step = 0.1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("sprite:transform/rot")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/keys = { "cont":true, "times":FloatArray( 0, 3 ), "transitions":FloatArray( 1, 1 ), "values":[ 0.0, 360.0 ] }
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = {
|
||||
"times": FloatArray( 0, 3 ),
|
||||
"transitions": FloatArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ 0.0, 360.0 ]
|
||||
}
|
||||
|
||||
[sub_resource type="ColorRamp" id=4]
|
||||
|
||||
@@ -45,9 +74,16 @@ colors = ColorArray( 1, 1, 1, 1, 1, 1, 1, 0 )
|
||||
|
||||
[sub_resource type="SampleLibrary" id=5]
|
||||
|
||||
samples/sound_explode = { "db":0.0, "pitch":1.0, "sample":ExtResource( 3 ) }
|
||||
samples/sound_explode = {
|
||||
"db": 0.0,
|
||||
"pitch": 1.0,
|
||||
"priority": 0,
|
||||
"sample": ExtResource( 3 )
|
||||
}
|
||||
|
||||
[node name="asteroid" type="Area2D"]
|
||||
[node name="asteroid" type="Area2D" groups=[
|
||||
"enemy",
|
||||
]]
|
||||
|
||||
input/pickable = true
|
||||
shapes/0/shape = SubResource( 1 )
|
||||
@@ -90,6 +126,7 @@ rect = Rect2( -10, -10, 20, 20 )
|
||||
config/amount = 32
|
||||
config/lifetime = 0.5
|
||||
config/emitting = false
|
||||
config/process_mode = 1
|
||||
config/half_extents = Vector2( 20, 20 )
|
||||
config/explosiveness = 0.1
|
||||
config/texture = ExtResource( 2 )
|
||||
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
2
2d/space_shooter/enemies/asteroid/meteorite.png.flags
Normal file
@@ -0,0 +1,2 @@
|
||||
filter=false
|
||||
gen_mipmaps=false
|
||||
77
2d/space_shooter/enemies/shooter/enemy2.gd
Normal file
@@ -0,0 +1,77 @@
|
||||
extends Area2D
|
||||
|
||||
# horizontal movement speed
|
||||
const SPEED = -220
|
||||
|
||||
# how many points does the player get for destroying this ship?
|
||||
const POINTS = 10
|
||||
|
||||
# time between shots in seconds
|
||||
const SHOOT_INTERVAL = 1
|
||||
|
||||
# the enemy's projectile scene
|
||||
const Shot = preload("res://enemies/shooter/enemy_shot.tscn")
|
||||
|
||||
# used to store this enemy's motion direction
|
||||
var motion = Vector2()
|
||||
|
||||
var destroyed = false
|
||||
|
||||
# remaining timeout until the enemy can fire again
|
||||
var shoot_timeout = 0
|
||||
|
||||
# the node in the tree where this enemy should spawn its bullets into
|
||||
var projectile_container
|
||||
|
||||
# the Position2D that defines where the bullets will be spawned
|
||||
onready var shoot_from = get_node("shoot_from")
|
||||
|
||||
# used to notify listeners about this enemy's death
|
||||
signal enemy_died(score)
|
||||
|
||||
func _ready():
|
||||
motion = Vector2(SPEED, 0)
|
||||
|
||||
func _fixed_process(delta):
|
||||
# the enemy constantly moves
|
||||
translate(motion * delta)
|
||||
|
||||
# count down the time until the next shot
|
||||
if shoot_timeout > 0.0:
|
||||
shoot_timeout -= delta
|
||||
|
||||
if (shoot_timeout <= 0):
|
||||
shoot_timeout = SHOOT_INTERVAL
|
||||
|
||||
if projectile_container != null:
|
||||
# Instance a shot
|
||||
var shot = Shot.instance()
|
||||
# Set position to "shoot_from" Position2D node's global position
|
||||
shot.set_pos(shoot_from.get_global_pos())
|
||||
# Add it to the projectile container, making its movement independent from ours
|
||||
projectile_container.add_child(shot)
|
||||
|
||||
func set_projectile_container(container):
|
||||
projectile_container = container
|
||||
|
||||
func destroy():
|
||||
# skip if already destroyed
|
||||
if (destroyed):
|
||||
return
|
||||
destroyed = true
|
||||
|
||||
# stop processing
|
||||
set_fixed_process(false)
|
||||
# play on-death effects
|
||||
get_node("sfx").play("sound_explode")
|
||||
get_node("anim").play("explode")
|
||||
# inform listeners about death, while sending the point value along with it
|
||||
emit_signal("enemy_died", POINTS)
|
||||
call_deferred("set_enable_monitoring", false)
|
||||
call_deferred("set_monitorable", false)
|
||||
|
||||
func _on_visibility_enter_screen():
|
||||
set_fixed_process(true)
|
||||
|
||||
func _on_visibility_exit_screen():
|
||||
queue_free()
|
||||
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
2
2d/space_shooter/enemies/shooter/enemy2.png.flags
Normal file
@@ -0,0 +1,2 @@
|
||||
filter=false
|
||||
gen_mipmaps=false
|
||||
@@ -1,9 +1,12 @@
|
||||
[gd_scene load_steps=8 format=1]
|
||||
|
||||
[ext_resource path="res://enemy2.gd" type="Script" id=1]
|
||||
[ext_resource path="res://enemy2.png" type="Texture" id=2]
|
||||
[ext_resource path="res://explosion.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://sound_explode.wav" type="Sample" id=4]
|
||||
[ext_resource path="res://enemies/shooter/enemy2.gd" type="Script" id=1]
|
||||
[ext_resource path="res://enemies/shooter/enemy2.png" type="Texture" id=2]
|
||||
[ext_resource path="res://effects/particles/explosion.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://effects/sounds/sound_explode.wav" type="Sample" id=4]
|
||||
|
||||
|
||||
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=1]
|
||||
|
||||
@@ -18,21 +21,48 @@ step = 0.1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("explosion:config/emitting")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/keys = { "cont":false, "times":FloatArray( 0, 0.1 ), "transitions":FloatArray( 1, 1 ), "values":[ true, false ] }
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = {
|
||||
"times": FloatArray( 0, 0.1 ),
|
||||
"transitions": FloatArray( 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ true, false ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("sprite:visibility/visible")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/keys = { "cont":false, "times":FloatArray( 0 ), "transitions":FloatArray( 1 ), "values":[ false ] }
|
||||
tracks/1/imported = false
|
||||
tracks/1/keys = {
|
||||
"times": FloatArray( 0 ),
|
||||
"transitions": FloatArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ false ]
|
||||
}
|
||||
tracks/2/type = "method"
|
||||
tracks/2/path = NodePath(".")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/keys = { "times":FloatArray( 0.9 ), "transitions":FloatArray( 1 ), "values":[ { "args":[ ], "method":"queue_free" } ] }
|
||||
tracks/2/imported = false
|
||||
tracks/2/keys = {
|
||||
"times": FloatArray( 0.9 ),
|
||||
"transitions": FloatArray( 1 ),
|
||||
"values": [ {
|
||||
"args": [ ],
|
||||
"method": "queue_free"
|
||||
} ]
|
||||
}
|
||||
|
||||
[sub_resource type="SampleLibrary" id=3]
|
||||
|
||||
samples/sound_explode = { "db":0.0, "pitch":1.0, "sample":ExtResource( 4 ) }
|
||||
samples/sound_explode = {
|
||||
"db": 0.0,
|
||||
"pitch": 1.0,
|
||||
"priority": 0,
|
||||
"sample": ExtResource( 4 )
|
||||
}
|
||||
|
||||
[node name="enemy2" type="Area2D"]
|
||||
[node name="enemy2" type="Area2D" groups=[
|
||||
"enemy",
|
||||
]]
|
||||
|
||||
input/pickable = true
|
||||
shapes/0/shape = SubResource( 1 )
|
||||
@@ -57,9 +87,7 @@ texture = ExtResource( 2 )
|
||||
|
||||
[node name="explosion" parent="." instance=ExtResource( 3 )]
|
||||
|
||||
transform/rot = -91.1436
|
||||
config/explosiveness = 0.1
|
||||
params/gravity_strength = 9.8
|
||||
config/process_mode = 1
|
||||
|
||||
[node name="anim" type="AnimationPlayer" parent="."]
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
extends Area2D
|
||||
|
||||
# Member variables
|
||||
@@ -6,19 +5,18 @@ const SPEED = -800
|
||||
|
||||
var hit = false
|
||||
|
||||
var motion = Vector2()
|
||||
|
||||
func _process(delta):
|
||||
translate(Vector2(delta*SPEED, 0))
|
||||
|
||||
translate(motion * delta)
|
||||
|
||||
func _ready():
|
||||
motion = Vector2(SPEED, 0)
|
||||
set_process(true)
|
||||
|
||||
|
||||
func is_enemy():
|
||||
return true
|
||||
|
||||
|
||||
func _hit_something():
|
||||
if (hit):
|
||||
return
|
||||
@@ -26,6 +24,9 @@ func _hit_something():
|
||||
set_process(false)
|
||||
get_node("anim").play("splash")
|
||||
|
||||
|
||||
func _on_visibility_exit_screen():
|
||||
queue_free()
|
||||
|
||||
func _on_enemy_shot_area_enter(area):
|
||||
if area.is_in_group("player"):
|
||||
area.take_damage()
|
||||
|
Before Width: | Height: | Size: 330 B After Width: | Height: | Size: 330 B |
2
2d/space_shooter/enemies/shooter/enemy_shot.png.flags
Normal file
@@ -0,0 +1,2 @@
|
||||
filter=false
|
||||
gen_mipmaps=false
|
||||
@@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=6 format=1]
|
||||
|
||||
[ext_resource path="res://enemy_shot.gd" type="Script" id=1]
|
||||
[ext_resource path="res://enemy_shot.png" type="Texture" id=2]
|
||||
[ext_resource path="res://enemies/shooter/enemy_shot.gd" type="Script" id=1]
|
||||
[ext_resource path="res://enemies/shooter/enemy_shot.png" type="Texture" id=2]
|
||||
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
|
||||
@@ -21,15 +22,35 @@ step = 0.1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("hit_splash:config/emitting")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/keys = { "cont":false, "times":FloatArray( 0, 0.1 ), "transitions":FloatArray( 1, 1 ), "values":[ true, false ] }
|
||||
tracks/0/imported = false
|
||||
tracks/0/keys = {
|
||||
"times": FloatArray( 0, 0.1 ),
|
||||
"transitions": FloatArray( 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ true, false ]
|
||||
}
|
||||
tracks/1/type = "method"
|
||||
tracks/1/path = NodePath(".")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/keys = { "times":FloatArray( 0.9 ), "transitions":FloatArray( 1 ), "values":[ { "args":[ ], "method":"queue_free" } ] }
|
||||
tracks/1/imported = false
|
||||
tracks/1/keys = {
|
||||
"times": FloatArray( 0.9 ),
|
||||
"transitions": FloatArray( 1 ),
|
||||
"values": [ {
|
||||
"args": [ ],
|
||||
"method": "queue_free"
|
||||
} ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("sprite:visibility/visible")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/keys = { "cont":false, "times":FloatArray( 0 ), "transitions":FloatArray( 1 ), "values":[ false ] }
|
||||
tracks/2/imported = false
|
||||
tracks/2/keys = {
|
||||
"times": FloatArray( 0 ),
|
||||
"transitions": FloatArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ false ]
|
||||
}
|
||||
|
||||
[node name="enemy_shot" type="Area2D"]
|
||||
|
||||
@@ -45,9 +66,8 @@ script/script = ExtResource( 1 )
|
||||
|
||||
[node name="visibility" type="VisibilityNotifier2D" parent="."]
|
||||
|
||||
transform/pos = Vector2( 1.8353, -0.0742126 )
|
||||
transform/scale = Vector2( 1.54149, 0.770745 )
|
||||
rect = Rect2( -10, -10, 20, 20 )
|
||||
transform/pos = Vector2( 1, 0 )
|
||||
rect = Rect2( -13, -5, 24, 10 )
|
||||
|
||||
[node name="sprite" type="Sprite" parent="."]
|
||||
|
||||
@@ -58,12 +78,16 @@ texture = ExtResource( 2 )
|
||||
shape = SubResource( 1 )
|
||||
trigger = false
|
||||
_update_shape_index = -1
|
||||
__meta__ = {
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
[node name="hit_splash" type="Particles2D" parent="."]
|
||||
|
||||
config/amount = 32
|
||||
config/lifetime = 0.5
|
||||
config/emitting = false
|
||||
config/process_mode = 1
|
||||
config/explosiveness = 0.1
|
||||
params/direction = 0.0
|
||||
params/spread = 180.0
|
||||
@@ -82,6 +106,9 @@ params/hue_variation = 0.0
|
||||
params/anim_speed_scale = 1.0
|
||||
params/anim_initial_pos = 0.0
|
||||
color/color_ramp = SubResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
[node name="anim" type="AnimationPlayer" parent="."]
|
||||
|
||||
@@ -94,6 +121,8 @@ playback/speed = 1.0
|
||||
blend_times = [ ]
|
||||
autoplay = ""
|
||||
|
||||
[connection signal="area_enter" from="." to="." method="_on_enemy_shot_area_enter"]
|
||||
|
||||
[connection signal="exit_screen" from="visibility" to="." method="_on_visibility_exit_screen"]
|
||||
|
||||
|
||||
40
2d/space_shooter/enemies/ufo/enemy1.gd
Normal file
@@ -0,0 +1,40 @@
|
||||
extends Area2D
|
||||
|
||||
# how many points does the player get for destroying this ship?
|
||||
const POINTS = 5
|
||||
|
||||
var destroyed = false
|
||||
|
||||
# used to notify listeners about this enemy's death
|
||||
signal enemy_died(score)
|
||||
|
||||
func _ready():
|
||||
# the ship will start its zigzag movement at a random offset in its animation path
|
||||
# this skip is visible for about one frame
|
||||
# as a workaround, we hide the node until the animation seeking is later completed
|
||||
hide()
|
||||
|
||||
func destroy():
|
||||
# skip if already destroyed
|
||||
if (destroyed):
|
||||
return
|
||||
|
||||
# set the state to destroyed
|
||||
destroyed = true
|
||||
# play on-death effects
|
||||
# take note of how the explode animation also frees the parent node after 0.9 seconds
|
||||
get_node("anim").play("explode")
|
||||
get_node("sfx").play("sound_explode")
|
||||
# inform listeners about death, while sending the point value along with it
|
||||
emit_signal("enemy_died", POINTS)
|
||||
# disable physics interactions
|
||||
call_deferred("set_enable_monitoring", false)
|
||||
call_deferred("set_monitorable", false)
|
||||
|
||||
# this signal is connected in the editor
|
||||
func _on_visibility_enter_screen():
|
||||
get_node("anim").play("zigzag")
|
||||
# randomly offset the animation's start point
|
||||
get_node("anim").seek(randf()*2.0)
|
||||
# as mentioned in _ready, show the node after seeking to the random start point in the animation
|
||||
show()
|
||||