Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Victorem - easy UDP game server and client framework for creating simple 2D and 3D online game prototype in Rust.

License

NotificationsYou must be signed in to change notification settings

VictoremWinbringer/Victorem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easy UDP game server and client framework for creating simple 2D and 3D online game prototype in Rust.

Example

Cargo.toml

[dependencies]victorem ="0.8.2"

Client

use victorem;use std::time::{Duration,Instant};fnmain(){letmut client = victorem::ClientSocket::new(11111,"127.0.0.1:22222").unwrap();letmut id:u32 =0;letmut timer =Instant::now();let period =Duration::from_millis(100);loop{if timer.elapsed() > period{            timer =Instant::now();            id +=1;let _ = client.send(format!("Ping {}", id).into_bytes());}let _ = client.recv().map(|v|String::from_utf8(v).unwrap_or(String::new())).map(|s|println!("From Server: {}", s));}}

Server

use victorem;use std::net::SocketAddr;use std::time::Duration;structPingPongGame{id:u32,}impl victorem::GameforPingPongGame{fnhandle_command(&mutself,delta_time:Duration,commands:Vec<Vec<u8>>,from:SocketAddr,) -> victorem::ContinueRunning{for vin commands{println!("From Client: {:?} {} {}",                delta_time,                from,String::from_utf8(v).unwrap_or(String::new()),);}true}fndraw(&mutself,delta_time:Duration) ->Vec<u8>{self.id +=1;format!("Pong {} {:?}",self.id, delta_time).into_bytes()}}fnmain(){letmut server = victorem::GameServer::new(PingPongGame{id:0},22222).unwrap();    server.run();}

About

Victorem - easy UDP game server and client framework for creating simple 2D and 3D online game prototype in Rust.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp