The Gang of Five
The forum will have some maintenance done in the next couple of months. We have also made a decision concerning AI art in the art section.


Please see this post for more details.

Multiplayer LBT RPG game

action9000 · 224 · 20950

NeptuneNavigator2001

  • Timeless Wanderer
  • Member+
  • Ducky
  • *
    • Posts: 1322
  • Trust in love, and never give up...
    • View Profile
So...  Looks like things are progressing at least, semi-smoothly on this, right?  (Sorry, I haven't kept up with the board for about a week now...  LOL Iris, you're over 100 posts ahead of me! xD)
"And the Most High said unto Moses, Ahayah-Asher-Ahayah.  And he said, Thus shalt thou say to the children of Israel, Ahayah hath sent me unto you...  This is my name forever, and this is my memorial unto all generations."

1953-2011...  One day, mother, I shall see you again...


action9000

  • Member+
  • Cera
  • *
    • Posts: 5742
    • View Profile
Multiplayer is *almost* working, everyone!

2 players over LAN works beautifully.  Both players can see each other move around and they can chat with each other.

My code does not allow clients (aka. non-hosts) to talk to each other.  Clients can only talk to the server.  The server then needs to relay the data to the clients.

Right now, I have a client and a server talking to each other awesome.  I just need to get the server to relay data (such as the coordinates of each player) to everybody else in the game.  Once I get 3 players working, 100+ players will be a breeze since the code is pretty generic to any number of players, up to my chosen maximum (of 100 in this case).

This shouldn't be much longer! :D


Coyote_A

  • Ducky
  • *
    • Posts: 1115
    • View Profile
    • http://www.facebook.com/CoyoteMao
Good to hear that, we're counting on you, action9000. :)


action9000

  • Member+
  • Cera
  • *
    • Posts: 5742
    • View Profile
Quote
we're counting on you, action9000.
No pressure or anything! :P:  :lol

By the way, I don't remember if I mentioned this already, in reference to this topic's poll:
It is *confirmed* that you will be able to play as a dinosaur of the Gang's approximate age, but NOT the gang themselves.  A number of dinosaur types will be available as choices when you start a new character.


SolarThreehorn

  • Chomper
  • *
    • Posts: 81
    • View Profile
Quote
It is *confirmed* that you will be able to play as a dinosaur of the Gang's approximate age, but NOT the gang themselves.

That's great, it should eliminate conflict on who plays who
***Progress looks good***


aabicus (LettuceBacon&Tomato)

  • Member+
  • Littlefoot
  • *
    • Posts: 8268
  • Rations
    • View Profile
    • aabicus.com
Wow, this thing's really improved since I last checked up. (which was, admittedly, in february.) Last time I came here, we weren't even sure if it was going to be continued.

Great job Action9000, and everyone who's helping!


Mumbling

  • Administrator
  • Littlefoot
  • *
    • Posts: 8945
    • View Profile
Yea it's really looking awesome already!

Tim(Action9000) is doing the main work though. Malte is doing a great job with creating a map of the great valley ( I would get confused if I had to summarise it all) So many people are reaally doing their best for this game..




And I'm the supporter...  :lol Keep Tim awake when he's programming :p


action9000

  • Member+
  • Cera
  • *
    • Posts: 5742
    • View Profile
Quote
And I'm the supporter...  Keep Tim awake when he's programming 
for which I'm very thankful! :lol:


action9000

  • Member+
  • Cera
  • *
    • Posts: 5742
    • View Profile
Quote
I would love to see the variables you're using. :lol
A quote from way back when, from landbeforetimelover:
Well Austin, you asked for it! :p  :lol  :lol

Code:  on  

//Just initializing some functions that we'll need.--------------------------

//Initialization and technical functions
void onStartLoadStuff();
void setupDisplay();

//Opening menus functions
void mainMenu();
void hostGameMenu();
void joinGameMenu();
void optionsMenu();

//Main game loop functions
void runMainGame();
void gameLoop();

//Game engine functions
void drawGUI();
void checkPlayerMovement();
void checkCameraMovement();

//Networking functions
void handleChatting();

//Player control functions
void handleGravity();
void tryToJump();

//---------------------------------------------------------------------------




//THIS SECTION CONTAINS ALL OF THE GLOBAL VARIABLES IN THE PROGRAM.
//I JUST INITIALIZED EVERYTHING HERE AND I TRIED TO ORGANIZE IT
//AS BEST I CAN. :P
//--------------------------------------------------------------------------------------------------------------------------------------------------------

