Skip to content

Commit

Permalink
Version 0.0.2 stable
Browse files Browse the repository at this point in the history
This was a refactoring release:
+ Rename Captain's Log to Database
+ Revamp the menu scene
+ Add Loading Scene for loading game map
+ Add crossfade effect transitions
+ Make generated maps create JSON, then load as if it was a save
+ Revised card creation process (no code involved)
+ Added game version info
  • Loading branch information
Kazuo256 committed Sep 22, 2016
2 parents 5295ddb + 2172f74 commit bd9a82e
Show file tree
Hide file tree
Showing 41 changed files with 700 additions and 239 deletions.
4 changes: 4 additions & 0 deletions assets/bodies/dummy/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"height": 1,
"offset": {"x": 0, "y": -32}
}
4 changes: 4 additions & 0 deletions assets/bodies/eye/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"height": 1,
"offset": {"x": 0, "y": -32}
}
4 changes: 4 additions & 0 deletions assets/bodies/froggy/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"height": 0,
"offset": {"x": 0, "y": -32}
}
4 changes: 4 additions & 0 deletions assets/bodies/hero/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"height": 1,
"offset": {"x": 0, "y": -32}
}
4 changes: 4 additions & 0 deletions assets/bodies/slime/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"height": 0,
"offset": {"x": 0, "y": -32}
}
4 changes: 4 additions & 0 deletions assets/bodies/thief/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"height": 1,
"offset": {"x": 0, "y": -32}
}
Binary file added assets/menu_cursor.ase
Binary file not shown.
Binary file added assets/menu_cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 55 additions & 17 deletions components/bodyview.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,81 @@
extends Node2D

const BodyViewScene = preload("res://components/bodyview.tscn")
const IO = preload("res://components/util/io.gd")

const LEFT = false
const RIGHT = true

const LIFEBAR_HEIGHT_SMALL = Vector2(-16, -48)
const LIFEBAR_HEIGHT_MEDIUM = Vector2(-16, -64)
const LIFEBAR_HEIGHT_TALL = Vector2(-16, -80)

var body

onready var sprite = get_node("Sprite")
onready var animation = get_node("Sprite/Animation")
onready var lifebar = get_node("Sprite/LifeBar")
onready var hl_indicator = get_node("Highlight")
var dir = LEFT
var metadata = {}

export(bool) var highlight = false

static func create(body):
var bodyview = BodyViewScene.instance()
bodyview.body = body
return bodyview
var bodyview = BodyViewScene.instance()
bodyview.body = body
return bodyview

func _ready():
sprite.set_texture(load("res://assets/bodies/" + body.type + "/idle.png"))
animation.play("idle")
set_process(true)
metadata.parse_json(IO.get_file_as_text("res://assets/bodies/" + body.type + "/meta.json"))
sprite.set_texture(load("res://assets/bodies/" + body.type + "/idle.png"))
animation.play("idle")
init_metadata()
set_process(true)

func init_metadata():
# this function gets the bodyview's metadata in json and applies it to the bodyview's nodes.
if metadata.has("height"):
if metadata.height == 0:
get_node("Sprite/LifeBar").set_pos(LIFEBAR_HEIGHT_SMALL)
elif metadata.height == 1:
get_node("Sprite/LifeBar").set_pos(LIFEBAR_HEIGHT_MEDIUM)
elif metadata.height == 2:
get_node("Sprite/LifeBar").set_pos(LIFEBAR_HEIGHT_TALL)
if metadata.has("offset"):
get_node("Sprite").set_offset(Vector2(metadata.offset.x, metadata.offset.y))

func highlight():
highlight = true
update_hl()
highlight = true
update_hl()

func unhighlight():
highlight = false
update_hl()
highlight = false
update_hl()

func set_hl_color(color):
get_node("Highlight").set_modulate(color)
get_node("Highlight").set_modulate(color)

func update_hl():
if highlight:
get_node("Highlight").show()
else:
get_node("Highlight").hide()
if highlight:
get_node("Highlight").show()
else:
get_node("Highlight").hide()

