diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-15 00:45:45 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-15 00:45:45 +0200 |
commit | 052e28628eceb112aaadd5e703709c80183d290f (patch) | |
tree | 665d3a17fa5c16c3561f530c4a22eb4e0e4f8828 /light-client/src/main.rs | |
parent | 804f05e5e556fb950292f323d32e5e4fc35d310b (diff) | |
download | hurrycurry-052e28628eceb112aaadd5e703709c80183d290f.tar hurrycurry-052e28628eceb112aaadd5e703709c80183d290f.tar.bz2 hurrycurry-052e28628eceb112aaadd5e703709c80183d290f.tar.zst |
create light client crate
Diffstat (limited to 'light-client/src/main.rs')
-rw-r--r-- | light-client/src/main.rs | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/light-client/src/main.rs b/light-client/src/main.rs new file mode 100644 index 00000000..03c2fd76 --- /dev/null +++ b/light-client/src/main.rs @@ -0,0 +1,77 @@ +/* + Hurry Curry! - a game about cooking + Copyright 2024 metamuffin + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, version 3 of the License only. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +*/ +use sdl2::{ + event::Event, + image::InitFlag, + keyboard::Keycode, + pixels::{Color, PixelFormatEnum}, + render::TextureAccess, +}; + +pub mod network; + +fn main() { + let sdl_context = sdl2::init().unwrap(); + let video_subsystem = sdl_context.video().unwrap(); + let _image_context = sdl2::image::init(InitFlag::WEBP).unwrap(); + let window = video_subsystem + .window("Hurry Curry! Light Client", 1280, 720) + .position_centered() + .resizable() + .build() + .map_err(|e| e.to_string()) + .unwrap(); + + let mut canvas = window + .into_canvas() + .accelerated() + .build() + .map_err(|e| e.to_string()) + .unwrap(); + let texture_creator = canvas.texture_creator(); + let mut texture = texture_creator + .create_texture( + Some(PixelFormatEnum::RGBA8888), + TextureAccess::Streaming, + 1024, + 1024, + ) + .unwrap(); + + texture.update(None, &vec![128; 1024 * 1024], 1024).unwrap(); + + 'mainloop: loop { + canvas.set_draw_color(Color::BLACK); + canvas.clear(); + + canvas.copy(&texture, None, None).unwrap(); + + canvas.present(); + + for event in sdl_context.event_pump().unwrap().poll_iter() { + match event { + Event::Quit { .. } + | Event::KeyDown { + keycode: Option::Some(Keycode::Escape), + .. + } => break 'mainloop, + _ => {} + } + } + } +} |