Need help programming an "Agar.io" Game in open frameworks!

Hey guys,

I need all the help I can get when it comes to this damn final. Basically my professor thinks I’m some genius programmer when realistically I am a beginner. For my final project, I submitted a game similar to the game Agar.io. You can find the game at the site: Agar.io or you can download it on your smartphone.

Basically, I programmed the game in C using open frameworks. The source code is as follows:

ofMain.cpp:

[CODE]#include “ofMain.h”
#include “ofApp.h”

//========================================================================
int main( ){
ofSetupOpenGL(2000, 2000,OF_WINDOW); // <-------- setup the GL context

// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp(new ofApp());

}
[/CODE]

ofApp.cpp:

[CODE]#include “ofApp.h”

int n = 1000,
isVis[1000],
covers[1000];

float ballX,
ballY,
ballRadius,

    ballR,
    ballG,
    ballB,
    ballVel,

    mouseX,
    mouseY,

    foodRadius[1000],

    maxWidth,
    maxHeight,

    foodX[1000],
    foodY[1000],
    foodCR[1000],
    foodCG[1000],
    foodCB[1000],

    gridX1[1000],
    gridY1[1000],
    gridX2[1000],
    gridY2[1000],
    gridHX1[1000],
    gridHY1[1000],
    gridHX2[1000],
    gridHY2[1000];

///////////////////////////////////////////////////////////////////////////////////////////////
float getDistance(float Xa, float Ya, float Xb, float Yb)
{
float dist;

dist = sqrt((Xa - Xb)*(Xa - Xb) + (Ya - Yb)*(Ya - Yb));

return dist;

}
///////////////////////////////////////////////////////////////////////////////////////////////

void coversCircle(int n, int covers[])
{

float dist[n];

for (int i = 0; i < n; i++)
{
    dist[i] = getDistance(ballX, ballY, foodX[i], foodY[i]);
                     
    if ((dist[i] <= ballRadius) && (isVis[i] = 1))
    {
        covers[i] = 1;
    }
    
}

}

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

void ofApp::setup(){

ofSetFrameRate(500);

srand(time(NULL));

ofSetCircleResolution(200);

ofBackground(0, 0, 0);

// Size of the play area
maxWidth = 5000.f;
maxHeight = 3000.f;

//Ball Starting Coord

ballX = maxWidth / 2;
ballY = maxHeight / 2;
ballRadius = 20;

//Food Radius
for (int i = 0; i < n; i++)
{
    foodRadius[i] = 10;
}

//Ball Color
ballR = 56+rand()%200;
ballG = 56+rand()%200;
ballB = 56+rand()%200;

for (int i = 0; i < n; i++)
{
    isVis[i] = 1;
    
    foodX[i] = ofRandom(maxWidth);
    foodY[i] = ofRandom(maxHeight);
    
    foodCR[i] = rand()%256;
    foodCG[i] = rand()%256;
    foodCB[i] = rand()%256;
}

}

//--------------------------------------------------------------
void ofApp::update(){

ballVel = 5/ballRadius;

//Bound the ball to the map
if ((ballX - ballRadius) <= (maxWidth - maxWidth))
{
    ballX = maxWidth - maxWidth + ballRadius;
}

if ((ballY - ballRadius) <= (maxHeight - maxHeight))
{
    ballY = maxHeight - maxHeight + ballRadius;
}
if ((ballX + ballRadius) >= (maxWidth))
{
    ballX = maxWidth - ballRadius;
}

if ((ballY + ballRadius) >= (maxHeight))
{
    ballY = maxHeight - ballRadius;
}

// Move the player
ballX += ( ofGetMouseX() - ofGetWidth() * 0.5 ) / 250;
ballY += ( ofGetMouseY() - ofGetHeight() * 0.5 ) / 250;

// Bound the player movements
ofClamp( ballX + ballRadius, 0, maxWidth );
ofClamp( ballY + ballRadius, 0, maxHeight );

///////////////////////////////////////////////////////////////////////////////////////////////

coversCircle(n, covers);
for (int i = 0; i < n; i++)
{

    if ((covers[i] == 1) && (isVis[i] == 1))
    {
        for ( int j = 0; j < 10; j++)
        {
        ballRadius = ballRadius+foodRadius[i]/100;
            j++;
        }
        isVis[i] = 0;
        foodRadius[i] = 0;
        //covers[i] = 0;
    }
}

}

//--------------------------------------------------------------
void ofApp::draw(){

// Save current matrix
ofPushMatrix();

// Center the view around the player
ofTranslate( ofGetWidth() / 2, ofGetHeight() / 2 );
ofTranslate(-ballX, -ballY);


/*//GRID
ofSetColor(100, 100, 100);
ofSetLineWidth(1);
for (int i = 0; i < 100; i++)
{
    ofLine(gridX1[i], gridY1[i], gridX2[i], gridY2[i]);
    ofLine(gridHX1[i], gridHY1[i], gridHX2[i], gridHY2[i]);
}
 */

// Draw grid
ofSetColor( 255 );
ofSetLineWidth(5);
for( float x = 0; x < maxWidth+1; x += 50 )
{
    ofLine( x, 0, x, maxHeight );
}

for( float y = 0; y < maxHeight+1; y += 50 )
{
    ofLine( 0, y, maxWidth, y );
}

// Draw Food
for (int i = 0; i < n; i++)
{
    if(isVis[i] == 1)
    {
        ofSetColor(foodCR[i], foodCG[i], foodCB[i]);
        ofCircle(foodX[i], foodY[i], foodRadius[i]);
    }
}

ofSetColor(ballR, ballG, ballB);
ofCircle(ballX, ballY, ballRadius);

// Restore previous matrix
ofPopMatrix();

}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){

}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){

}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){

}

//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){

}
[/CODE]

ofApp.h:

[CODE]#pragma once

#include “ofMain.h”

class ofApp : public ofBaseApp{

public:
	void setup();
	void update();
	void draw();

	void keyPressed(int key);
	void keyReleased(int key);
	void mouseMoved(int x, int y );
	void mouseDragged(int x, int y, int button);
	void mousePressed(int x, int y, int button);
	void mouseReleased(int x, int y, int button);
	void windowResized(int w, int h);
	void dragEvent(ofDragInfo dragInfo);
	void gotMessage(ofMessage msg);

};
[/CODE]

So, basically what this asshole of a professor wants me to do is EITHER:

A. CREATE A MULTIPLAYER ONLINE GAME BASED ON WHAT I HAVE ALREADY CREATED

From what I know, I think I would have to somehow create a server source and somehow pass variables through the server for the players to be able to see each other while playing the game. I am completely lost when it comes to all of this.

OR

B. IMPLEMENT AN XBOX 360 WIRED CONTROLLER TO CONTROL THE MOUSE MOVEMENTS.

Now, I have already installed the drivers and mapped the xbox 360 controller to my mac, but I am totally lost when it comes to implementing it to replace my mouse movements in the program. All I really need to do is replace the joystick of the controller with my mouse movements. I have no idea how to implement that using C.

By the way:

I am using Xcode and I am on a Mac OS X Yosemite because that should make a big difference.

Now, I would really appreciate all the help I can get because this is my final project and I will probably end up failing this stupid ass class because my professor, once again, for some reason thinks I’m some sort of genius, and I have no idea why.

lmfao

lol… i know man… i know…

Im fucked.

What the hell? turning this into a multiplayer online game would take quite some time. So would wiring an xbox controller to it. Both are ridiculous requests

Ya… I still have to get it done though. I figured this community would be able to help me with the online part because its similar to how private servers are ran.