This commit is contained in:
Robin Hübner 2017-07-29 16:49:55 +02:00
parent dadecd0b78
commit 9d620588a2
16 changed files with 131 additions and 10 deletions

1
.gitattributes vendored
View File

@ -4,3 +4,4 @@ icon.png filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text
*.mp3 filter=lfs diff=lfs merge=lfs -text
*.ogg filter=lfs diff=lfs merge=lfs -text
*.ase filter=lfs diff=lfs merge=lfs -text

9
Game.tscn Normal file
View File

@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=1]
[ext_resource path="res://Player.tscn" type="PackedScene" id=1]
[node name="Game" type="Node"]
[node name="Player" parent="." instance=ExtResource( 1 )]

7
GingerbreadMan.tscn Normal file
View File

@ -0,0 +1,7 @@
[gd_scene format=1]
[node name="GingerbreadMan" type="AnimatedSprite"]
animation = "default"

5
Menu.tscn Normal file
View File

@ -0,0 +1,5 @@
[gd_scene format=1]
[node name="Menu" type="Node"]

67
Player.gd Normal file
View File

@ -0,0 +1,67 @@
extends Node2D
var mov_direction = Vector2(1, 0)
var mov_speed = 128 # pixels per second
var cur_frame = 0
var cur_time_per_frame = 0.1
var cur_time = 0
var cur_moving = true
onready var sprite = get_node("Sprite")
func _ready():
set_fixed_process(true)
func _fixed_process(delta):
var mov_delta = Vector2(0, 0)
var mov_direction = Vector2(1, 0)
# move towards mouse
mov_direction = (get_viewport().get_mouse_pos() - get_global_pos()).normalized()
if Input.is_action_pressed("player_move_forwards") or Input.is_action_pressed("player_move_backwards") or Input.is_action_pressed("player_move_left") or Input.is_action_pressed("player_move_right"):
if Input.is_action_pressed("player_move_forwards"):
mov_delta.y -= 1 * (mov_speed * delta)
# mov_delta = mov_direction * (mov_speed * delta)
cur_moving = true
elif Input.is_action_pressed("player_move_backwards"):
# mov_delta = (-mov_direction) * (mov_speed * delta)
mov_delta.y += 1 * (mov_speed * delta)
cur_moving = true
if Input.is_action_pressed("player_move_left"):
mov_delta.x -= 1 * (mov_speed * delta)
cur_moving = true
elif Input.is_action_pressed("player_move_right"):
mov_delta.x += 1 * (mov_speed * delta)
cur_moving = true
else:
cur_moving = false
if Input.is_action_pressed("player_attack"):
pass
cur_time = cur_time + delta
if cur_moving and cur_frame != 6:
if cur_time > cur_time_per_frame:
cur_frame += 1
cur_time = 0
else:
if cur_moving:
cur_frame = 1
else:
cur_frame = 0
# set frame shit
sprite.set_frame(cur_frame)
sprite.set_rot(sprite.get_global_pos().angle_to_point(get_viewport().get_mouse_pos()))
# do teh moves
move_local_x(mov_delta.x)
move_local_y(mov_delta.y)
func _process(delta):
pass

17
Player.tscn Normal file
View File

@ -0,0 +1,17 @@
[gd_scene load_steps=3 format=1]
[ext_resource path="res://Player.gd" type="Script" id=1]
[ext_resource path="res://img/player.atex" type="Texture" id=2]
[node name="Player" type="Node2D"]
transform/scale = Vector2( 2, 2 )
script/script = ExtResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 2 )
hframes = 7
region_rect = Rect2( 0, 0, 32, 32 )

7
StarBoy.tscn Normal file
View File

@ -0,0 +1,7 @@
[gd_scene format=1]
[node name="StarBoy" type="AnimatedSprite"]
animation = "default"

View File

@ -1,14 +1,13 @@
; 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
[application]
name="ld-39"
main_scene="res://Game.tscn"
icon="res://icon.png"
[input]
player_move_forwards=[key(Up), key(W), jaxis(0, 2)]
player_move_backwards=[key(S), key(Down), jaxis(0, 3)]
player_attack=[mbutton(0, 1)]
player_move_left=[key(A), key(Left)]
player_move_right=[key(D), key(Right)]

BIN
img/player.atex Normal file

Binary file not shown.

BIN
img/tiles.atex Normal file

Binary file not shown.

BIN
img/tiles.tex Normal file

Binary file not shown.

BIN
raw/gingerbreadman.ase (Stored with Git LFS) Normal file

Binary file not shown.

BIN
raw/player.ase (Stored with Git LFS) Normal file

Binary file not shown.

BIN
raw/player.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

3
raw/tiles.ase Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3b1710693c102f83eab24c16193ad28c389ccb256e7e4c90daf152ff472bc34f
size 789

BIN
raw/tiles.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B