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

Overview

Victorem

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};

fn main() {
    let mut client = victorem::ClientSocket::new(11111, "127.0.0.1:22222").unwrap();
    let mut id: u32 = 0;
    let mut 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;

struct PingPongGame {
    id: u32,
}

impl victorem::Game for PingPongGame {
    fn handle_command(
        &mut self,
        delta_time: Duration,
        commands: Vec<Vec<u8>>,
        from: SocketAddr,
    ) -> victorem::ContinueRunning {
        for v in commands {
            println!(
                "From Client: {:?} {} {}",
                delta_time,
                from,
                String::from_utf8(v).unwrap_or(String::new()),
            );
        }
        true
    }

    fn draw(&mut self, delta_time: Duration) -> Vec<u8> {
        self.id += 1;
        format!("Pong {} {:?}", self.id, delta_time).into_bytes()
    }
}

fn main() {
    let mut server = victorem::GameServer::new(PingPongGame { id: 0 }, 22222).unwrap();
    server.run();
}
You might also like...
Facilitate the process of creating a decompilation project for a given Wii/Gamecube game

dadosod Facilitate the process of creating a decompilation project for a given Wii/Gamecube game Features Disassembly DOL Guess/Calculate common secti

🎮 A Realtime Multiplayer Server/Client Game example built entirely with Rust 🦀

Example of a 🎮 Realtime Multiplayer Web Game Server/Client built entirely using Rust 🦀

A simple-to-use input manager for the Bevy game engine that empowers players and makes accessibility easy.

Bevy Ineffable A simple-to-use input manager for the Bevy game engine that empowers players and makes accessibility easy. Core tenets Make accessibili

Simple event-based client-server networking library for Bevy

Bevy Client Server Events Simple event-based client-server networking library for Bevy. Easily send bevy events to/from a client/server without worryi

🎮 A simple 2D game framework written in Rust

Tetra Tetra is a simple 2D game framework written in Rust. It uses SDL2 for event handling and OpenGL 3.2+ for rendering. Website Tutorial API Docs FA

Abstreet - Transportation planning and traffic simulation software for creating cities friendlier to walking, biking, and public transit
Abstreet - Transportation planning and traffic simulation software for creating cities friendlier to walking, biking, and public transit

A/B Street Ever been stuck in traffic on a bus, wondering why is there legal street parking instead of a dedicated bus lane? A/B Street is a project t

Wein2D.js bindings for creating browser games in Rust using WebAssembly.

Wein2D.js-WASM Wein2D.js bindings for creating browser games in Rust using WebAssembly. Wein2D.js-WASM requires Wein2d.js to be loaded in the same doc

Bell is a work in progress programming language that compiles to MCfunction (Minecraft's language for creating datapacks).

Bell is a work in progress programming language that compiles to MCfunction (Minecraft's language for creating datapacks). It provides a higher level,

A tool for creating optimised, platform specific glTF files.

Squisher What? squisher is a program that takes a glTF or .glb file with PNG/JPG textures and produces a .glb file where the textures have been replac

Comments
  • Use ToSocketAddrs for addr instead of &str

    Use ToSocketAddrs for addr instead of &str

    https://github.com/VictoremWinbringer/Victorem/blob/657f6465df8b615e5bdc3fd5d7358d2d444566e5/src/data_access_layer.rs#L16

    Have a look at https://doc.rust-lang.org/std/net/struct.UdpSocket.html#method.bind . Normally you would want to use generic type <A: ToSocketAddrs>(addr: A) for addr instead of &str.

    opened by kpp 0
Releases(0.8.2)
Owner
Victor Winbringer
Software Developer (C#, Go, Swift, Python, JavaScript, TypeScript, Haskell, SQL, C, HLSL, Rust)
Victor Winbringer
Solana Game Server is a decentralized game server running on Solana, designed for game developers

Solana Game Server* is the first decentralized Game Server (aka web3 game server) designed for game devs. (Think web3 SDK for game developers as a ser

Tardigrade Life Sciences, Inc 16 Dec 1, 2022
An online judge sandbox server in Rust, inspired by go-judge, for SAST OJ.

RsJudge An online judge sandbox server in Rust, inspired by go-judge, for SAST OJ. Table of Contents Features Build from source Prerequisites Build Fe

NJUPT SAST 4 Dec 10, 2023
Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.

vx_bevy A voxel engine prototype made using the Bevy game engine. Goals and features Very basic worldgen Animated chunk loading (ala cube world) Optim

Lucas Arriesse 125 Dec 31, 2022
A prototype plugin providing a simple line drawing api for bevy.

bevy_debug_lines A prototype plugin providing a simple line drawing api for bevy. See docs.rs for documentation. Expect breakage on master. Click on t

Michael Palmos 92 Dec 31, 2022
Creating a simple flappy bird game in Rust language

Creating a simple flappy bird game in Rust language The main goal of this project is to get my hands dirty with rust, while creating something fun. Ex

Sajidur Rahman 1 Feb 10, 2022
This is an online game in which you program your character and he fights with other players

Game for programmers The goal of this project is to create a simple game for programmers. The essence of the game Each player has his own character th

Danila 1 Dec 10, 2021
A Client/Server game networking plugin using QUIC, for the Bevy game engine.

Bevy Quinnet A Client/Server game networking plugin using QUIC, for the Bevy game engine. Bevy Quinnet QUIC as a game networking protocol Features Roa

Gilles Henaux 65 Feb 20, 2023
Engine / framework for creating highly customizable and user modable action RPG's

Rust RPG Toolkit PLEASE NOTE: this in early and very heavy development. API is subject to constant change, as it has newly transitioned from being a g

Ole A. Sjo Fasting 58 Dec 5, 2022
Hotham is a framework for quickly and easily creating amazing standalone VR experiences.

?? Under construction! Please mind the mess! ?? Introduction G'day, and welcome to Hotham! ?? Hotham is an attempt to create a lightweight, high perfo

Let Eyes Equals Two 296 Dec 29, 2022
Utilities for creating strictly ordered execution graphs of systems for the Bevy game engine

bevy_system_graph This crate provides the utilities for creating strictly ordered execution graphs of systems for the Bevy game engine. Bevy Version S

Hourai Teahouse 19 Dec 2, 2022