//KEYBOARD CONSTANTS---------------------------------------------------------
//I defined the names of the keys to match the physical scancodes of the keys. This just makes the code easier to read and write.
//Instead of reading "if you pressed Key 17, do this", you can read "If you pressed the W key, do this" in the code.
//It's just easier to work with.
const int W_Key = 17;
const int S_Key = 31;
const int Q_Key = 16;
const int E_Key = 18;
const int A_Key = 30;
const int D_Key = 32;
const int SPACEBAR = 57;
const int KEY_FSLASH = 53;
const int ENTER_Key = 28;
const int NUMPAD_ENTER_Key = 156;
const int BACKSPACE_Key = 14;

//---------------------------------------------------------------------------



//GRAPHIC QUALITY VARIABLES. CAN BE CHANGED BY THE USER TO MAXIMIZE PERFORMANCE / QUALITY LATER.-----
int xResolution = 800;
int yResolution = 600;
int colourDepth = 32;
//-----------------------------------------------------------------------------------------------


//FRAMERATE SYNC TIMER VARIABLES------------------------------------------------------------------------
long now;
long goal;
long starttime;
long intstep;
int intstepmode;
char* t;
int timer_ticks;
int timer_ticks_count;
int tempTimer;
//------------------------------------------------------------------------------------------------------

//CAMERA VARIABLES-----------------------------------------------------------

//the ID number of the main camera
int mainCam=10;
int cubeCam=100;
//cubeCam is an invisible cube sitting on top of the camera. It is used to make the camera detectable.


//Stores the last known Camera Distance from the player
float lastCameraDistanceFromPlayer;

//Stores the current camera distance from the player
float currentCameraDistanceFromPlayer = 120;

//Stores the camera's absolute coordinates, X and Z.
//the Y value is stored as cameraHeight, below.
float cameraPositionX = 512;
float cameraPositionZ = 5;

float tempCameraPositionX = 512;

float tempCameraPositionZ = 5;

//The larger this value, the faster the camera pitch changes when the mouse is moved.
//This value may no longer be needed due to the latest code updates (May 31, 2008)
float pitchSensitivity = .28;

//These values store the main camera's angle of rotation (left or right) around the player,
//height above (+) or below (-) the player,
//and the pitch (up/down angle) of the camera so it faces the player.
float cameraAngle = 0;

//the height of the camera, RELATIVE TO THE PLAYER.
float cameraHeight = 110;
float cameraPitch = 5.6;

//This value determines how far out the camera may zoom.
int maxZoomDistance = 250;

//These values control how fast the camera moves when it is moved by the mouse.
int XSensitivity=2;
int YSensitivity=2;
int ZSensitivity=32;

//These values are used by left-click camera control.
//The camera does not remember these values after the mouse button is released.
float tempCameraAngle;
float tempCameraHeight=cameraHeight;
float tempCameraPitch;

float lastKnownCameraHeight=cameraHeight;
float lastCameraX=cameraPositionX;
float lastCameraZ=cameraPositionZ;

//These values store the distance the mouse moved between the last frame and the current frame.
//(Ex. if I move the mouse one pixel to the right, the X value is 1 until
//the next frame of animation.)
float mouseMoveX;
float mouseMoveY;

//These values are set to false unless the specified mouse button is pressed.
//Ex. when the left button is pressed, leftClicked becomes TRUE for One game frame.
//This is used for the program to have a chance to store the mouse's position
//the instant a mouse button is clicked.
//This is useful so we can move the camera and/or the mouse cursor
//back to where they were when the mouse button is released.
bool leftClicked=false;
bool rightClicked=false;

//From 1 to 100.
//This value determines how smoothly the camera moves.
//1: The camera follows the mouse movement perfectly tight.
//Higher values smooth out the camera's movement but result in less precise mouse control.
float cameraSmoothness = 2;
//---------------------------------------------------------------------------




//BASIC OBJECT VARIABLES---------------------------------------

//The absolute coordinate of the player
float playerPositionX = 513;
float playerPositionY = 50;
float playerPositionZ = 20;

float oldPlayerX;
float oldPlayerY;
float oldPlayerZ;

float nextPlayerPositionX;
float nextPlayerPositionY;
float nextPlayerPositionZ;

//The player's rotation: left or right, and how much.
float playerAngleY = 0;

float xVelocity=0;
float yVelocity=0;
float zVelocity=0;
//-------------------------------------------------------------



//CHARACTER MOVEMENT: SPEED, ETC.--------------------------------------------
int playerHeight=6;

//How fast the player moves with normal forward movement
//(measured in 3d units per frame)
float playerJogSpeed = 2;

//How fast the player moves with normal backward movement.
float playerBackwardSpeed = -1;

//How fast the player rotates left or right when the keyboard is used.
float playerTurnSpeed = 2;

//This value is true when the player's feet are on the ground.
bool onGround = false;

bool jumped=false;

//the speed the player jumps upwards the instant the spacebar is pressed.
float jumpingForce = 200;

int collideFalling;
int collideClimbing;
//---------------------------------------------------------------------------



//MAP VARIABLES AND ID NUMBERS------------------------------------------------

//These unique ID numbers are given to each map file in the world.
int map = 1001;
int map2 = 1002;
//----------------------------------------------------------------------------



//PLAYER VARIABLES AND ID NUMBERS---------------------------------------------

//This ID number is assigned to the player.
//It MUST be different from any other object in the game!
int player = 2001;
int playerIDFromNet;

//The absolute coordinates of every player in the game are stored here.
//the number in the [ ] brackets is the maximum number of players.
//Each value in the [ ] brackets from 0 to 99 represents a memory location for 1 player.
double netPlayersX[100];
double netPlayersY[100];
double netPlayersZ[100];

//----------------------------------------------------------------------------


//NETWORKING VARIABLES--------------------------------------------------------
const int SERVER = 1;
const int CLIENT = 2;

char* screen_line;
int isHosting;
int inGame;
char* IPAddress = new char[100];
char* IP = new char[100];
int IPLength;

char* netStatus = new char [50];

int networkPurpose; //Either SERVER or CLIENT.
int maxPlayers=100; //Set to be a large value for testing purposes.

bool enterKeyPressed=false;

int IDbyte;
const int MYPOSITIONTOSERVER = 501;
const int CHATTING = 502;
const int CLIENTPOSITIONTOCLIENT = 503;
const int SERVERPOSITIONTOCLIENT = 504;
const int CLIENTPOSITIONTOSERVER = 505;

//----------------------------------------------------------------------------



//CHAT VARIABLES--------------------------------------------------------------
char* line1 = new char[200];
char* line2 = new char[200];
char* line3 = new char[200];
char* line4 = new char[200];
char* line5 = new char[200];
char* line6 = new char[200];


char* chatInput = new char[10];
char* chatFull = new char[200];
int chatLength;

int chatTextX;
int chatTextY;

char* chatFullFromNet = new char[200];

bool FSlashPressed=false;
bool enterKeyForChatPressed=false;
bool backspacePressed=false;
bool relaying=false;
//----------------------------------------------------------------------------




//WORLD AND PHYSICS CONSTANTS-------------------------------------------------
const float gravity = 5.673186; // ft per second squared. SUBJECT TO CHANGE
float normalY;
float slope = 0.9; //From 0-1. The smaller this num, the steeper the max slope you can climb.
//----------------------------------------------------------------------------


//IMAGE VARIABLES AND ID NUMBERS----------------------------------------------
int splashscreen = 3001;
int char1 = 3002;
int char2 = 3003;
int characterselectbg = 3004;
int hostgametextoff = 3005;
int hostgametexton = 3006;
int joingamebg = 3007;
int joingametextoff = 3008;
int joingametexton = 3009;
int menubg = 3010;
int optionstextoff = 3011;
int optionstexton = 3012;
int resolutionoff = 3013;
int resolutionon = 3014;
int backbutton = 3015;
int startbutton = 3016;

int daySky=4001;
int skyBox=10001;
//----------------------------------------------------------------------------

//SYSTEM AND GENERAL FLOW CONTROL VARIABLES-------------------------------------------
bool firstRunOfOnStart = true;
bool firstRunOfMainMenu = true;
bool firstRunOfGameLoop = true;
//------------------------------------------------------------------------------------

There ya go: all of the initialization from my program so far. :p

And yes...the camera is a pain. :P:  I have comments everywhere on the camera variables for a reason. :lol:


action9000

  • Member+
  • Cera
  • *
    • Posts: 5742
    • View Profile
Well everyone, I suppose it's that time again....

MULTIPLAYER!! :wow

Okay, this is a pretty cool update.  I'm ready for stress testing this network play with a bunch of people online.  I can get 3 computers from my house going but I want to test it with as many people as possible.

