-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
b0da719
commit e80df51
Showing
11 changed files
with
154 additions
and
460 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ mod gameoflife; | |
mod tetris; | ||
mod asteroids; | ||
mod crystalrpg; | ||
mod pong; |
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,57 @@ | ||
use alloc::boxed::Box; | ||
use alloc::string::String; | ||
use alloc::vec::Vec; | ||
use async_trait::async_trait; | ||
use core::fmt::Write; | ||
use crate::std::application::{Application, Error}; | ||
use crate::std; | ||
|
||
struct Game { | ||
ball: Ball, | ||
player1: Player, | ||
player2: Player, | ||
} | ||
|
||
#[async_trait] | ||
impl Application for Game { | ||
fn new() -> Self { | ||
Game { | ||
ball: Ball::new(), | ||
player1: Player::new(1), | ||
player2: Player::new(2), | ||
} | ||
} | ||
|
||
async fn run(&mut self, _: Vec<String>) -> Result<(), Error> { | ||
loop { | ||
self.ball.update(&self.player1, &self.player2); | ||
} | ||
Ok(()) | ||
} | ||
} | ||
|
||
struct Player { | ||
x: i32, | ||
y: i32, | ||
score: i32, | ||
} | ||
|
||
impl Player { | ||
fn new(y: i32) -> Self { | ||
Player { x: 0, y, score: 0 } | ||
} | ||
} | ||
|
||
struct Ball { | ||
x: i32, | ||
y: i32, | ||
} | ||
|
||
impl Ball { | ||
fn new() -> Self { | ||
Ball { x: 0, y: 0 } | ||
} | ||
fn update(&mut self, player1: &Player, player2: &Player) { | ||
self.x += 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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use crate::std::frame::{ColouredChar, Dimensions, Frame, Position}; | ||
|
||
pub(crate) fn render_outline(frame: &mut Frame, dimensions: Dimensions) { | ||
// draws the sides of the container | ||
for i in 0..frame.dimensions.x { | ||
frame.write(Position::new(i, 0), ColouredChar::new('─')); | ||
frame.write(Position::new(i, frame.dimensions.y - 1), ColouredChar::new('─')); | ||
} | ||
|
||
// draws the top and bottom of the container | ||
for i in 0..frame.dimensions.y { | ||
frame.write(Position::new(0, i), ColouredChar::new('│')); | ||
frame.write(Position::new(frame.dimensions.x - 1, i), ColouredChar::new('│')); | ||
} | ||
|
||
// draws the corners of the container | ||
frame.write(Position::new(0, 0), ColouredChar::new('┌')); | ||
frame.write(Position::new(dimensions.x - 1, 0), ColouredChar::new('┐')); | ||
frame.write(Position::new(0, dimensions.y - 1), ColouredChar::new('└')); | ||
frame.write(Position::new(dimensions.x - 1, dimensions.y - 1), ColouredChar::new('┘')); | ||
} |
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,4 +1,5 @@ | ||
pub mod cg_core; | ||
pub mod cg_widgets; | ||
pub mod cg_inputs; | ||
mod cg_utils; | ||
|
Oops, something went wrong.