• entries
271
969
• views
189767

# Multiplayer is Fun!

111 views

Hey everyone,

I apologize for my lack of decent updates, but schools a bitch, and quite frankly, I haven't been getting much done programming wise lately.

Anyways, Angels 20 is rolling along nicely, there really isn't much left engine wise for me to do, all I have to do now is argue with Mark about how much damage each weapon does, and do some special case programming for certain levels. We're still on track for finishing the first campaign before November, but we're starting to get cramped for time.

In other news.... I finally got the hang of winsock, and now my multiplayer dogfight game is working!!!! I wasn't sure if it would work, because the lag was so bad over a LAN, that the game was running at about 5 updates a second. I was about to give up when I decided to post in the Networking forum, which yielded a reference to TCP_NODELAY. After looking around for info, I decided that it was the answer to my problem, and lo and behold it was. We soon had 4 player "dogfights" going on in my comp sci class,which energized and inspired me to make this game really fun.

The first item on my list was weapons, which went pretty well, considering the problems I had earlier just trying to get the game to run.

The next item was a text rendering system. I still want this game to be resource-free, which means I didn't want to use bitmapped fonts, or anything of that matter, so I decided to brute force my way through the problem. I spent about 2 hours yesterday plotting vertices for every letter and number in the English alphabet. Anyways, it took a while, but it works, and I've provided te source code to anyone who wants something similar ( or needs a good laugh):

Text.h
#ifndef TEXT_H#define TEXT_H#include "gl/glaux.h"#include #include class Text{public :Text();void RenderText(char text[], float x , float y , float color[3]);}; #endif

Text.cpp
#include "Text.h"Text::Text(){}void Text::RenderText(char text[], float x , float y , float color[3]){float typeback = -0.7*(strlen(text));glTranslatef(x +(typeback/2+1.4) , y , 0);glColor3f(color[0] , color[1] , color[2]);for(int i = 0 ; i < strlen(text) ; i ++){glTranslatef(0.6 ,0,0);if(text == 'a' || text == 'A'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0,0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.25 , 0);glEnd();}if(text == 'b' || text == 'B'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0,0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(-0.25 , 0 , 0);glEnd();}if(text == 'c' || text == 'C'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.-25 , 0 , 0);glVertex3f(0.25 , 0,0);glEnd();}if(text == 'd' || text == 'D'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(-0.25 , 0,0);glEnd();}if(text == 'e' || text == 'E'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(-0.25 , 0 , 0);glEnd();}if(text == 'f' || text == 'F'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.25 , 0);glEnd();}if(text == 'g' || text == 'G'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(-0.10 , 0.25 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(-0.25 , 0 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(0.25 , 0.25 , 0);glEnd();}if(text == 'h' || text == 'H'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(0.25 , 0.5 , 0);glEnd();}if(text == 'i' || text == 'I'){glBegin(GL_LINES);glVertex3f(0 , 0 , 0);glVertex3f(0 , 0.5 , 0);glVertex3f(-0.1 , 0.5 , 0);glVertex3f(0.1 , 0.5 , 0);glVertex3f(0.1 , 0 , 0);glVertex3f(-0.1 , 0 , 0);glEnd();}if(text == 'j' || text == 'J'){glBegin(GL_LINES);glVertex3f(0.0 , 0 , 0);glVertex3f(0.0 , 0.5 , 0);glVertex3f(0.0 , 0 , 0);glVertex3f(-0.25 , 0.2 , 0);glEnd();}if(text == 'k' || text == 'K'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(0.25 , 0 , 0);glEnd();}if(text == 'l' || text == 'L'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0 , 0);glVertex3f(0.25 , 0 , 0);glEnd();}if(text == 'm' || text == 'M'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.0 , 0.0 , 0);glVertex3f(0.0 , 0.0 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0 , 0);glEnd();}if(text == 'n' || text == 'N'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(0.25 , 0.5 , 0);glEnd();}if(text == 'o' || text == 'O'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(-0.25 , 0 , 0);glEnd();}if(text == 'p' || text == 'P'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.25 , 0);glEnd();}if(text == 'q' || text == 'Q'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(-0.25 , 0 , 0);glVertex3f(0.1 , 0.1 , 0);glVertex3f(0.25 , -0.1 , 0);glEnd();}if(text == 'r' || text == 'R'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(0.25 , 0.0 , 0);glEnd();}if(text == 's' || text == 'S'){glBegin(GL_LINES);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(-0.25 , 0 , 0);glEnd();}if(text == 't' || text == 'T'){glBegin(GL_LINES);glVertex3f(-0.0 , 0 , 0);glVertex3f(-0.0 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glEnd();}if(text == 'u' || text == 'U'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.0 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(0.25 , 0.5 , 0);glEnd();}if(text == 'v' || text == 'V'){glBegin(GL_LINES);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.0 , 0.0 , 0);glVertex3f(-0.0 , 0.0 , 0);glVertex3f(0.25 , 0.5 , 0);glEnd();}if(text == 'w' || text == 'W'){glBegin(GL_LINES);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0 , 0);glVertex3f(0.0 , 0.5 , 0);glVertex3f(0.0 , 0.5 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(0.25 , 0.5 , 0);glEnd();}if(text == 'x' || text == 'X'){glBegin(GL_LINES);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.0 , 0);glEnd();}if(text == 'y' || text == 'Y'){glBegin(GL_LINES);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.0 , 0.25 , 0);glVertex3f(-0.0 , 0.25 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.0 , 0.25 , 0);glVertex3f(0.0 , 0.0 , 0);glEnd();}if(text == 'z' || text == 'Z'){glBegin(GL_LINES);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.0 , 0);glVertex3f(-0.25 , 0.0 , 0);glVertex3f(0.25 , 0.0 , 0);glEnd();}if(text == '0' || text == '0'){glBegin(GL_LINES);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(-0.25 , 0 , 0);glEnd();}if(text == '1' ){glBegin(GL_LINES);glVertex3f(-0.0 , 0 , 0);glVertex3f(-0.0 , 0.5 , 0);glVertex3f(-0.1 , 0.0 , 0);glVertex3f(0.1 , 0.0 , 0);glVertex3f(0.0 , 0.5 , 0);glVertex3f(-0.1 , 0.4 , 0);glEnd();}if(text == '2' ){glBegin(GL_LINES);glVertex3f(0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(-0.25 , 0 , 0);glVertex3f(-0.25 , 0.0 , 0);glVertex3f(0.25 , 0 , 0);glEnd();}if(text == '3' ){glBegin(GL_LINES);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.0 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(0.25 , 0.5 , 0);glEnd();}if(text == '4' ){glBegin(GL_LINES);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(0.25 , 0.25 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.0 , 0);glEnd();}if(text == '5' ){glBegin(GL_LINES);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.3 , 0);glVertex3f(-0.25 , 0.3 , 0);glVertex3f(0.25 , 0.3 , 0);glVertex3f(0.25 , 0.3 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(-0.25 , 0 , 0);glEnd();}if(text == '6' ){glBegin(GL_LINES);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.0 , 0);glVertex3f(-0.25 , 0.3 , 0);glVertex3f(0.25 , 0.3 , 0);glVertex3f(0.25 , 0.3 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(-0.25 , 0 , 0);glEnd();}if(text == '7' ){glBegin(GL_LINES);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.0 , 0);glEnd();}if(text == '8' ){glBegin(GL_LINES);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.0 , 0);glVertex3f(-0.25 , 0.3 , 0);glVertex3f(0.25 , 0.3 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0 , 0);glVertex3f(0.25 , 0.0 , 0);glVertex3f(-0.25 , 0 , 0);glEnd();}if(text == '9' ){glBegin(GL_LINES);glVertex3f(0.25 , 0 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.5 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(-0.25 , 0.25 , 0);glVertex3f(0.25 , 0.25 , 0);glEnd();}if(text == ':' ){glBegin(GL_LINES);glVertex3f(0.0 , 0.1 , 0);glVertex3f(0.0 , 0.2 , 0);glVertex3f(0.0 , 0.3 , 0);glVertex3f(0.0 , 0.4 , 0);glEnd();}if(text == '|' ){glTranslatef(-(i-1)*0.7, -0.6 , 0);}}}