Anyway, let's get to the cool stuff:
The link!
http://search3.idrive.com/driveway/jsp/dwa...p?id=j2m4v2p4w0

Please read the Instructions file I included.  If you choose not to read it, at least read this:
Quote
****IMPORTANT****
DO NOT CLICK THE START BUTTON ON THE JOIN GAME SCREEN!
IT IS NOT SET UP YET! PRESSING IT WILL HAVE UNPREDICTABLE RESULTS,
INCLUDING SIMPLY RUNNING A SINGLE-PLAYER GAME.
JUST PRESS ENTER TO JOIN THE GAME.
*****************

If the IP address you entered does not have a game at it, the game will attempt to connect for 5 seconds before clearing the IP Address text space and giving you an error.  You may then enter another IP Address.

I had that issue when playtesting with Littlefoot Fan.  I will fix this soon but I just wanted to get this release out in the open for everyone to see! :D

One more note from the instructions file that you may find useful:
Quote
CHATTING:
To chat, press the / key and start typing.
Press ENTER to send your chat to everyone in the game.
Chats will appear on the left side of the screen.

NEW STUFF IN THIS VERSION:
1) Multiplayer support up to 100 players in one game.  Players in the game can see each other move.  Players can also chat in-game.
HOST GAME and JOIN GAME features are now functional.  Read the instructions file for details on how to play multiplayer.

2) Sky background.  It's still pretty rough, with the seams at the "corners" but it's a lot nicer than the green background. :p

3) Daytime-style lighting

4) Shadows have been disabled on the cube for now, until I can make everything nice and pretty.


Anyway, now for the important stuff:
I recommend we playtest this using Hamachi to run it over a LAN.  I have not yet set up ports for internet play.  We can *try* internet play but I cannot guarantee good results.  It hasn't been tested at all.


Known Bugs:
1) The START button on the JOIN GAME screen does NOT actually join the game.  The ENTER key does.  The START button does something from an old version, where it starts the game in a weird single-player mode.  Don't use it. :p
[EDIT] FIXED!

2) The cubes don't have the proper shadows on them.  I disabled shadowing for now to speed up rendering on slower computers.  I also want to play around a bit more with the graphic effects before I start turning on a bunch of stuff.
[EDIT] This will not be changed any time soon.

3) The OPTIONS screen still doesn't let you change anything.
[EDIT] FIXED!

4) If you type text longer than 200 characters before pressing ENTER, the results will be unpredictable.  I want to put a limit on this soon so you physically can't type more than that, but I haven't done it yet.

5) Players are not yet notified when somebody joins or leaves the game.

6) If one player leaves the game, the host isn't properly notified yet.  That cube may not disappear from the game.  New players who join may be assigned to a weird ID number.  This means that if you leave and join the game enough times, you will eventually overload the 100 player limit.  I'm not freeing up ID numbers yet.

7)The text will flicker a bit, moreso on slower computers.  I am looking into a fix for this.  I think I know the cause, I just need to figure out some clever way around it.

8) Players are not yet able to input their usernames into the game.  As a result, the chat just simply shows the text that was sent.  It doesn't show who sent it.  You may not want to use the game as an instant messenger just yet. :p

9) Backspacing in the chat system doesn't work very well. :p

10) The angle the player is facing is not yet sent over the network, just their physical location.

COMING SOON:
1) Basically, fix everything that's broken. :p
2) The beginnings of the development of 3d models of the Great Valley map. :)


Mumbling

  • Administrator
  • Littlefoot
  • *
    • Posts: 8945
    • View Profile
Whoa.. It's really going fast at the moment..  :^.^:  Good Job Tim =)


aabicus (LettuceBacon&Tomato)

  • Member+
  • Littlefoot
  • *
    • Posts: 8268
  • Rations
    • View Profile
    • aabicus.com
Well, here goes nothing... *clicks link* Wish me luck...

UPDATE: All right, it got me to the character select screen, but no characters appeared, and when I used ctrl-alt-delete to shut the thing down the character screen has remained. I'm still trying to figure out how to get rid of it and see my old background again. To sum it up, it didn't work very well.

YET ANOTHER UPDATE: Well, I got rid of the Character Select screen by completely purging my system of RPG.exe. I'm most relieved. Tell you what, I think I won't try any more test runs until the thing's finished, okay dokey?  :D


action9000

  • Member+
  • Cera
  • *
    • Posts: 5742
    • View Profile
Quote
All right, it got me to the character select screen, but no characters appeared, and when I used ctrl-alt-delete to shut the thing down the character screen has remained.

There are no "characters" at this point.  You're a cube.  That's all you get for now. :p
Just press the Start button from the Host Game screen. :)

To close the program, just press ESC. :)

As for it not closing properly on ctrl-alt-delete...I'm not sure how to help you with that I'm afraid, but you can close the game properly by just pressing ESC.


aabicus (LettuceBacon&Tomato)

  • Member+
  • Littlefoot
  • *
    • Posts: 8268
  • Rations
    • View Profile
    • aabicus.com
Seriously? I thought you said not to press Start. Oh. Okay, I'll try it again. On sec, it needs to redownload.


action9000

  • Member+
  • Cera
  • *
    • Posts: 5742
    • View Profile
Quote
I thought you said not to press Start.
Sorry.  I probably confused you by writing an incomplete instruction manual. :slap

When you HOST a game, you press START to start the game.

When you JOIN a game, just type the IP Address of the host and press the ENTER key.  It's the JOIN game screen where the start button doesn't work.

ESC backs you out of menus, from the HOST or JOIN screen back to the MAIN menu.  From the MAIN menu, ESC will close the game.  The way the program is written, ESC from any of the menus may close the program completely.  I apologize if this happens, there are a lot of works in progress still in this. :p

From inside the game itself (the world), ESC also closes the game.


By the way, a few controls:

W - forward
S - backward
A - turn left
D - turn right
SPACE - jump

Hold left mouse - rotate camera
Hold right mouse - rotate player with camera


aabicus (LettuceBacon&Tomato)

  • Member+
  • Littlefoot
  • *
    • Posts: 8268
  • Rations
    • View Profile
    • aabicus.com
I'm in. It's working swell. I'm a cube in the middle of and endless grey desert. Rather depressing, to be honest.

I'm also stuck. How do you move?

EDIT: Wait! I just found out how to jump! Now I'm trying AWSD and all letter keys.

EDIT: Dang Straight. That's how you move. I'm geting the hang of this. I can also now move the camera all over, creating an awesome vertigo-inducing swirly spiral of death. It's twice as radical when you do it while jumping.

EDIT: Hey, during one of my spirals of death I thought I saw a humogous green triangle. Is there any of those in there? Or was I seeing things?

EDIT: I saw it again! It's a cool green hexa-penta-polyhedral shapeless vortex in the middle of the sky. Freezing your jump while looking at it automatically transports you back to the ground when you let go of the mouse button.
 This is epic. I love this game all ready.


action9000

  • Member+
  • Cera
  • *
    • Posts: 5742
    • View Profile
Quote
I'm in. It's working swell. I'm a cube in the middle of and endless grey desert. Rather depressing, to be honest.
Once I get the bugs out, we can start making a Great Valley. :)

We have people designing maps already!

Quote
EDIT: Dang Straight. That's how you move. I'm geting the hang of this. I can also now move the camera all over, creating an awesome vertigo-inducing swirly spiral of death. It's twice as radical when you do it while jumping.
Haha, not too shabby, eh?  B)

Quote
EDIT: Hey, during one of my spirals of death I thought I saw a humogous green triangle. Is there any of those in there? Or was I seeing things?
Hmmmm, I know what the green triangle could potentially be....you may have found a bug.
The green background is what the sky is replacing. Apparently you found a way to see through my sky, onto the background.  I'll see if I can reproduce this.


action9000

  • Member+
  • Cera
  • *
    • Posts: 5742
    • View Profile
Quote
I'll see if I can reproduce this.
I'm having a hard time reproducing this bug. I'll try it later on a slower computer.

How powerful is the computer you're running it on?


aabicus (LettuceBacon&Tomato)

  • Member+
  • Littlefoot
  • *
    • Posts: 8268
  • Rations
    • View Profile
    • aabicus.com
Quote from: action9000,Jun 19 2008 on  01:55 AM

Hmmmm, I know what the green triangle could potentially be....you may have found a bug.
The green background is what the sky is replacing. Apparently you found a way to see through my sky, onto the background.  I'll see if I can reproduce this.
Can we name it after me? We can call it the LettuceInTheSky bug, since it's green. Like me, I'm green (inexperienced) in the sense of technological know-how.


action9000

  • Member+
  • Cera
  • *
    • Posts: 5742
    • View Profile
Quote
Can we name it after me? We can call it the LettuceInTheSky bug, since it's green. Like me, I'm green (inexperienced) in the sense of technological know-how.
Yes...yes we can! :wow