mirror of
https://github.com/creyD/ludum_dare_46.git
synced 2026-06-14 06:22:22 +02:00
Initial project created
Added a simple basic template with a player control script and basic collision detection. Ideal coding style guidelines enforced.
This commit is contained in:
36
src/Player/Player.gd
Normal file
36
src/Player/Player.gd
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
extends KinematicBody2D
|
||||||
|
class_name Player
|
||||||
|
"""
|
||||||
|
This is an example player controller script created by Paul
|
||||||
|
"""
|
||||||
|
var velocity := Vector2.ZERO
|
||||||
|
# This is how you export variables with ranges to the editor window
|
||||||
|
export(int, 0, 500) var MAX_SPEED = 125
|
||||||
|
export(int, 0, 500) var FRICTION = 200 # Speed at which the player deaccelarates
|
||||||
|
export(int, 0, 500) var ACCELERATION = 450
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
"""
|
||||||
|
Run approximately every 1/60th of a second by default.
|
||||||
|
@param delta, so the time since lastt frame, should be pretty constant at 1/60 by default.
|
||||||
|
"""
|
||||||
|
# If a constant is applicable, use it instead of creating the object yourself
|
||||||
|
var input_vector := Vector2.ZERO
|
||||||
|
# This is a clever way to handle directional input
|
||||||
|
# Input.get_action_strength(...) returns a value between 0 and 1 depending
|
||||||
|
# on how strong the controller direction is pressed
|
||||||
|
# For keyboards it always returns 1 if pressed and 0 if not
|
||||||
|
# The actions are custom and defined in the project settings
|
||||||
|
input_vector.x = Input.get_action_strength("right") - Input.get_action_strength("left")
|
||||||
|
input_vector.y = Input.get_action_strength("down") - Input.get_action_strength("up")
|
||||||
|
input_vector = input_vector.normalized()
|
||||||
|
|
||||||
|
if input_vector == Vector2.ZERO:
|
||||||
|
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
|
||||||
|
else:
|
||||||
|
velocity = velocity.move_toward(MAX_SPEED * input_vector, ACCELERATION * delta)
|
||||||
|
|
||||||
|
# IMPORTANT: If you are using move_and_slide don't multiply by delta
|
||||||
|
# Godots physics system does that internally
|
||||||
|
# In move_and_collide(...) you have to multiply by delta.
|
||||||
|
move_and_slide(velocity)
|
||||||
24
src/Player/Player.tscn
Normal file
24
src/Player/Player.tscn
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Player/Player.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://icon.png" type="Texture" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape2D" id=1]
|
||||||
|
radius = 6.0
|
||||||
|
height = 5.0
|
||||||
|
|
||||||
|
[node name="Player" type="KinematicBody2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_group_": true
|
||||||
|
}
|
||||||
|
FRICTION = 270
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
scale = Vector2( 0.5, 0.5 )
|
||||||
|
texture = ExtResource( 2 )
|
||||||
|
offset = Vector2( 0, -18 )
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
rotation = 1.5708
|
||||||
|
shape = SubResource( 1 )
|
||||||
13
src/World.tscn
Normal file
13
src/World.tscn
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1]
|
||||||
|
|
||||||
|
[node name="World" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Player" parent="." instance=ExtResource( 1 )]
|
||||||
|
position = Vector2( 164.844, 101.687 )
|
||||||
|
|
||||||
|
[node name="StaticBody2D" type="StaticBody2D" parent="."]
|
||||||
|
|
||||||
|
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
|
||||||
|
polygon = PoolVector2Array( 192.287, 146.593, 265.375, 115.213, 228.831, 67.1505, 257.43, 37.3594, 218.9, 7.9655, 298.343, 3.59614, 310.26, 179.959, 11.9516, 168.837, 42.9343, 30.6067, 69.1505, 118.788, 86.628, 87.4084, 96.5583, 127.527 )
|
||||||
7
src/default_env.tres
Normal file
7
src/default_env.tres
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[gd_resource type="Environment" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[sub_resource type="ProceduralSky" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
background_mode = 2
|
||||||
|
background_sky = SubResource( 1 )
|
||||||
BIN
src/icon.png
Normal file
BIN
src/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
34
src/icon.png.import
Normal file
34
src/icon.png.import
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://icon.png"
|
||||||
|
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=false
|
||||||
|
svg/scale=1.0
|
||||||
88
src/project.godot
Normal file
88
src/project.godot
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
; Engine configuration file.
|
||||||
|
; It's best edited using the editor UI and not directly,
|
||||||
|
; since the parameters that go here are not all obvious.
|
||||||
|
;
|
||||||
|
; Format:
|
||||||
|
; [section] ; section goes between []
|
||||||
|
; param=value ; assign values to parameters
|
||||||
|
|
||||||
|
config_version=4
|
||||||
|
|
||||||
|
_global_script_classes=[ {
|
||||||
|
"base": "KinematicBody2D",
|
||||||
|
"class": "Player",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://Player/Player.gd"
|
||||||
|
} ]
|
||||||
|
_global_script_class_icons={
|
||||||
|
"Player": ""
|
||||||
|
}
|
||||||
|
|
||||||
|
[application]
|
||||||
|
|
||||||
|
config/name="LD46 Game"
|
||||||
|
run/main_scene="res://World.tscn"
|
||||||
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/width=320
|
||||||
|
window/size/height=180
|
||||||
|
window/size/test_width=1280
|
||||||
|
window/size/test_height=720
|
||||||
|
window/stretch/mode="2d"
|
||||||
|
window/stretch/aspect="keep"
|
||||||
|
|
||||||
|
[importer_defaults]
|
||||||
|
|
||||||
|
texture={
|
||||||
|
"compress/bptc_ldr": 0,
|
||||||
|
"compress/hdr_mode": 0,
|
||||||
|
"compress/lossy_quality": 0.7,
|
||||||
|
"compress/mode": 0,
|
||||||
|
"compress/normal_map": 0,
|
||||||
|
"detect_3d": false,
|
||||||
|
"flags/anisotropic": false,
|
||||||
|
"flags/filter": false,
|
||||||
|
"flags/mipmaps": false,
|
||||||
|
"flags/repeat": 0,
|
||||||
|
"flags/srgb": 2,
|
||||||
|
"process/HDR_as_SRGB": false,
|
||||||
|
"process/fix_alpha_border": true,
|
||||||
|
"process/invert_color": false,
|
||||||
|
"process/premult_alpha": false,
|
||||||
|
"size_limit": 0,
|
||||||
|
"stream": false,
|
||||||
|
"svg/scale": 1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
[rendering]
|
||||||
|
|
||||||
|
environment/default_environment="res://default_env.tres"
|
||||||
Reference in New Issue
Block a user