Skip to content

Commit

Permalink
Add multi palette support
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariasteam committed Jul 23, 2018
1 parent 85f7846 commit 74ca786
Show file tree
Hide file tree
Showing 11 changed files with 226 additions and 59 deletions.
39 changes: 39 additions & 0 deletions Materials/mat_column.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[gd_resource type="FixedMaterial" format=1]

[resource]

flags/visible = true
flags/double_sided = false
flags/invert_faces = false
flags/unshaded = false
flags/on_top = false
flags/lightmap_on_uv2 = true
flags/colarray_is_srgb = true
params/blend_mode = 0
params/depth_draw = 1
params/line_width = 4.34635e-31
fixed_flags/use_alpha = false
fixed_flags/use_color_array = false
fixed_flags/use_point_size = false
fixed_flags/discard_alpha = false
fixed_flags/use_xy_normalmap = false
params/diffuse = Color( 1, 1, 1, 1 )
params/specular = Color( 0, 0, 0, 1 )
params/emission = Color( 0, 0, 0, 1 )
params/specular_exp = 40
params/detail_mix = 1.0
params/normal_depth = 1
params/shader = 0
params/shader_param = 0.5
params/glow = 0
params/point_size = 1.0
uv_xform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
textures/diffuse_tc = 0
textures/detail_tc = 0
textures/specular_tc = 0
textures/emission_tc = 0
textures/specular_exp_tc = 0
textures/glow_tc = 0
textures/normal_tc = 0
textures/shade_param_tc = 0

39 changes: 39 additions & 0 deletions Materials/mat_player.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[gd_resource type="FixedMaterial" format=1]

[resource]

flags/visible = true
flags/double_sided = false
flags/invert_faces = false
flags/unshaded = false
flags/on_top = false
flags/lightmap_on_uv2 = true
flags/colarray_is_srgb = true
params/blend_mode = 0
params/depth_draw = 1
params/line_width = 4.34635e-31
fixed_flags/use_alpha = false
fixed_flags/use_color_array = false
fixed_flags/use_point_size = false
fixed_flags/discard_alpha = false
fixed_flags/use_xy_normalmap = false
params/diffuse = Color( 1, 1, 1, 1 )
params/specular = Color( 0, 0, 0, 1 )
params/emission = Color( 0, 0, 0, 1 )
params/specular_exp = 40
params/detail_mix = 1.0
params/normal_depth = 1
params/shader = 0
params/shader_param = 0.5
params/glow = 0
params/point_size = 1.0
uv_xform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
textures/diffuse_tc = 0
textures/detail_tc = 0
textures/specular_tc = 0
textures/emission_tc = 0
textures/specular_exp_tc = 0
textures/glow_tc = 0
textures/normal_tc = 0
textures/shade_param_tc = 0

39 changes: 39 additions & 0 deletions Materials/mat_segment_bad.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[gd_resource type="FixedMaterial" format=1]

[resource]

flags/visible = true
flags/double_sided = false
flags/invert_faces = false
flags/unshaded = false
flags/on_top = false
flags/lightmap_on_uv2 = true
flags/colarray_is_srgb = true
params/blend_mode = 0
params/depth_draw = 1
params/line_width = 4.34635e-31
fixed_flags/use_alpha = false
fixed_flags/use_color_array = false
fixed_flags/use_point_size = false
fixed_flags/discard_alpha = false
fixed_flags/use_xy_normalmap = false
params/diffuse = Color( 1, 1, 1, 1 )
params/specular = Color( 0, 0, 0, 1 )
params/emission = Color( 0, 0, 0, 1 )
params/specular_exp = 40
params/detail_mix = 1.0
params/normal_depth = 1
params/shader = 0
params/shader_param = 0.5
params/glow = 0
params/point_size = 1.0
uv_xform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
textures/diffuse_tc = 0
textures/detail_tc = 0
textures/specular_tc = 0
textures/emission_tc = 0
textures/specular_exp_tc = 0
textures/glow_tc = 0
textures/normal_tc = 0
textures/shade_param_tc = 0

39 changes: 39 additions & 0 deletions Materials/mat_segment_regular.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[gd_resource type="FixedMaterial" format=1]

[resource]

