revert to sending in a way that works without the special null handling
This commit is contained in:
		
							parent
							
								
									102a82b1ca
								
							
						
					
					
						commit
						67d3de3d42
					
				
					 1 changed files with 16 additions and 9 deletions
				
			
		
							
								
								
									
										25
									
								
								src/main.rs
									
										
									
									
									
								
							
							
						
						
									
										25
									
								
								src/main.rs
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,8 +1,9 @@
 | 
			
		|||
use game::Game;
 | 
			
		||||
use servicepoint::{
 | 
			
		||||
    Bitmap, BitmapCommand, CharGrid, CharGridCommand, ClearCommand, GridMut, TILE_HEIGHT,
 | 
			
		||||
    TILE_WIDTH, UdpSocketExt,
 | 
			
		||||
    BinaryOperation, BitVecCommand, Bitmap, CharGrid, CharGridCommand, ClearCommand,
 | 
			
		||||
    CompressionCode, DisplayBitVec, FRAME_PACING, GridMut, TILE_HEIGHT, TILE_WIDTH, UdpSocketExt,
 | 
			
		||||
};
 | 
			
		||||
use std::thread::sleep;
 | 
			
		||||
use std::{net::UdpSocket, time::Instant};
 | 
			
		||||
 | 
			
		||||
mod bar;
 | 
			
		||||
| 
						 | 
				
			
			@ -13,8 +14,8 @@ mod unlocks;
 | 
			
		|||
 | 
			
		||||
type Currency = f64;
 | 
			
		||||
 | 
			
		||||
const DESTINATION: &str = "127.0.0.1:2342";
 | 
			
		||||
//const DESTINATION: &str = "172.23.42.29:2342";
 | 
			
		||||
//const DESTINATION: &str = "127.0.0.1:2342";
 | 
			
		||||
const DESTINATION: &str = "172.23.42.29:2342";
 | 
			
		||||
 | 
			
		||||
fn main() {
 | 
			
		||||
    env_logger::init();
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +24,7 @@ fn main() {
 | 
			
		|||
    let connection = UdpSocket::bind_connect(DESTINATION).unwrap();
 | 
			
		||||
    connection.send_command(ClearCommand);
 | 
			
		||||
 | 
			
		||||
    let mut bitmap_cmd = BitmapCommand::from(Bitmap::max_sized());
 | 
			
		||||
    let mut pixels = Bitmap::max_sized();
 | 
			
		||||
    let mut chars_cmd = CharGridCommand::from(CharGrid::new(TILE_WIDTH, TILE_HEIGHT));
 | 
			
		||||
 | 
			
		||||
    let mut last_refresh = Instant::now();
 | 
			
		||||
| 
						 | 
				
			
			@ -35,17 +36,23 @@ fn main() {
 | 
			
		|||
        state.progress(delta);
 | 
			
		||||
 | 
			
		||||
        let chars = &mut chars_cmd.grid;
 | 
			
		||||
        let pixels = &mut bitmap_cmd.bitmap;
 | 
			
		||||
 | 
			
		||||
        chars.fill('\0');
 | 
			
		||||
        chars.fill(' ');
 | 
			
		||||
        pixels.fill(false);
 | 
			
		||||
 | 
			
		||||
        let chars_view = chars.window_mut(.., ..).unwrap();
 | 
			
		||||
        let pixels_view = pixels.window_mut(.., ..).unwrap();
 | 
			
		||||
        state.draw(chars_view, pixels_view);
 | 
			
		||||
 | 
			
		||||
        connection.send_command(&bitmap_cmd).unwrap();
 | 
			
		||||
        connection.send_command(&chars_cmd).unwrap();
 | 
			
		||||
        //sleep(FRAME_PACING / 10);
 | 
			
		||||
        connection
 | 
			
		||||
            .send_command(BitVecCommand {
 | 
			
		||||
                offset: 0,
 | 
			
		||||
                bitvec: DisplayBitVec::from(pixels.clone()),
 | 
			
		||||
                operation: BinaryOperation::Or,
 | 
			
		||||
                compression: CompressionCode::default(),
 | 
			
		||||
            })
 | 
			
		||||
            .unwrap();
 | 
			
		||||
        sleep(FRAME_PACING * 2);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue