This repository has been archived by the owner on Jan 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from MinusKelvin/client-rewrite
Client rewrite
- Loading branch information
Showing
82 changed files
with
1,077 additions
and
1,180 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
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
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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
[package] | ||
name = "gui" | ||
version = "0.1.0" | ||
authors = ["MinusKelvin <minuskelvin.carlson@gmail.com>"] | ||
authors = ["MinusKelvin <mark.carlson@minuskelvin.net>"] | ||
edition = "2018" | ||
default-run = "gui" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
arrayvec = "0.4.11" | ||
ggez = "0.5.1" | ||
game-util = { git = "https://github.com/MinusKelvin/game-util-rs" } | ||
cold-clear = { path = "../bot" } | ||
libtetris = { path = "../libtetris" } | ||
battle = { path = "../battle" } | ||
cold-clear = { path = "../bot" } | ||
serde = "1" | ||
bincode = "1" | ||
arrayvec = "0.4.11" | ||
rand = "0.7.3" | ||
gilrs = { version = "0.7.4", features = ["serde"] } | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_yaml = "0.8.11" | ||
bincode = "1.2" | ||
libflate = "0.1" | ||
serde_yaml = "0.8" | ||
rand = "0.7.0" | ||
rand_pcg = "0.2.0" | ||
enumset = "0.4.0" | ||
winit = { version = "0.19", features = ["serde"] } | ||
|
||
[build-dependencies] | ||
build-utils = { git = "https://github.com/MinusKelvin/game-util-rs" } |
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,6 @@ | ||
use std::env; | ||
use std::path::Path; | ||
|
||
fn main() { | ||
build_utils::gen_sprites("sprites", Path::new(&env::var("OUT_DIR").unwrap()), 1024); | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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,70 @@ | ||
use game_util::prelude::*; | ||
use battle::{ Battle, BattleUpdate }; | ||
use crate::player_draw::PlayerDrawState; | ||
use crate::res::Resources; | ||
|
||
pub struct BattleUi { | ||
player_1_graphics: PlayerDrawState, | ||
player_2_graphics: PlayerDrawState, | ||
time: u32 | ||
} | ||
|
||
impl BattleUi { | ||
pub fn new(battle: &Battle, p1_name: String, p2_name: String) -> Self { | ||
BattleUi { | ||
player_1_graphics: PlayerDrawState::new(battle.player_1.board.next_queue(), p1_name), | ||
player_2_graphics: PlayerDrawState::new(battle.player_2.board.next_queue(), p2_name), | ||
time: 0 | ||
} | ||
} | ||
|
||
pub fn update( | ||
&mut self, | ||
res: &mut Resources, | ||
update: BattleUpdate, | ||
p1_info_update: Option<cold_clear::Info>, | ||
p2_info_update: Option<cold_clear::Info> | ||
) { | ||
for event in update.player_1.events.iter().chain(update.player_2.events.iter()) { | ||
use battle::Event::*; | ||
match event { | ||
PieceMoved | SoftDropped | PieceRotated => { | ||
if res.move_sound_sink.len() <= 1 { | ||
res.move_sound_sink.append(res.move_sound.sound()); | ||
} | ||
} | ||
PiecePlaced { hard_drop_distance, locked, .. } => { | ||
if hard_drop_distance.is_some() { | ||
res.hard_drop.play(); | ||
} | ||
if locked.placement_kind.is_clear() { | ||
res.line_clear.play(); | ||
} | ||
} | ||
_ => {} | ||
} | ||
} | ||
|
||
self.player_1_graphics.update(update.player_1, p1_info_update, update.time); | ||
self.player_2_graphics.update(update.player_2, p2_info_update, update.time); | ||
self.time = update.time; | ||
} | ||
|
||
pub fn draw(&self, res: &mut Resources) { | ||
res.text.draw_text( | ||
&format!("{}:{:02}", self.time / 60 / 60, self.time / 60 % 60), | ||
20.0, 1.5, | ||
game_util::Alignment::Center, | ||
[0xFF; 4], 1.0, 0 | ||
); | ||
|
||
self.player_1_graphics.draw(res, 0.0+1.0); | ||
self.player_2_graphics.draw(res, 20.0+1.0); | ||
|
||
res.sprite_batch.render(Transform3D::ortho( | ||
0.0, 40.0, | ||
0.0, 23.0, | ||
-1.0, 1.0 | ||
)); | ||
} | ||
} |
Oops, something went wrong.