January 2018
Beginner to intermediate
454 pages
10h 8m
English
I guess you did it without any issues, but in any case, here's the code:
extern crate sdl2; use sdl2::event::Event; use sdl2::keyboard::Keycode; use sdl2::pixels::Color; use sdl2::rect::Rect; use sdl2::render::{Canvas, Texture, TextureCreator}; use sdl2::video::{Window, WindowContext}; use std::thread::sleep; use std::time::{Duration, SystemTime}; // To make things easier to read, we'll create a constant which will be the texture's size. const TEXTURE_SIZE: u32 = 32; #[derive(Clone, Copy)] enum TextureColor { Green, Blue, } fn create_texture_rect<'a>(canvas: &mut Canvas<Window>, texture_creator: &'a TextureCreator<WindowContext>, color: TextureColor, size: u32) -> Option<Texture<'a>> { // We'll want to handle failures ...
Read now
Unlock full access