flags/visible = true
flags/double_sided = false
flags/invert_faces = false
flags/unshaded = false
flags/on_top = false
flags/lightmap_on_uv2 = true
flags/colarray_is_srgb = true
params/blend_mode = 0
params/depth_draw = 1
params/line_width = 4.34635e-31
fixed_flags/use_alpha = false
fixed_flags/use_color_array = false
fixed_flags/use_point_size = false
fixed_flags/discard_alpha = false
fixed_flags/use_xy_normalmap = false
params/diffuse = Color( 1, 1, 1, 1 )
params/specular = Color( 0, 0, 0, 1 )
params/emission = Color( 0, 0, 0, 1 )
params/specular_exp = 40
params/detail_mix = 1.0
params/normal_depth = 1
params/shader = 0
params/shader_param = 0.5
params/glow = 0
params/point_size = 1.0
uv_xform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
textures/diffuse_tc = 0
textures/detail_tc = 0
textures/specular_tc = 0
textures/emission_tc = 0
textures/specular_exp_tc = 0
textures/glow_tc = 0
textures/normal_tc = 0
textures/shade_param_tc = 0

22 changes: 6 additions & 16 deletions Scenes/Column.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[gd_scene load_steps=7 format=1]

[ext_resource path="res://Scenes/Column.gd" type="Script" id=1]
[ext_resource path="res://configs.gd" type="Script" id=2]
[ext_resource path="res://Scenes/Player.tscn" type="PackedScene" id=3]
[ext_resource path="res://platforms_deployer.gd" type="Script" id=4]
[ext_resource path="res://Scenes/Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://platforms_deployer.gd" type="Script" id=3]
[ext_resource path="res://Materials/mat_column.tres" type="Material" id=4]
[ext_resource path="res://Mesh/column.msh" type="Mesh" id=5]
[ext_resource path="res://Scenes/PowerUP.tscn" type="PackedScene" id=6]

Expand All @@ -12,24 +12,14 @@
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
script/script = ExtResource( 1 )

[node name="Configs" type="Spatial" parent="."]

_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
script/script = ExtResource( 2 )
color_regular = Color( 0.811412, 0.656281, 0.898438, 1 )
color_bad = Color( 0.996094, 0.256805, 0.534039, 1 )
color_column = Color( 0.67526, 0.360626, 0.789062, 1 )
color_player = Color( 0.390375, 0.894531, 0.0454254, 1 )
color_power_up_1 = Color( 0.179443, 0.74521, 0.820312, 1 )

[node name="Player" parent="." instance=ExtResource( 3 )]
[node name="Player" parent="." instance=ExtResource( 2 )]

transform/local = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6.27751, 0 )

[node name="Axis" type="Spatial" parent="."]

_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
script/script = ExtResource( 4 )
script/script = ExtResource( 3 )
space = 7
n_platforms = 30

Expand All @@ -39,7 +29,7 @@ _import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 2.55, 0, 0, 0, 1, 0, 0, 0, 2.55, 0, -105, 0 )
layers = 1
geometry/visible = true
geometry/material_override = null
geometry/material_override = ExtResource( 4 )
geometry/cast_shadow = 0
geometry/receive_shadows = false
geometry/range_begin = 0.0
Expand Down
22 changes: 11 additions & 11 deletions Scenes/Player.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[gd_scene load_steps=13 format=1]
[gd_scene load_steps=14 format=1]

[ext_resource path="res://Scenes/Player.gd" type="Script" id=1]
[ext_resource path="res://Materials/particle.tres" type="Material" id=2]
[ext_resource path="res://Mesh/ball.msh" type="Mesh" id=3]
[ext_resource path="res://Sound/jump.ogg" type="AudioStream" id=4]
[ext_resource path="res://Sound/die.ogg" type="AudioStream" id=5]
[ext_resource path="res://Sound/acceleration.ogg" type="AudioStream" id=6]
[ext_resource path="res://Materials/mat_player.tres" type="Material" id=3]
[ext_resource path="res://Mesh/ball.msh" type="Mesh" id=4]
[ext_resource path="res://Sound/jump.ogg" type="AudioStream" id=5]
[ext_resource path="res://Sound/die.ogg" type="AudioStream" id=6]
[ext_resource path="res://Sound/acceleration.ogg" type="AudioStream" id=7]

[sub_resource type="BoxShape" id=1]

Expand Down Expand Up @@ -141,7 +142,6 @@ _import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )

[node name="Group" type="Spatial" parent="RigidBody/Axis"]

editor/display_folded = true
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0.10596 )