func set_dir(current_pos, new_pos):
var dir_vec = new_pos - current_pos
if dir_vec.x - dir_vec.y < 0:
turn_left()
else:
turn_right()

func turn_right():
dir = RIGHT

func turn_left():
dir = LEFT

func _process(delta):
set_pos(get_parent().map_to_world(body.pos) + Vector2(0, 16 - 1))
lifebar.set_value(body.get_hp_percent())
set_pos(get_parent().map_to_world(body.pos) + Vector2(0, 16 - 1))
lifebar.set_value(body.get_hp_percent())
sprite.set_flip_h(dir)
4 changes: 2 additions & 2 deletions components/bodyview.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 0
margin/left = 48.0
margin/top = -0.84375
margin/top = -0.833333
margin/right = -80.0
margin/bottom = 113.0
margin/bottom = 112.0
custom_styles/fg = SubResource( 1 )
range/min = 0.0
range/max = 100.0
Expand Down
2 changes: 1 addition & 1 deletion components/controller/default_controller.gd
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func consume_input_key(event):
return

func event_cancel():
get_node("/root/captains_log").finish()
get_node("/root/database").finish()
get_tree().quit()

func event_toggle_fullscreen():
Expand Down
9 changes: 7 additions & 2 deletions components/controller/main_controller.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ var hand
var display_popup
var upgrades_popup

func _ready():
self.disable()

func event_save():
get_node("/root/captains_log/scene_manager").close_route()
get_node("/root/database/scene_manager").close_route()
self.disable()

func event_idle():
player.add_action(Action.Idle.new())
Expand Down Expand Up @@ -41,13 +45,14 @@ func set_player_map(player, hand):
self.hand = hand
display_popup = get_node("../CardDisplay")
upgrades_popup = get_node("../UpgradesDisplay")
call_deferred("enable")

func event_next_sector():
player.add_action(Action.ChangeSector.new(1))

func event_create_slime():
var map = get_node("../../map")
var monsters = get_node("/root/captains_log/monsters").get_children()
var monsters = get_node("/root/database/monsters").get_children()
monsters[randi()%monsters.size()].create(map, map.get_random_free_pos())

func event_display_card():
Expand Down
51 changes: 51 additions & 0 deletions components/controller/menu_controller.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

extends "res://components/controller/default_controller.gd"

const COLOR_SELECTED = Color(234.0/255,166.0/255,81.0/255)
const COLOR_UNSELECTED = Color(1,1,1)

var choice
var choice_list_size
var cursor
var saves_node

onready var menu = get_parent()

func _ready():
choice = 1 # default to new route choice
self.disable()

func setup():
saves_node = menu.saves_node
cursor = saves_node.get_node("cursor")
cursor.show()
choice_list_size = saves_node.get_child_count() - 1
self.enable()
self.update_choice()

func update_choice():
# updates cursor position
# should play a sfx eventually too
cursor.set_pos(Vector2(-32, ((choice-1) * 32) - 4))
print(saves_node.get_child(choice))
for btn in saves_node.get_children():
if btn != cursor:
if btn == saves_node.get_child(choice):
btn.add_color_override("font_color", COLOR_SELECTED)
else:
btn.add_color_override("font_color", COLOR_UNSELECTED)

func event_up():
choice = ((choice + choice_list_size - 2) % choice_list_size) + 1
update_choice()

func event_down():
choice = (choice % choice_list_size) + 1
update_choice()

func event_select():
var selection = saves_node.get_child(choice)
assert(selection != cursor) # redundant check yay
self.disable()
cursor.hide()
selection.emit_signal("selected")
25 changes: 9 additions & 16 deletions components/theme/wilokai.tres
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_resource type="Theme" load_steps=7 format=1]
[gd_resource type="Theme" load_steps=6 format=1]

[ext_resource path="res://assets/fonts/PressStart2P-8pt.fnt" type="BitmapFont" id=1]

