Mega Man Online
|
|
|
Networking Manager Header
#ifndef _NETWORKMANAGER_H_
#define _NETWORKMANAGER_H_
#define WIN32_LEAN_AND_MEAN
#include
#include
#include
#include
#include
#include
//Include sdl_ttf
// Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib
#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib")
#pragma comment (lib, "AdvApi32.lib")
#define DEFAULT_BUFLEN 64
#define DEFAULT_PORT "27017"
#define INCRIPTION_KEY 64
struct SharedMem
{
bool m_bIsRecieving;
char m_cRecievingPacket[DEFAULT_BUFLEN];
bool m_bIsSending;
char m_cSendingPacket[DEFAULT_BUFLEN];
SharedMem()
{
m_bIsRecieving = true;
m_bIsSending = true;
m_cRecievingPacket[DEFAULT_BUFLEN] = NULL;
m_cSendingPacket[DEFAULT_BUFLEN] = NULL;
}
};
class NetworkManager
{
bool m_bIsHost;
//Begin Stream Calls This and is an Infinite Loop
void RecieveUpdate();
void SendUpdate();
void Incription(char[]);
void Decription(char[]);
//Constructer Calls This returns a true if connection is successful
double m_dPing;
bool Init();
public:
SharedMem m_SharedMem;
NetworkManager(bool);
~NetworkManager();
//Called Once from a SDL_Create Thread, arg = NetworkManager
static int BeginRecievingStream(void *arg);
static int BeginSendingStream(void *arg);
//read only - returns m_bIsHost
bool Host();
};
#endif
Networking Manager CPP
#define INCRIPTION // Comment to turn off incription
#include"NetworkManager.h"
#include "SDL_thread.h"
#include
#include
//Client Side
WSADATA wsaData;
SOCKET ConnectSocket = INVALID_SOCKET;
struct addrinfo *result = NULL,
*ptr = NULL,
hints;
char sendbuf[] = "this is a test";
char *myRPSInput = NULL;
char recvbuf[DEFAULT_BUFLEN];
int iResult;
int recvbuflen = DEFAULT_BUFLEN;
char ipaddr[] = "10.229.20.83"; //Home Ip
char buffer[512]={0};
//Server Side
SOCKET ListenSocket = INVALID_SOCKET;
SOCKET ClientSocket = INVALID_SOCKET;
int iSendResult;
NetworkManager::NetworkManager(bool host)
{
m_dPing = 0;
m_bIsHost = host;
if(Init())
std::cout<<"Connection Success\n";
else
std::cout<<"Connection Failed\n";
}
NetworkManager:: ~NetworkManager()
{
}
bool NetworkManager::Init()
{
if(m_bIsHost)
{
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != 0) {
//printf("WSAStartup failed with error: %d\n", iResult);
return false;
}
ZeroMemory(&hints, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE;
// Resolve the server address and port
iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result);
if ( iResult != 0 ) {
//printf("getaddrinfo failed with error: %d\n", iResult);
WSACleanup();
return false;
}
// Create a SOCKET for connecting to server
ListenSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
if (ListenSocket == INVALID_SOCKET) {
//printf("socket failed with error: %ld\n", WSAGetLastError());
freeaddrinfo(result);
WSACleanup();
return false;
}
// Setup the TCP listening socket
iResult = bind( ListenSocket, result->ai_addr, (int)result->ai_addrlen);
if (iResult == SOCKET_ERROR) {
//printf("bind failed with error: %d\n", WSAGetLastError());
freeaddrinfo(result);
closesocket(ListenSocket);
WSACleanup();
return false;
}
iResult = listen(ListenSocket, SOMAXCONN);
if (iResult == SOCKET_ERROR) {
//printf("listen failed with error: %d\n", WSAGetLastError());
closesocket(ListenSocket);
WSACleanup();
return false;
}
// Accept a client socket
ClientSocket = accept(ListenSocket, NULL, NULL);
if (ClientSocket == INVALID_SOCKET) {
//printf("accept failed with error: %d\n", WSAGetLastError());
closesocket(ListenSocket);
WSACleanup();
return false;
}
char ping = 0x00;
//char blank[DEFAULT_BUFLEN] = {0}; // To Absrob " the is a test"
m_dPing = SDL_GetTicks();
recv(ClientSocket, buffer , sizeof(ping), NULL);
printf(" amount better be the same on the other end = %d", buffer );
printf(" Ping is: %f", SDL_GetTicks() - m_dPing);
send( ClientSocket, buffer, sizeof(ping), 0 );
return true;
}
else
{
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != 0) {
///printf("WSAStartup failed with error: %d\n", iResult);
return false ;
}
ZeroMemory( &hints, sizeof(hints) );
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
// Resolve the server address and port
iResult = getaddrinfo(ipaddr, DEFAULT_PORT, &hints, &result);
if ( iResult != 0 ) {
//printf("getaddrinfo failed with error: %d\n", iResult);
WSACleanup();
return false;
}
// Attempt to connect to an address until one succeeds
for(ptr=result; ptr != NULL ;ptr=ptr->ai_next) {
// Create a SOCKET for connecting to server
ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype,
ptr->ai_protocol);
if (ConnectSocket == INVALID_SOCKET) {
//printf("socket failed with error: %ld\n", WSAGetLastError());
WSACleanup();
return false;
}
// Connect to server.
iResult = connect( ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen);
if (iResult == SOCKET_ERROR) {
closesocket(ConnectSocket);
ConnectSocket = INVALID_SOCKET;
return false ;
}
break;
}
// freeaddrinfo(result);
if (ConnectSocket == INVALID_SOCKET) {
//printf("Unable to connect to server!\n");
WSACleanup();
return false ;
}
//Get Initial Ping
char ping = 0xFF;
m_dPing = SDL_GetTicks();
// Send a Blank test abritarty date for a ping test
iResult = send( ConnectSocket, &ping, sizeof(ping), 0 );
if (iResult == SOCKET_ERROR) {
//printf("send failed with error: %d\n", WSAGetLastError());
closesocket(ConnectSocket);
WSACleanup();
return false ;
}
//return true;
int rec = recv(ConnectSocket, buffer, sizeof(char), 0);
printf("%d Recieved\n", rec);
printf(" amount better be the same on the other end = %d", buffer );
printf(" Ping is: %f", SDL_GetTicks() - m_dPing);
return true;
}
}
void NetworkManager:: RecieveUpdate()
{
while(true)
{
if(m_bIsHost)
{
//HOST
//Recieving
if(m_SharedMem.m_bIsRecieving == true)
{
recv(ClientSocket, m_SharedMem.m_cRecievingPacket, DEFAULT_BUFLEN, NULL);
Decription(m_SharedMem.m_cRecievingPacket);
m_SharedMem.m_bIsRecieving = false;
}
}
else//Client
{
//Recieving
if(m_SharedMem.m_bIsRecieving == true)
{
recv( ConnectSocket, m_SharedMem.m_cRecievingPacket, DEFAULT_BUFLEN, NULL);
Decription(m_SharedMem.m_cRecievingPacket);
m_SharedMem.m_bIsRecieving = false;
}
}
}
}
void NetworkManager::SendUpdate()
{
while(true)
{
if(m_bIsHost)
{
//HOST
//SENDING
if(m_SharedMem.m_bIsSending == true)
{
Incription(m_SharedMem.m_cSendingPacket);
send(ClientSocket, m_SharedMem.m_cSendingPacket, DEFAULT_BUFLEN, NULL);
m_SharedMem.m_bIsSending = false;
}
}
else//Client
{ //SENDING
if(m_SharedMem.m_bIsSending == true)
{
Incription(m_SharedMem.m_cSendingPacket);
send(ConnectSocket, m_SharedMem.m_cSendingPacket, DEFAULT_BUFLEN, NULL);
m_SharedMem.m_bIsSending = false;
}
}
}
}
int NetworkManager::BeginRecievingStream(void *arg)
{
NetworkManager* nm;
nm = (NetworkManager*)arg;
nm->RecieveUpdate();
return 1;
}
int NetworkManager::BeginSendingStream(void *arg)
{
NetworkManager* nm;
nm = (NetworkManager*)arg;
nm->SendUpdate();
return 1;
}
bool NetworkManager::Host()
{
return m_bIsHost;
}
void NetworkManager::Incription(char pack[])
{
#ifdef INCRIPTION
for(int i = 0; i < DEFAULT_BUFLEN; ++i)
{
pack[i] ^= INCRIPTION_KEY;
}
#endif
}
void NetworkManager::Decription(char pack[])
{
#ifdef INCRIPTION
for(int i = 0; i < DEFAULT_BUFLEN; ++i)
{
pack[i] ^= INCRIPTION_KEY;
}
#endif
}
GamePlay Manager CPP
#include "GameManager.h"
#include "Player.h"
#include "Bullet.h"
#include
//#include "al.h"
//#include "alc.h"
//#include "alut.h"
using namespace std;
GameManager::GameManager()
{
num_history = 0;
//muc = NULL;
physics_manager = new PhysicsManager();
projectiles = new GameObject*[MAXBULLETS];
num_bullets = 0;
player = NULL;
player2 = NULL;
m_PlayerController = NULL;
screen = NULL;
game_objs = NULL;
num_objs = 0;
keys = new char[action_size];
keys2 = new char[action_size];
for (int i=0; i 0)
{
SDL_JoystickEventState(SDL_ENABLE);
joystick = SDL_JoystickOpen(0);
}
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
if ( !screen )
return false;
//1. open a file level file
ifstream input;
input.open(filename.c_str());
//1.5 verify opened
if (!input)
{
//cout << "ERROR 404: FILE NOT FOUND!!";
return false;
}
//2 use file
input >> size;
game_objs = new GameObject*[size + MAXBULLETS];
//gameObjects.resize(size);
//use file
while(input >> name >> location >> x >> y >> sheet >> physics)
{
spawnObject(name, location, x,y,sheet,physics);
}
//3 close file
input.close();
generateBullets();
num_bullets = 0;
t0 = SDL_GetTicks();
return true;
}
void GameManager::spawnObject( std::string name, std::string location,
int x, int y, std::string sheet, char physics)
{
//game object types
if (name == "player")
{
player = new Player(name, location, x, y);
game_objs[num_objs] = player;
}
else if(name == "player2")
{
player2 = new Player(name, location, x, y);
game_objs[num_objs] = player2;
}
else if (name == "bullet")
{
game_objs[num_objs] = new Bullet(name, location, x, y);
((Bullet*)game_objs[num_objs])->deactivate();
projectiles[num_bullets++] = game_objs[num_objs];
}
else if (name == "health")
{
((Player*)player)->m_HealthBar = new GameObject(name, location, x, y);
game_objs[num_objs] = ((Player*)player)->m_HealthBar;
}
else if (name == "health2")
{
((Player*)player2)->m_HealthBar = new GameObject(name, location, x, y);
game_objs[num_objs] = ((Player*)player2)->m_HealthBar;
}
else if (name == "ammo")
{
((Player*)player)->m_AmmoBar = new GameObject(name, location, x, y);
((Player*)player)->m_AmmoBarCopy = new GameObject(name, location, x, y);
game_objs[num_objs] = ((Player*)player)->m_AmmoBar;
num_objs++;
((Player*)player2)->m_AmmoBar = new GameObject(name, location, x, y);
((Player*)player2)->m_AmmoBarCopy = new GameObject(name, location, x, y);
game_objs[num_objs] = ((Player*)player2)->m_AmmoBar;
}
else
{
game_objs[num_objs] = new GameObject(name, location, x, y);
if(game_objs[num_objs]->name == "RedWins")
game_objs[num_objs]->m_bRender = false;
if(game_objs[num_objs]->name == "BlueWins")
game_objs[num_objs]->m_bRender = false;
}
//spritesheet
if (sheet != "#")
{
game_objs[num_objs]->setSpriteSheet(sheet);
}
//physics object
if (physics == 'p')
{
physics_manager->add(game_objs[num_objs]);
if(game_objs[num_objs]->name =="Tube")
{
std::cout<name<move(UP);
if (keys[LEFT])
m_PlayerController->move(LEFT);
if (keys[DOWN])
m_PlayerController->move(DOWN);
if (keys[RIGHT])
m_PlayerController->move(RIGHT);
if (keys[JUMP])
m_PlayerController->move(JUMP);
if (keys[FIRE])
m_PlayerController->move(FIRE, getBullet() );
//Clamp
if(m_PlayerController->pos.x > SCREEN_WIDTH)
m_PlayerController->pos.x = SCREEN_WIDTH;
if(m_PlayerController->pos.x < 0)
m_PlayerController->pos.x = 0;
if(m_PlayerController->pos.y > SCREEN_HEIGHT)
m_PlayerController->pos.y = SCREEN_HEIGHT;
if(m_PlayerController->pos.y - m_PlayerController->h < 0)
m_PlayerController->pos.y = 0 + m_PlayerController->h;
//std::cout<< m_PlayerController->direction<Host())///////////////////////////////H O S T///////////////////////////////////////////////////////////////////////
{
//Reciving Data
if (m_pNetworkManager->m_SharedMem.m_bIsRecieving == false)
{
//Copys ALL Netwroks REC data to Packet Data
memcpy(packetData + packetOffset, m_pNetworkManager->m_SharedMem.m_cRecievingPacket, DEFAULT_BUFLEN);
memcpy(&player2->pos, packetData + packetOffset , sizeof(player2->pos));
packetOffset += sizeof(player2->pos);
//Res player2's dir
memcpy( &player2->direction, packetData + packetOffset , sizeof(player2->direction));
packetOffset += sizeof(player2->direction);
//Make MemSharedMem to true
memset(m_pNetworkManager->m_SharedMem.m_cRecievingPacket, 0, DEFAULT_BUFLEN);
m_pNetworkManager->m_SharedMem.m_bIsRecieving = true;
}
//Sending Data
if (m_pNetworkManager->m_SharedMem.m_bIsSending == false)
{
//PREPBlock
//Clear the NM Buffer, PacketData Buffer,and Offset Befor Sending
memset(m_pNetworkManager->m_SharedMem.m_cSendingPacket, 0, DEFAULT_BUFLEN);
memset(packetData, 0, DEFAULT_BUFLEN);
packetOffset = 0;
//~PREPBlock
//TOtAL copys = 4
//COPY Player1 pos to PacketData
memcpy(packetData + packetOffset, &m_PlayerController->pos, sizeof(m_PlayerController->pos));
packetOffset += sizeof(m_PlayerController->pos);
//Copy Player1 AnimDirection to Paket Data
memcpy(packetData + packetOffset, &m_PlayerController->direction , sizeof(m_PlayerController->direction));
packetOffset += sizeof(((Player*)m_PlayerController)->direction);
//Copy Player1 Health
memcpy(packetData + packetOffset,&((Player*)m_PlayerController)->health, sizeof(((Player*)m_PlayerController)->health));
packetOffset += sizeof(((Player*)m_PlayerController)->health);
//Copy Player2 Health
memcpy(packetData + packetOffset,&((Player*)player2)->health, sizeof(((Player*)player2)->health));
packetOffset += sizeof(((Player*)player2)->health);
//The Copy the packet to the Network Manager
memcpy(m_pNetworkManager->m_SharedMem.m_cSendingPacket, packetData, packetOffset );
//Make MemSharedMem to true
m_pNetworkManager->m_SharedMem.m_bIsSending = true;
}
}
else///////////////////////////////C L I E N T///////////////////////////////////////////////////////////////////////
{
//Client Recieving Data
if(m_pNetworkManager->m_SharedMem.m_bIsRecieving == false)
{
//Copys ALL Netwroks REC data to Packet Data
memcpy(packetData , m_pNetworkManager->m_SharedMem.m_cRecievingPacket, DEFAULT_BUFLEN);
//TotAL copys = 4
//Rec player 1 pos
memcpy(&player->pos, packetData + packetOffset , sizeof(player->pos));
packetOffset += sizeof(player->pos);
//Res player1's dir
memcpy( &player->direction, packetData + packetOffset , sizeof(player->direction));
packetOffset += sizeof(player->direction);
//Copy Player 1's health
memcpy(&((Player*)player)->health, packetData + packetOffset, sizeof(((Player*)player)->health));
packetOffset += sizeof(((Player*)player)->health);
//Copy Clients Health
memcpy(&((Player*)m_PlayerController)->health, packetData + packetOffset, sizeof(((Player*)player)->health));
packetOffset += sizeof(((Player*)player)->health);
//clear the buffer and unlocket for NM to have data sent
memset(m_pNetworkManager->m_SharedMem.m_cRecievingPacket,0,DEFAULT_BUFLEN);
m_pNetworkManager->m_SharedMem.m_bIsRecieving = true;
}
//Client Sending Data
if(m_pNetworkManager->m_SharedMem.m_bIsSending == false)
{
//PREPBlock
//Clear the NM Buffer, PacketData Buffer,and Offset Befor Sending
memset(m_pNetworkManager->m_SharedMem.m_cSendingPacket, 0, DEFAULT_BUFLEN);
memset(packetData, 0, DEFAULT_BUFLEN);
packetOffset = 0;
//~PREPBlock
//COPY Player2 pos to PacketData
memcpy(packetData + packetOffset, &m_PlayerController->pos, sizeof(m_PlayerController->pos));
packetOffset += sizeof(m_PlayerController->pos);
//Copy Player2 AnimDirection to Paket Data
memcpy(packetData + packetOffset, &m_PlayerController->direction , sizeof(m_PlayerController->direction));
packetOffset += sizeof(m_PlayerController->direction);
//Then Copy the packet to the Network Manager
memcpy(m_pNetworkManager->m_SharedMem.m_cSendingPacket, packetData, packetOffset );
//Make MemSharedMem to true
m_pNetworkManager->m_SharedMem.m_bIsSending = true;
}
}
}//~Network Code///////////////////////////////////////////////////////////////////////////////////////////////////////////////
physics_manager->update();
Uint32 t1 = SDL_GetTicks();
unsigned int delta_time = (unsigned int)(t1 - t0);
t0 = t1;
SDL_FillRect(screen, NULL, 0);
if(m_pNetworkManager!= NULL)
{
if(m_pNetworkManager->Host())
{
if(player2->direction & (1 << FIRE) )
{
player2->Fire(getBullet());
}
}
else
{
if(player->direction & (1 << FIRE) )
{
player->Fire(getBullet());
}
}
}
//update all the objects and Render in layers
for(int i=1; ihealth<= 0)
{
if(game_objs[i]->name == "RedWins")
{
game_objs[i]->m_bRender = true;
}
}
if(((Player*)player2)->health <= 0)
{
if(game_objs[i]->name == "BlueWins")
{
game_objs[i]->m_bRender = true;
}
}
game_objs[i]->update( screen, delta_time );
}
if ( SDL_Flip( screen ) == -1)
return false;
return true;
}
void shift(int history[])
{
memcpy(history, history+1, sizeof(int)*2);
}
void GameManager::keyCombo()
{
for (int direction=0; direction<5; direction++)
{
if (keys[direction])
{
if (num_history == 0)
{
history[num_history] = direction;
num_history++;
break;
}
else
{
if (history[num_history-1] != direction)
{
if (num_history == 3)
{
shift(history);
num_history--;
}
history[num_history] = direction;
num_history++;
break;
}
}
}
}
if (num_history >= 3)
{
if (history[num_history-3] == DOWN &&
(history[num_history-2] == RIGHT || history[num_history-2] == LEFT)&&
history[num_history-1] == FIRE)
{
keys[JUMP] = true;
num_history = 0;
}
}
else
keys[JUMP] = false;
}
void GameManager::moveJoystick(SDL_Event& joyevent)
{
//left right axis
if (joyevent.jaxis.axis == 0)
{
if (joyevent.jaxis.value < -3200)
keys[LEFT] = true;
else
keys[LEFT] = false;
if (joyevent.jaxis.value > 3200)
keys[RIGHT] = true;
else
keys[RIGHT] = false;
}
//up down axis
else if (joyevent.jaxis.axis == 1)
{
if (joyevent.jaxis.value < -3200)
keys[UP] = true;
else
keys[UP] = false;
if (joyevent.jaxis.value > 3200)
keys[DOWN] = true;
else
keys[DOWN] = false;
}
}
/*
set flags for key presses
*/
bool GameManager::keyUpdate()
{
SDL_Event key_event;
while(SDL_PollEvent(&key_event))
{
switch(key_event.type)
{
case SDL_JOYAXISMOTION:
moveJoystick(key_event);
break;
case SDL_JOYBUTTONDOWN:
if (key_event.jbutton.button == 0)
keys[FIRE] = true;
break;
case SDL_JOYBUTTONUP:
if (key_event.jbutton.button == 0)
keys[FIRE] = false;
break;
//keydown
case SDL_KEYDOWN:
if (!keyDown(key_event.key.keysym.sym))
return false;
break;
//key up
case SDL_KEYUP:
if (!keyUp(key_event.key.keysym.sym))
return false;
break;
//move mouse
case SDL_MOUSEMOTION:
//player->x = key_event.motion.x;
//player->y = key_event.motion.y;
break;
case SDL_MOUSEBUTTONDOWN:
key_event.button.button;
key_event.button.x;
key_event.button.y;
break;
//quit
case SDL_QUIT:
return false;
break;
default:
break;
}
}
return true;
}
bool GameManager::keyDown(SDLKey key)
{
switch(key)
{
//SDL_GetKeyName(key_event.key.keysym.sym);
//SDLK_RETURN
//SDLK_ESCAPE
//SDLK_SPACE
//SDLK_a ... SDLK_z
//SDLK_0 ... SDLK_9
case SDLK_0:
if(m_pNetworkManager== NULL) //Host
{
m_pNetworkManager = new NetworkManager(true);
m_pThreadNM[0] = SDL_CreateThread( NetworkManager::BeginRecievingStream, (void*)m_pNetworkManager);
m_pThreadNM[1] = SDL_CreateThread( NetworkManager::BeginSendingStream, (void*)m_pNetworkManager);
m_PlayerController = player;
}
break;
case SDLK_1:
if(m_pNetworkManager== NULL) //Client
{
m_pNetworkManager = new NetworkManager(false);
m_pThreadNM[0] = SDL_CreateThread( NetworkManager::BeginRecievingStream, (void*)m_pNetworkManager);
m_pThreadNM[1] = SDL_CreateThread( NetworkManager::BeginSendingStream, (void*)m_pNetworkManager);
m_PlayerController = player2;
}
break;
case SDLK_LEFT:
case 'a':
keys[LEFT] = true;
break;
case SDLK_RIGHT:
case 'd':
keys[RIGHT] = true;
break;
case SDLK_UP:
case 'w':
keys[UP] = true;
break;
case SDLK_DOWN:
case 's':
keys[DOWN] = true;
break;
case SDLK_SPACE:
keys[JUMP] = true;
break;
case 'q':
//alSourcePlay (helloSource);
keys[FIRE] = true;
break;
//quit
case 'p':
//if (!muc)
//{
/*char blah;
blah = (*this)
//Mix_Chunk * chunk = Mix_LoadWAV("sounds/sample.wav");
//muc = Mix_LoadMUS("sounds/fart.wav");
char * error;
error = SDL_GetError();
if (!muc)
exit(-22);
Mix_PlayMusic(muc, 0);
*/
//Mix_HookMusicFinished(this->musicDone);
//}
break;
case SDLK_ESCAPE:
return false;
break;
default:
break;
}
return true;
}
bool GameManager::keyUp(SDLKey key)
{
switch(key)
{
//SDL_GetKeyName(key_event.key.keysym.sym);
//SDLK_RETURN
//SDLK_ESCAPE
//SDLK_SPACE
//SDLK_a ... SDLK_z
//SDLK_0 ... SDLK_9
case SDLK_LEFT:
case 'a':
keys[LEFT] = false;
break;
case SDLK_RIGHT:
case 'd':
keys[RIGHT] = false;
break;
case SDLK_UP:
case 'w':
keys[UP] = false;
break;
case SDLK_DOWN:
case 's':
keys[DOWN] = false;
break;
case SDLK_SPACE:
//alSourcePlay (bloop);
keys[JUMP] = false;
//game_objs[1].y++;
break;
case 'q':
keys[FIRE] = false;
break;
}
return true;
}
void GameManager::musicDone()
{
//Mix_HaltMusic();
//Mix_FreeMusic(muc);
//muc = NULL;
}
void GameManager::quit()
{
for (int i=0; igetSurface() );
delete game_objs[i];
}
//delete game_objs;
SDL_Quit();
}
void GameManager::generateBullets()
{
if (MAXBULLETS > 0)
{
if (projectiles[0])
{
for (int i=1; ilocation, -10, -10, "#", 'p');
}
}
}
}
GameObject* GameManager::getBullet()
{
num_bullets %= MAXBULLETS;
return projectiles[num_bullets++];
}