Expand Down Expand Up @@ -584,7 +584,7 @@ _import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 0.675, 0, 0, 0, 0.65, 0, 0, 0, 0.675, 0, 0, 7.95683 )
layers = 1
geometry/visible = true
geometry/material_override = null
geometry/material_override = ExtResource( 3 )
geometry/cast_shadow = 1
geometry/receive_shadows = true
geometry/range_begin = 0.0
Expand All @@ -596,7 +596,7 @@ geometry/depth_scale = false
geometry/visible_in_all_rooms = false
geometry/use_baked_light = false
geometry/baked_light_tex_id = 0
mesh/mesh = ExtResource( 3 )
mesh/mesh = ExtResource( 4 )
mesh/skeleton = NodePath("..")
material/0 = null

Expand Down Expand Up @@ -651,7 +651,7 @@ autostart = false

[node name="JumpSound" type="StreamPlayer" parent="."]

stream/stream = ExtResource( 4 )
stream/stream = ExtResource( 5 )
stream/play = false
stream/loop = false
stream/volume_db = 10.0
Expand All @@ -662,7 +662,7 @@ stream/buffering_ms = 500

[node name="DieSound" type="StreamPlayer" parent="."]

stream/stream = ExtResource( 5 )
stream/stream = ExtResource( 6 )
stream/play = false
stream/loop = false
stream/volume_db = 11.0
Expand All @@ -673,7 +673,7 @@ stream/buffering_ms = 500

[node name="AccelerationSound" type="StreamPlayer" parent="."]

stream/stream = ExtResource( 6 )
stream/stream = ExtResource( 7 )
stream/play = false
stream/loop = false
stream/volume_db = 10.0
Expand Down
2 changes: 1 addition & 1 deletion Scenes/PowerUP.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ extends Spatial
# var b = "textvar"

func _ready():
return
var color = global.mat_power_up_1.get_parameter(FixedMaterial.PARAM_DIFFUSE)
get_node("Particles").get_material().set_parameter(FixedMaterial.PARAM_DIFFUSE, color)



func _on_Area_area_enter( area ):
OS.set_time_scale(0.4)
get_tree().get_nodes_in_group("player")[0].power_up()
Expand Down
2 changes: 1 addition & 1 deletion Scenes/end_line.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ func meteorize():
pass

func _on_Timer_timeout():
global.handl_win()
global.handle_win()
24 changes: 0 additions & 24 deletions configs.gd

This file was deleted.

41 changes: 35 additions & 6 deletions global.gd
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
extends Node

var mat_bad
var mat_regular
var mat_column
var mat_player
var mat_bad = preload("res://Materials/mat_segment_bad.tres")
var mat_regular = preload("res://Materials/mat_segment_regular.tres")
var mat_column = preload("res://Materials/mat_column.tres")
var mat_player = preload("res://Materials/mat_player.tres")
var mat_power_up_1

var environment_palette = []
var current_palette

var player

var player_color = []
Expand All @@ -20,8 +23,15 @@ var level = 0
signal update_points_viewer
signal update_progress

func apply_random_palette():
randomize()
current_palette = environment_palette[randi() % environment_palette.size()]
mat_regular.set_parameter(FixedMaterial.PARAM_DIFFUSE, Color(current_palette[0]))
mat_bad.set_parameter(FixedMaterial.PARAM_DIFFUSE, Color(current_palette[1]))
mat_column.set_parameter(FixedMaterial.PARAM_DIFFUSE, Color(current_palette[2]))

func handl_win():
func handle_win():
apply_random_palette()
level += 1
progress = 0
total_points += current_points
Expand Down Expand Up @@ -58,15 +68,34 @@ func save_game():

func _ready():
load_game()
load_palette()
apply_random_palette()

func load_palette():
var palette = File.new()
if !palette.file_exists("res://palette.json"):
return #Error

var content = {}
palette.open("res://palette.json", File.READ)
content.parse_json(palette.get_as_text())
palette.close()

for element in content["environment"]:
environment_palette.push_back(element)

mat_player.set_parameter(FixedMaterial.PARAM_DIFFUSE, Color(content["player"]))



func load_game():
var savegame = File.new()
if !savegame.file_exists("user://savegame.save"):
return #Error! We don't have a save to load

var currentline = {}
savegame.open("user://savegame.save", File.READ)
currentline.parse_json(savegame.get_line())
currentline.parse_json(savegame.get_line())
total_points = currentline["total_points"]
level = currentline["level"]
savegame.close()
Expand Down
Loading

0 comments on commit 74ca786

Please sign in to comment.