• Cargo.toml
  • src/main.rs
BIN (Deleted) assets.zip

Binary file not shown.

+1 -0Cargo.toml
1 1
[package]
2 2
name = "game-tutorial"
3 3
version = "0.1.0"
4 4
authors = ["Sunjay Varma <[email protected]>"]
5 5
edition = "2018"
6 6

7 7
[dependencies]
  8
sdl2 = "0.32.1"
+42 -2src/main.rs
1  
fn main() {
2  
    println!("Hello, world!");
  1
use sdl2::pixels::Color;
  2
use sdl2::event::Event;
  3
use sdl2::keyboard::Keycode;
  4
use std::time::Duration;
  5

  6
fn main() -> Result<(), String> {
  7
    let sdl_context = sdl2::init()?;
  8
    let video_subsystem = sdl_context.video()?;
  9

  10
    let window = video_subsystem.window("rust-sdl2 demo", 800, 600)
  11
        .position_centered()
  12
        .build()
  13
        .expect("could not initialize video subsystem");
  14

  15
    let mut canvas = window.into_canvas().build()
  16
        .expect("could not make a canvas");
  17

  18
    canvas.set_draw_color(Color::RGB(0, 255, 255));
  19
    canvas.clear();
  20
    canvas.present();
  21
    let mut event_pump = sdl_context.event_pump()?;
  22
    let mut i = 0;
  23
    'running: loop {
  24
        i = (i + 1) % 255;
  25
        canvas.set_draw_color(Color::RGB(i, 64, 255 - i));
  26
        canvas.clear();
  27
        for event in event_pump.poll_iter() {
  28
            match event {
  29
                Event::Quit {..} |
  30
                Event::KeyDown { keycode: Some(Keycode::Escape), .. } => {
  31
                    break 'running;
  32
                },
  33
                _ => {}
  34
            }
  35
        }
  36
        // The rest of the game loop goes here...
  37

  38
        canvas.present();
  39
        ::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60));
  40
    }
  41

  42
    Ok(())
3 43
}
BIN (Deleted) assets.zip

Binary file not shown.

+1 -0Cargo.toml
1
[package]
1
[package]
2
name = "game-tutorial"
2
name = "game-tutorial"
3
version = "0.1.0"
3
version = "0.1.0"
4
authors = ["Sunjay Varma <[email protected]>"]
4
authors = ["Sunjay Varma <[email protected]>"]
5
edition = "2018"
5
edition = "2018"
6

6

7
[dependencies]
7
[dependencies]
    8
sdl2 = "0.32.1"
+42 -2src/main.rs
1
fn main() {
1
use sdl2::pixels::Color;
2
    println!("Hello, world!");
2
use sdl2::event::Event;
    3
use sdl2::keyboard::Keycode;
    4
use std::time::Duration;
    5

    6
fn main() -> Result<(), String> {
    7
    let sdl_context = sdl2::init()?;
    8
    let video_subsystem = sdl_context.video()?;
    9

    10
    let window = video_subsystem.window("rust-sdl2 demo", 800, 600)
    11
        .position_centered()
    12
        .build()
    13
        .expect("could not initialize video subsystem");
    14

    15
    let mut canvas = window.into_canvas().build()
    16
        .expect("could not make a canvas");
    17

    18
    canvas.set_draw_color(Color::RGB(0, 255, 255));
    19
    canvas.clear();
    20
    canvas.present();
    21
    let mut event_pump = sdl_context.event_pump()?;
    22
    let mut i = 0;
    23
    'running: loop {
    24
        i = (i + 1) % 255;
    25
        canvas.set_draw_color(Color::RGB(i, 64, 255 - i));
    26
        canvas.clear();
    27
        for event in event_pump.poll_iter() {
    28
            match event {
    29
                Event::Quit {..} |
    30
                Event::KeyDown { keycode: Some(Keycode::Escape), .. } => {
    31
                    break 'running;
    32
                },
    33
                _ => {}
    34
            }
    35
        }
    36
        // The rest of the game loop goes here...
    37

    38
        canvas.present();
    39
        ::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60));
    40
    }
    41

    42
    Ok(())
3
}
43
}
/target
**/*.rs.bk
[package]
name = "game-tutorial"
version = "0.1.0"
authors = ["Sunjay Varma <[email protected]m>"]
edition = "2018"

[dependencies]
sdl2 = "0.32.1"
use sdl2::pixels::Color;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use std::time::Duration;

fn main() -> Result<(), String> {
    let sdl_context = sdl2::init()?;
    let video_subsystem = sdl_context.video()?;

    let window = video_subsystem.window("rust-sdl2 demo", 800, 600)
        .position_centered()
        .build()
        .expect("could not initialize video subsystem");

    let mut canvas = window.into_canvas().build()
        .expect("could not make a canvas");

    canvas.set_draw_color(Color::RGB(0, 255, 255));
    canvas.clear();
    canvas.present();
    let mut event_pump = sdl_context.event_pump()?;
    let mut i = 0;
    'running: loop {
        i = (i + 1) % 255;
        canvas.set_draw_color(Color::RGB(i, 64, 255 - i));
        canvas.clear();
        for event in event_pump.poll_iter() {
            match event {
                Event::Quit {..} |
                Event::KeyDown { keycode: Some(Keycode::Escape), .. } => {
                    break 'running;
                },
                _ => {}
            }
        }
        // The rest of the game loop goes here...

        canvas.present();
        ::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60));
    }

    Ok(())
}