Browse Source

Increased animation speed

master
iamsosmart19 4 years ago
parent
commit
c0d0a56078
  1. 22
      src/main.rs

22
src/main.rs

@ -3,8 +3,8 @@ use ggez::graphics::{self, Color, DrawMode, Mesh, MeshBuilder};
use ggez::{Context, ContextBuilder, GameResult}; use ggez::{Context, ContextBuilder, GameResult};
struct Apr { struct Apr {
rows: i32, row: i32,
cols: i32, col: i32,
board: Vec<Vec<u8>>, board: Vec<Vec<u8>>,
grid: Mesh, grid: Mesh,
// Your state here... // Your state here...
@ -61,8 +61,8 @@ impl Apr {
// Load/create resources such as images here. // Load/create resources such as images here.
let board = make_board(r, c); let board = make_board(r, c);
Apr { Apr {
rows: r, row: r,
cols: c, col: c,
grid: make_grid(_ctx, r, c, board.as_slice()).unwrap(), grid: make_grid(_ctx, r, c, board.as_slice()).unwrap(),
board: board, board: board,
__TEST_state : 0, __TEST_state : 0,
@ -71,7 +71,7 @@ impl Apr {
fn set_colour(&mut self, ctx : &mut Context, r : usize, c : usize, col : u8) -> GameResult<()> { fn set_colour(&mut self, ctx : &mut Context, r : usize, c : usize, col : u8) -> GameResult<()> {
self.board[r][c] = col; self.board[r][c] = col;
self.grid = make_grid(ctx, self.rows, self.cols, self.board.as_slice())?; self.grid = make_grid(ctx, self.row, self.col, self.board.as_slice())?;
Ok(()) Ok(())
} }
} }
@ -80,10 +80,12 @@ impl EventHandler for Apr {
fn update(&mut self, _ctx: &mut Context) -> GameResult<()> { fn update(&mut self, _ctx: &mut Context) -> GameResult<()> {
// Err(ggez::GameError::CustomError("You done messed up trying to play this game!".to_string())) // Err(ggez::GameError::CustomError("You done messed up trying to play this game!".to_string()))
// Update code here... // Update code here...
let c = self.__TEST_state % 8; for x in 0..self.row*self.col/5 {
let r = (self.__TEST_state / 8) % 8; let c = self.__TEST_state % self.col as usize;
self.set_colour(_ctx, r, c, (self.board[r][c] + 1) % 8)?; let r = (self.__TEST_state / self.row as usize) % self.row as usize;
self.__TEST_state += 1; self.set_colour(_ctx, r, c, (self.board[r][c] + 1) % 8)?;
self.__TEST_state += 1;
}
Ok(()) Ok(())
} }
@ -106,7 +108,7 @@ fn main() {
// Create an instance of your event handler. // Create an instance of your event handler.
// Usually, you should provide it with the Context object to // Usually, you should provide it with the Context object to
// use when setting your game up. // use when setting your game up.
let apr = Apr::new(&mut ctx, 8, 8); let apr = Apr::new(&mut ctx, 16, 16);
// Run! // Run!
event::run(ctx, event_loop, apr); event::run(ctx, event_loop, apr);

Loading…
Cancel
Save