implement upgrade system

This commit is contained in:
Vinzenz Schroeter 2025-07-05 23:23:07 +02:00
commit 3468fff882
7 changed files with 558 additions and 100 deletions

View file

@ -1,13 +1,17 @@
use game::Game;
use servicepoint::{BinaryOperation, BitVecCommand, Bitmap, CharGrid, CharGridCommand, ClearCommand, CompressionCode, UdpSocketExt, FRAME_PACING, TILE_HEIGHT, TILE_WIDTH};
use servicepoint::{
BinaryOperation, BitVecCommand, Bitmap, CharGrid, CharGridCommand, ClearCommand,
CompressionCode, FRAME_PACING, TILE_HEIGHT, TILE_WIDTH, UdpSocketExt,
};
use std::{
net::UdpSocket,
thread::sleep,
time::{Duration, Instant}
time::{Duration, Instant},
};
mod bar;
mod game;
mod upgrades;
type Currency = f64;
@ -20,6 +24,8 @@ const DESTINATION: &str = "127.0.0.1:2342";
//const DESTINATION: &str = "172.23.42.29:2342";
fn main() {
env_logger::init();
let mut state = Game::new();
let connection = UdpSocket::bind_connect(DESTINATION).unwrap();
connection.send_command(ClearCommand);
@ -33,22 +39,30 @@ fn main() {
let delta = current_time - last_refresh;
last_refresh = current_time;
(state, _) = state.progress(delta);
state.progress(delta);
chars.fill(' ');
pixels.fill(false);
let mut chars_view = chars.window_mut(0, 0, chars.width(), chars.height()).unwrap();
let mut pixels_view = pixels.window_mut(0,0,pixels.width(), pixels.height()).unwrap();
let mut chars_view = chars
.window_mut(0, 0, chars.width(), chars.height())
.unwrap();
let mut pixels_view = pixels
.window_mut(0, 0, pixels.width(), pixels.height())
.unwrap();
state.draw(&mut chars_view, &mut pixels_view);
connection.send_command(CharGridCommand::from(chars.clone())).unwrap();
connection.send_command(BitVecCommand {
bitvec: pixels.clone().into(),
compression: CompressionCode::default(),
operation: BinaryOperation::Or,
offset: 0,
}).unwrap();
connection
.send_command(CharGridCommand::from(chars.clone()))
.unwrap();
connection
.send_command(BitVecCommand {
bitvec: pixels.clone().into(),
compression: CompressionCode::default(),
operation: BinaryOperation::Or,
offset: 0,
})
.unwrap();
sleep(FRAME_PACING);
}