diff --git a/src/main.rs b/src/main.rs index 0f4dc30..1a00cf6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,20 +2,6 @@ use ggez::{Context, ContextBuilder, GameResult}; use ggez::graphics::{self, Color}; use ggez::event::{self, EventHandler}; -fn main() { - // Make a Context. - let (mut ctx, event_loop) = ContextBuilder::new("apruebo", "s1m7u and e-dt") - .build() - .expect("aieee, could not create ggez context!"); - - // Create an instance of your event handler. - // Usually, you should provide it with the Context object to - // use when setting your game up. - let apr = Apr::new(&mut ctx); - - // Run! - event::run(ctx, event_loop, apr); -} struct Apr { // Your state here... @@ -28,10 +14,36 @@ impl Apr { // ... } } + + fn make_grid(&self, ctx : &mut Context, r: i32, c: i32) -> GameResult<()> { + let start_x : f32 = 20.0; + let start_y : f32 = 20.0; + let size : f32 = 20.0; //compile time constants for now + let mut start_white : bool = true; + for row in 0..r { + let mut colour = start_white; + for col in 0..c { + graphics::rectangle(ctx, + if (colour) { graphics::DrawMode::Line } else { graphics::DrawMode::Fill }, + graphics::Rect { + x : start_x + (size * col), + y : start_y + (size * row), + w : size, + h : size + })?; + colour = !colour; + } + start_white = !start_white; + } + } } + + impl EventHandler for Apr { fn update(&mut self, _ctx: &mut Context) -> GameResult<()> { + + Err(ggez::GameError::CustomError("You done messed up trying to play this game!".to_string())) // Update code here... // Ok(()) @@ -43,3 +55,18 @@ impl EventHandler for Apr { graphics::present(ctx) } } + +fn main() { + // Make a Context. + let (mut ctx, event_loop) = ContextBuilder::new("apruebo", "s1m7u and e-dt") + .build() + .expect("aieee, could not create ggez context!"); + + // Create an instance of your event handler. + // Usually, you should provide it with the Context object to + // use when setting your game up. + let apr = Apr::new(&mut ctx); + + // Run! + event::run(ctx, event_loop, apr); +}