A downloadable multiplayer engine

DONT USE IN PRODUCTION. ITS NOT SECURE YET.


This is a multiplayer game engine I am working on, it currently has very few features:

  • A very simple scripting language (This language is probably temporary though). 
  • A very simple language for making the world.
  • The client can control any part of the world and the server will replicate what the client did to the other clients (This will be off by default in the feature for security).
  • There is also client-sided scripting (Not documented yet)

An example game in my engine (The same one as in the video but updated, the video is out of date):

An agario clone (Don't copy and paste from here, download it from the downloads!)

_________________________________________________________________________________________

images IMAGESDIRECTORYHERE\

Camera:
    camera-follow localPlayer

FoodSpawner:
    .timeLeft 10
    onUpdate
        this.timeLeft--;
        if this.timeLeft <= 0:
            this.timeLeft = Random 10 20;
            Instantiate "Food" Random 0-300 300; Random 0-300 300;; 

Player:
    boxCollider
    topDownPlayer
    player-speed 300 300
    texture player.png
    size 32 32
    position 0 0
    .type Player
    .size 32
    onLoad
        PositionSet this.object random 0-300 300; random 0-300 300;;
    onCollisionStay
        if other.type == "Player" if other.size < this.size:
            this.size += other.size;
            Inflate this.object other.size other.size;
            Remove other.object;

Food:
    boxCollider
    texture food.png
    size 8 8
    position 0 0
    .type Food
    onCollisionStay
        if other.type == "Player":
            Inflate other.object 5 5;
            other.size += 5;
            Remove this.object;

___________________________________________________________________________________________

The game above is just an agar.io clone. It doesn't use client-sided scripting because I didn't yet implement splitting in it. However, the code above wont work since you need to replace all spaces with  tabs  (TO BE FIXED LATER).

Another example game is a pong clone (Included in the server GameFile.txt)

___________________________________________________________________________________________

images IMAGESPATHHEREPLS\

state:
    .currentPlayers 0    
    .player1Score 0
    .player2Score 0    
            
Player:
    boxCollider
    texture Rectangle.bmp
    size 32 128
    topDownPlayer
    player-speed 0 300
    .type Player
    onLoad
        state.currentPlayers++;
        if state.currentPlayers == 1:
            PositionSet this.object 64 256;
        if state.currentPlayers == 2:
            PositionSet this.object 719 256
        if state.currentPlayers >= 3:
            Remove this.object;

WallUP:
    boxCollider
    size 3000 32
    position 0 -32
    .type Wall

WallDown:
    boxCollider
    size 3000 32
    position 0 500
    .type Wall

WallLeft:
    boxCollider
    size 32 3000
    position -32 0
    .type Player2Scored
    
WallRight:
    boxCollider
    size 32 3000
    position 800 0
    .type Player1Scored

Ball:
    boxCollider
    texture BlackPixel.bmp
    size 32 32
    position 412 256
    .dirX 16
    .dirY 0
    .prevX 0
    .prevY 0
    .type Ball
    .respawn 0
    onUpdate
        if state.currentPlayers >= 2:
            this.prevX = GetX this.object;
            this.prevY = GetY this.object;
            PositionRelativeSet this.object this.dirX this.dirY
    onCollisionStay
        PositionSet this.object this.prevX this.prevY;
        if other.type == "Player":
            this.diffY = GetY other.object; +48 - GetY this.object;
            this.diffY = this.diffY / 4;
            this.dirX = 0-this.dirX;
            this.dirY = 0-this.diffY;
        if other.type == "Wall":
            this.dirY = 0-this.dirY;
        if other.type == "Player1Scored":
            this.respawn = 1;
            state.player1Score++;
            UITextSet ComponentGet Player1Score.object "UIText"; state.player1Score;
        if other.type == "Player2Scored":
            this.respawn = 1;
            state.player2Score++;
            UITextSet ComponentGet Player2Score.object "UIText"; state.player2Score;
        if this.respawn:
            this.respawn = 0;
            PositionSet this.object 412 256;
            this.dirX = 16;
            this.dirY = 0;

Player1ScoreLabel:
    UIText Player1
    position 400 16
Player1Score:
    UIText 0
    position 460 16
Player2ScoreLabel:
    UIText Player2
    position 400 32
Player2Score:
    UIText 0
    position 460 32

___________________________________________________________________________________________

___________________________________________________________________________________________


Planned in the future:

  • Write documentation
  • Add C# plugin support
  • Add more client-sided events like
    • client-onMouseClick
    • client-onMouseMove
    • client-onMouseOver

___________________________________________________________________________________________

Small documentation (Incomplete):

  • Functions
    • Print <STRING>;
      • Prints the string to the server console (SERVER SIDED FUNCTION ONLY)
      • Example: Print "hello world";
    • Remove <GameObject>;
      • Removes the object from the world and broadcasts its removal
      • Example: Remove this.object;
    • PositionSet <GameObject> <Int x> <Int y>;
      • Sets the objects x and y to the specified numbers.
      • Example: PositionSet this.object 100 100;
    • PositionRelativeSet <GameObject> <Int deltaX> <int deltaY>
      • Adds to the objects x and y the specified values. i.e, x += deltaX, y += deltaY.
      • Example: PositionRelativeSet this.object 10 10;
    • SizeSet <GameObject> <int width> <int height>
      • Sets the size of the gameObject to the specified paramaters
      • Example: SizeSet this.object 100 32
    • SizeGetX <GameObject>
    • SizeGetY <GameObject>
    • Inflate <GameObject> <int deltaWidth> <int deltaHeight>
    • GetX <GameObject>
    • GetY <GameObject>
    • Instantiate <string object> [int x] [int y]
    • Random <int inclusiveMin> <int exclusiveMax>
    • MessageStringSend <GameObject object> <string message>
      • Server:
        • Broadcasts this message to the gameObject (specified in the parameter) to all clients.
        • Event name: onMessageStringRecieved
        • Event argument names: this, args.message, args.sender (useless currently)
      • Client:
        • Sends this message to the gameObject (specified in the parameter) to the server.
        • Event name: client-onMessageStringRecieved
        • Event argument names: this, args.message
    • UITextSet <UIText> <string text>
    • UITextGet <UIText>
    • ComponentGet <GameObject> <string componentName>

___________________________________________________________________________________________

  • Events
    • onLoad
      • Runs on the server side and gets activated when the object gets added to the world.
      • Its client sided counterpart is client-onLoad.
    • onCollisionStay
      • Runs on the server side and gets activated every frame the object is colliding with another object.
      • Event arguments: this, other
        • "this" is the current object, and to access the gameObject you write ( this.object )
        • "other" is the other object colliding with this object, and to access the gameObject you write ( other.object )
      • Its client sided counterpart is client-onCollisionStay
    • onUpdate
      • Runs on the server side and gets activated every frame.
      • Event arguments: this, other


        • "this" is the current object, and to access the gameObject you write ( this.object )
      • Its client sided counterpart is client-onUpdate

___________________________________________________________________________________________

Download

Download
WUIClient 0.0.1.zip 5 MB
Download
WUIServer 0.0.1.zip 87 kB
Download
AgarioClone.zip 4.1 kB

Install instructions

You need to extract the server and the client to two different folders, then run the WUIServer.exe, and then run the WUIClient.exe (As many as you want since this is multiplayer).

The WUIServer has a Config.txt where you can change to what ip and port does the server listen to, by default I put that the server listens to 127.0.0.1 at port 3333, which means this is only local, if you want other computers to join then, change it to 0.0.0.0 at port 3333. The WUIServer also has a GameFile.txt, where you put your code for the game, and an Images folder.

The WUIClient has a Config.txt where you can change what ip the client should connect to, and an Images folder for images that will appear in the editor (Not even close to completion).