Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea committed Dec 25, 2019
1 parent e88f7f3 commit 56c173a
Show file tree
Hide file tree
Showing 63 changed files with 2,542 additions and 0 deletions.
Binary file added assets/.DS_Store
Binary file not shown.
Binary file added assets/animations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions assets/animations.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/animations.png-214a16f24de20d007189dcc2a9bf9db8.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/animations.png"
dest_files=[ "res://.import/animations.png-214a16f24de20d007189dcc2a9bf9db8.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=true
svg/scale=1.0
Binary file added assets/china-background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions assets/china-background.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/china-background.png-ea13ee08935f30ecaffdfffcac060d8d.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/china-background.png"
dest_files=[ "res://.import/china-background.png-ea13ee08935f30ecaffdfffcac060d8d.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=true
svg/scale=1.0
Binary file added assets/shadows.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions assets/shadows.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/shadows.png-27b96f6e4ccc31dac1c426f608ab2879.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/shadows.png"
dest_files=[ "res://.import/shadows.png-27b96f6e4ccc31dac1c426f608ab2879.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=true
svg/scale=1.0
15 changes: 15 additions & 0 deletions default_bus_layout.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[gd_resource type="AudioBusLayout" format=2]

[resource]
bus/1/name = "music"
bus/1/solo = false
bus/1/mute = false
bus/1/bypass_fx = false
bus/1/volume_db = 0.0
bus/1/send = "Master"
bus/2/name = "sfx"
bus/2/solo = false
bus/2/mute = false
bus/2/bypass_fx = false
bus/2/volume_db = -23.3
bus/2/send = "Master"
7 changes: 7 additions & 0 deletions default_env.tres
Original file line number Diff line number Diff line change
@@ -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 )
69 changes: 69 additions & 0 deletions game.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
extends Node


#enum CONTROL_TYPE { CONTROL_MOUSE, CONTROL_GAMEPAD }
const CONTROL_GAMEPAD = 1
const GRAVITY = 1500
const TERMINAL_VELOCITY = 220
const FLOOR_Y = 142
const LIMIT_LEFT = 20
const LIMIT_RIGHT = 300

var player = null setget _set_player, _get_player
var main = null
var gamestate setget _set_gamestate
#===========================
func _set_player( v ):
player = weakref( v )
func _get_player():
if player == null: return null
return player.get_ref()
#===========================
func set_initial_gamestate():
gamestate = {
"cur_scene": ""
}
func _set_gamestate( v ):
gamestate = v
if main != null:
main.update_hud()
#===========================


func _ready():
#Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
self.pause_mode = PAUSE_MODE_PROCESS
set_initial_gamestate()
Engine.set_target_fps(Engine.get_iterations_per_second())

var songs = [preload( "res://music/titlesong.ogg" )]

var cursong = -1
func play_music( no ):
if main == null: return
if no == cursong: return
cursong = no
main.play_music( songs[no] )

#func _process(delta):
# if Input.is_action_pressed( "btn_quit" ):
# get_tree().quit()




#enum SFX { \
# SFX_PLAYER_SHOOT_1, \
# SFX_EXPLOSION_SMALL }
#const SFXS = [ \
# preload( "res://sfx/player_shoot_1.wav" ), \
# preload( "res://sfx/explosion_small.wav" ) ]
#
#
#func play_sfx( no, randompitch = true ):
# if main != null:
# if randompitch:
# main.get_node( "sfx" ).set_pitch( rand_range( -0.3, 0.3 ) + 1 )
# else:
# main.get_node( "sfx" ).set_pitch( 1 )
# main.get_node( "sfx" ).mplay( SFXS[no] )
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions icon.png.import
Original file line number Diff line number Diff line change
@@ -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=true
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=true
svg/scale=1.0
127 changes: 127 additions & 0 deletions main.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
extends Node2D

const FIRST_SCN = "res://scenes/scene_china.tscn"
const MENU_SCN = "res://scenes/scene_china.tscn"

func _ready():
game.main = self
#game.music = $music
call_deferred( "_first_screen" )

func _first_screen():
_load_scene( FIRST_SCN )

var load_state = 0
var cur_scn = ""
func _load_scene( scn ):
print( "Loading level: ", scn, " State: ", load_state )
#print( game.gamestate )
if load_state == 0:
#get_tree().paused = true
# set current scene
cur_scn = scn
# fade out
$fade_layer/fadeanim.play( "fade_out" )
load_state = 1
$loadtimer.set_wait_time( 0.3 )
$loadtimer.start()
elif load_state == 1:
# hide hud
# $hud_layer/hud.hide()
# clear current act
var children = $levels.get_children()
if not children.empty():
_disconnect_level( children[0] )
children[0].queue_free()
load_state = 2
$loadtimer.set_wait_time( 0.1 )
$loadtimer.start()
elif load_state == 2:
# load new act
var act = load( cur_scn ).instance()
$levels.add_child( act )
_connect_level( act )
#if act is preload( "res://levels/level.gd" ):
# $hud_layer/hud.show()

load_state = 3
$loadtimer.set_wait_time( 0.1 )
$loadtimer.start()
elif load_state == 3:
#show hud
"""
if cur_scn != MENU_SCN:
$hud_layer/hud.show()
$hud_layer/mouse.show()
else:
$hud_layer/mouse.hide()
#$hud_layer/hud.show()
"""
# fade in
$fade_layer/fadeanim.play( "fade_in" )
# play stuff
load_state = 4
$loadtimer.set_wait_time( 0.3 )
$loadtimer.start()
get_tree().paused = false
elif load_state == 4:
print( "finished loading" )
load_state = 0

func update_hud():
# $hud_layer/hud/coinmgr/coincount/coincount.text = "%d" % game.gamestate.coins
#if game.gamestate.coins > oldcoins:
# oldcoins = game.gamestate.coins
# $hud_layer/hud/coinget.play( "cycle" )
pass


func _on_loadtimer_timeout():
_load_scene( cur_scn )

func _connect_level( v ):
v.connect( "restart_level", self, "_restart_level" )
v.connect( "finished_level", self, "_finished_level" )
v.connect( "game_over", self, "_game_over" )

func _disconnect_level( v ):
v.disconnect( "restart_level", self, "_restart_level" )
v.disconnect( "finished_level", self, "_finished_level" )
v.disconnect( "game_over", self, "_game_over" )

func _restart_level():
_load_scene( cur_scn )

func _finished_level( nxt_scn):
_load_scene( nxt_scn )

func _game_over():
print( cur_scn, " ", MENU_SCN )
if cur_scn == MENU_SCN:
get_tree().quit()
else:
_load_scene( MENU_SCN )

var mstate = 0
var curmusic = null
func play_music( res ):
#print( " play music ", mstate )
#print( curmusic, " ", res )
match mstate:
0:
curmusic = res
mstate = 1
$music/musicfade.play( "fadeout" )
1:
#print( "STARTING MUSIC" )

$music.stream = curmusic
$music.play()
$music/musicfade.play( "fadein" )
mstate = 2
2:
mstate = 0


func _on_musicfade_animation_finished(anim_name):
play_music( null )
Loading

0 comments on commit 56c173a

Please sign in to comment.