-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e9d8b48
Showing
11 changed files
with
388 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Game Off 2020 | ||
|
||
Game Off 2020 | ||
|
||
**Theme:** Moonshot | ||
|
||
**Engine:** Godot | ||
|
||
**Author:** @scyq | ||
|
||
## Description | ||
|
||
Use your wisdom to control your brick fleet and hit the moon more times. | ||
Bricks have health, and the durability of bricks is not unlimited. | ||
Death does not mean failure, hitting the moon is our ultimate goal. | ||
|
||
The v1.0 version only supports person-versus-person battles and local HTML5 versions. | ||
|
||
P1 uses the arrow to control the direction, right Shift to reorganize the bricks. | ||
|
||
P2 controls the direction through WASD, and the space bar reorganizes the bricks. | ||
|
||
Play on Link [From itch.io](https://scyq.itch.io/shoot-the-moon) | ||
|
||
## How to play on Local | ||
|
||
Download the html.zip on itch first. | ||
|
||
1. If you have Python3 | ||
|
||
1. Open your terminal (mac and linux) or cmd(windows) and input command next | ||
|
||
2. ```shell | ||
python -m http.server 8000 --bind 127.0.0.1 | ||
``` | ||
|
||
3. Open your browser, open `http://localhost:8000` and play! | ||
|
||
2. If you have Node.js | ||
|
||
1. Open your terminal (mac and linux) or cmd(windows) | ||
|
||
2. ```shell | ||
http-server | ||
``` | ||
|
||
3. Open your browser, open the local-server (default is ``http://localhost:8080``) and play! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
extends RigidBody2D | ||
|
||
export var velocity = 1200 | ||
var collider_normal | ||
|
||
# -1 - wall and others | ||
# 0 - P1 | ||
# 1 - P2 / CPU | ||
var last_hit = -1 | ||
|
||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
# get random start direction | ||
randomize() | ||
var start_v = Vector2(randi(), randi()) | ||
for i in range(2): | ||
var dir = randi() % 2 | ||
print(dir) | ||
if dir == 0: | ||
dir = 1 | ||
else: | ||
dir = -1 | ||
start_v[i] *= dir | ||
linear_velocity = start_v.normalized() * velocity | ||
|
||
# warning-ignore:unused_argument | ||
func _physics_process(delta): | ||
linear_velocity = linear_velocity.normalized() * velocity | ||
|
||
|
||
|
||
func _on_Ball_body_entered(body): | ||
# hit the brick | ||
if body.has_method("handle_hit"): | ||
last_hit = body.handle_hit() | ||
$hit_brick.play() | ||
# hit moon | ||
elif body.has_method("update_scores"): | ||
body.update_scores(last_hit) | ||
# hit others | ||
else: | ||
$hit_other.play() | ||
|
||
|
||
|
||
|
||
# linear_velocity = linear_velocity.bounce(body.get_collider().get_normal()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
extends KinematicBody2D | ||
|
||
|
||
var screen_size = Vector2() | ||
var direction | ||
var motion | ||
export var speed = 400 | ||
export var life = 4 | ||
|
||
var color_set = [0, "aec8f8", "6995e8", "1755ca", "00308b"] | ||
|
||
|
||
func get_input(): | ||
var up = Input.is_action_pressed("p1_up") | ||
var down = Input.is_action_pressed("p1_down") | ||
if up: | ||
direction[1] = -1 | ||
elif down: | ||
direction[1] = 1 | ||
else: | ||
direction[1] = 0 | ||
var left = Input.is_action_pressed("p1_left") | ||
var right = Input.is_action_pressed("p1_right") | ||
if left: | ||
direction[0] = -1 | ||
elif right: | ||
direction[0] = 1 | ||
else: | ||
direction[0] = 0 | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
direction = Vector2() | ||
screen_size = get_viewport_rect().size | ||
modulate.a = 1 | ||
|
||
func _process(delta): | ||
pass | ||
|
||
func _physics_process(delta): | ||
get_input() | ||
motion = direction * speed * delta | ||
move_and_collide(motion) | ||
|
||
func handle_hit() -> int : | ||
life -= 1 | ||
modulate = color_set[life] | ||
if life <= 0: | ||
$free.play() | ||
$Boom.emitting = true | ||
queue_free() | ||
return 0 | ||
|
||
# Called every frame. 'delta' is the elapsed time since the previous frame. | ||
#func _process(delta): | ||
# pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
extends Node2D | ||
|
||
onready var controller | ||
var alive = true | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
controller = $"../Controller" | ||
pass # Replace with function body. | ||
|
||
func get_input(): | ||
if Input.is_action_pressed("p1_unity"): | ||
var children = get_children() | ||
var center = children[0] | ||
var life_sum = 0 | ||
for i in range (1, len(children)): | ||
var kid = children[i] | ||
life_sum += kid.life | ||
kid.queue_free() | ||
center.life += life_sum | ||
|
||
func _process(delta): | ||
get_input() | ||
if alive: | ||
if get_child_count() <= 0: | ||
alive = false | ||
controller.game_over(0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
extends Control | ||
|
||
var color = [Color(0,0,255,1), Color(255,0,0,1)] | ||
var win = ["BLUE", "RED"] | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
pass # Replace with function body. | ||
|
||
|
||
# Called every frame. 'delta' is the elapsed time since the previous frame. | ||
#func _process(delta): | ||
# pass | ||
func end(winner : int): | ||
$Winner.text = win[winner] | ||
$Winner.add_color_override("font_color", color[winner]) | ||
$AnimationPlayer.play("ShowWinner") | ||
|
||
func _on_Button_pressed(): | ||
get_parent().get_tree().reload_current_scene() | ||
pass # Replace with function body. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
extends StaticBody2D | ||
|
||
onready var p1_board | ||
onready var p2_board | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
p1_board = $"../P1_Board" | ||
p2_board = $"../P2_Board" | ||
|
||
func update_scores(hitter : int): | ||
match hitter: | ||
0: | ||
p1_board.text = String(int(p1_board.text) + 1) | ||
1: | ||
p2_board.text = String(int(p2_board.text) + 1) | ||
$get_score.play() | ||
|
||
#func _process(delta): | ||
# pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
extends KinematicBody2D | ||
|
||
|
||
var screen_size = Vector2() | ||
var direction | ||
var motion | ||
export var speed = 400 | ||
export var life = 4 | ||
|
||
var color_set = [0, "ffcfcf", "e58787", "b73131", "8d0f0f"] | ||
|
||
|
||
func get_input(): | ||
var up = Input.is_action_pressed("p2_up") | ||
var down = Input.is_action_pressed("p2_down") | ||
if up: | ||
direction[1] = -1 | ||
elif down: | ||
direction[1] = 1 | ||
else: | ||
direction[1] = 0 | ||
var left = Input.is_action_pressed("p2_left") | ||
var right = Input.is_action_pressed("p2_right") | ||
if left: | ||
direction[0] = -1 | ||
elif right: | ||
direction[0] = 1 | ||
else: | ||
direction[0] = 0 | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
direction = Vector2() | ||
screen_size = get_viewport_rect().size | ||
modulate.a = 1 | ||
|
||
func _process(delta): | ||
pass | ||
|
||
func _physics_process(delta): | ||
get_input() | ||
motion = direction * speed * delta | ||
move_and_collide(motion) | ||
|
||
func handle_hit() -> int : | ||
life -= 1 | ||
modulate = color_set[life] | ||
if life <= 0: | ||
$free.play() | ||
$Boom.emitting = true | ||
queue_free() | ||
return 1 | ||
|
||
# Called every frame. 'delta' is the elapsed time since the previous frame. | ||
#func _process(delta): | ||
# pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
extends Node2D | ||
|
||
onready var controller | ||
|
||
var alive = true | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
controller = $"../Controller" | ||
pass # Replace with function body. | ||
|
||
|
||
func get_input(): | ||
if Input.is_action_pressed("p2_unity"): | ||
var children = get_children() | ||
var center = children[0] | ||
var life_sum = 0 | ||
for i in range (1, len(children)): | ||
var kid = children[i] | ||
life_sum += kid.life | ||
kid.queue_free() | ||
center.life += life_sum | ||
|
||
func _process(delta): | ||
get_input() | ||
if alive: | ||
if get_child_count() <= 0: | ||
alive = false | ||
controller.game_over(1) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
extends AudioStreamPlayer | ||
|
||
var bgm = preload("res://assets/sounds/bgm.wav") | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
play() | ||
|
||
|
||
# Called every frame. 'delta' is the elapsed time since the previous frame. | ||
#func _process(delta): | ||
# pass | ||
|
||
|
||
func _on_bgm_finished(): | ||
play() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
extends Node | ||
|
||
|
||
onready var p1_score = $"../P1_Board" | ||
onready var p2_score = $"../P2_Board" | ||
onready var end = $"../Control" | ||
var winner = -1 | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
pass # Replace with function body. | ||
|
||
func game_over(who_die : int): | ||
p1_score = int(p1_score.text) | ||
p2_score = int(p2_score.text) | ||
if p1_score > p2_score: | ||
winner = 0 | ||
elif p1_score < p2_score: | ||
winner = 1 | ||
# scores reach a tie | ||
else: | ||
if who_die == 0: | ||
winner = 1 | ||
else: | ||
winner = 0 | ||
end.end(winner) | ||
|
||
|
||
|
||
|
||
# Called every frame. 'delta' is the elapsed time since the previous frame. | ||
#func _process(delta): | ||
# pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
extends Control | ||
|
||
var classic_game = preload("res://nodes/main.tscn") | ||
|
||
# Declare member variables here. Examples: | ||
# var a = 2 | ||
# var b = "text" | ||
|
||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
$Begin/AnimationPlayer.play("ShowAuthor") | ||
|
||
|
||
# Called every frame. 'delta' is the elapsed time since the previous frame. | ||
#func _process(delta): | ||
# pass | ||
|
||
|
||
func _on_pvpButton_pressed(): | ||
$buttonAudio.play() | ||
pass # Replace with function body. | ||
|
||
|
||
func _on_buttonAudio_finished(): | ||
get_tree().change_scene_to(classic_game) | ||
|
||
|
||
func _on_Timer_timeout(): | ||
$Begin.visible = false | ||
$Other.visible = true | ||
pass # Replace with function body. |