Well, there you have it, the result of 3 mountain dews, 2 hours of work, and an extreme lack of forethought.

Anyways, I got the game working pretty good now (although my mother is the only opponent available to me right now[wink]), it works on pretty slow machines, but it probably wont run very well over the internet, I haven't implemented client-side interpolation yet, so the server is firing off 60 updates a second to each client. Anyways, here's a screen of a particularly one sided dogfight between me and ??? ????.

Well, I'll hopefully have another update ready soon, talk to you guys later!

Angels 20 Feature WorkList
-A Map of the Level on the HUD
-Good MIG AI
-Destructable Tiles
-A checklist of enemies on the level
-Repair Trucks that actually have to stop to repair stuff
-Ground Vehicles that can shoot at you
-More weapons (ie. Napalm, Cluster Bombs, etc)
-Fully Automatic Gun
-Forward Supply Bases
-More mission parameters (ie. timelimits , targets , etc)
-Random HUD Stuff
-Expanded Tileset
-Improved Level Editor
-Gameplay balancing and tweaking
-New Mission Types
(Almost Done!!!!)

# Dont Forget To Try Out The Newest Version Of Angels 20

You are shooting your own mother in the back? That's not very sportsman-like...

I like the vector graphics style text font though. I seem to remember doing the same thing myself years and years ago for a game in BASIC, and I remember how painful it was to implement the whole alphabet like that. I might use that technique again (or at least a similar bitmapped font) for any retro-themed arcade games I decide to work on.

The game's looking good, though.

Quote:
 You are shooting your own mother in the back? That's not very sportsman-like...

she took away my car, she had it coming...[wink]

In retrospect, I could've really sped up the letter making process if I had realized nearly every letter can be derived from a blocky '8', DOH!!!!!

Anyways, Thanks for the kind words!!

Sweeeeet!

Looking good man, keep it up.

## Create an account

Register a new account