Expand Down Expand Up @@ -30,24 +30,17 @@ content_margin/right = -1.0
content_margin/top = -1.0
content_margin/bottom = -1.0

[sub_resource type="StyleBoxEmpty" id=5]

content_margin/left = -1.0
content_margin/right = -1.0
content_margin/top = -1.0
content_margin/bottom = -1.0

[resource]

Button/colors/font_color = Color( 0.678431, 0.513726, 0.313726, 1 )
Button/colors/font_color = Color( 1, 1, 1, 1 )
Button/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
Button/colors/font_color_hover = Color( 0.941176, 0.941176, 0.941176, 1 )
Button/colors/font_color_pressed = Color( 1, 1, 1, 1 )
Button/constants/hseparation = 2
Button/colors/font_color_hover = Color( 0.917969, 0.651098, 0.319138, 1 )
Button/colors/font_color_pressed = Color( 0.882353, 0.623529, 0.305882, 0.960784 )
Button/constants/hseparation = 8
Button/fonts/font = ExtResource( 1 )
Button/styles/disabled = SubResource( 1 )
Button/styles/focus = SubResource( 2 )
Button/styles/hover = SubResource( 3 )
Button/styles/normal = SubResource( 4 )
Button/styles/pressed = SubResource( 5 )
Button/styles/focus = null
Button/styles/hover = SubResource( 2 )
Button/styles/normal = SubResource( 3 )
Button/styles/pressed = SubResource( 4 )

25 changes: 18 additions & 7 deletions components/ui/save-button.tscn
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
[gd_scene load_steps=2 format=1]
[gd_scene load_steps=3 format=1]

[ext_resource path="res://assets/fonts/PressStart2P-small.fnt" type="Font" id=1]
[ext_resource path="res://assets/fonts/PressStart2P-small.fnt" type="BitmapFont" id=1]

[node name="menu_button" type="Button"]
[sub_resource type="GDScript" id=1]

margin/right = 12.0
margin/bottom = 19.0
script/source = "\nextends Label\n\nsignal selected(info)\n"

[node name="menu_button" type="Label"]

rect/min_size = Vector2( 0, 28 )
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 0.0
margin/top = 0.0
margin/right = 256.0
margin/bottom = 35.0
custom_fonts/font = ExtResource( 1 )
toggle_mode = false
flat = false
text = "load file"
valign = 1
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = 1
script/script = SubResource( 1 )


10 changes: 10 additions & 0 deletions components/util/io.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

extends Object

static func get_file_as_text(filepath):
var datafile = File.new()
var datatext
datafile.open(filepath, File.READ)
datatext = datafile.get_as_text()
datafile.close()
return datatext
4 changes: 2 additions & 2 deletions components/util/mapgen/map_generator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ var PIPELINE = [
func _ready():
pass

func generate_map(id,w,h):
func generate_map(w,h,assembler):
var map = MapGrid.new(w,h, Step.WALL)
for step in PIPELINE:
map = map.apply_step(step)
return map.export_scene(id)
return map.export_scene(assembler)
19 changes: 11 additions & 8 deletions components/util/mapgen/map_grid.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ func set_tile(i, j, value):
func apply_step(step):
return step.apply(map_, width_, height_)

func export_scene(id):
var map_node = MapScene.create(id, width_, height_)
var floors = map_node.get_node("floors")
var walls = map_node.get_node("walls")
func export_scene(assembler):
var floors = []
var walls = []
floors.resize(width_ * height_)
walls.resize(width_ * height_)
for i in range(width_):
for j in range(height_):
walls.set_cell(j, i, map_[i][j])
if map_[i][j] != Step.WALL:
floors.set_cell(j, i, 0)
return map_node
walls[i*width_ + j] = map_[j][i]
if map_[j][i] != Step.WALL:
floors[i*width_ + j] = 0
else:
floors[i*width_ + j] = -1
assembler.set_sector_map(floors, walls, width_, height_)
Loading

0 comments on commit bd9a82e

Please sign in to comment.