mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
Hello WWWWWWorld!
This commit is contained in:
145
desktop_version/src/BinaryBlob.cpp
Normal file
145
desktop_version/src/BinaryBlob.cpp
Normal file
@@ -0,0 +1,145 @@
|
||||
#include "BinaryBlob.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* FIXME: Abstract to FileSystemUtils! */
|
||||
#include <physfs.h>
|
||||
|
||||
binaryBlob::binaryBlob()
|
||||
{
|
||||
numberofHeaders = 0;
|
||||
for (int i = 0; i < 128; i += 1)
|
||||
{
|
||||
m_headers[i].valid = false;
|
||||
|
||||
for (int j = 0; j < 48; j += 1)
|
||||
{
|
||||
m_headers[i].name[j] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VVV_COMPILEMUSIC
|
||||
void binaryBlob::AddFileToBinaryBlob(const char* _path)
|
||||
{
|
||||
long size;
|
||||
char * memblock;
|
||||
|
||||
FILE *file = fopen(_path, "rb");
|
||||
if (file != NULL)
|
||||
{
|
||||
fseek(file, 0, SEEK_END);
|
||||
size = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
memblock = (char*) malloc(size);
|
||||
fread(memblock, 1, size, file);
|
||||
|
||||
fclose(file);
|
||||
|
||||
printf("The complete file size: %li\n", size);
|
||||
|
||||
m_memblocks[numberofHeaders] = memblock;
|
||||
for (int i = 0; _path[i]; i += 1)
|
||||
{
|
||||
m_headers[numberofHeaders].name[i] = _path[i];
|
||||
}
|
||||
|
||||
m_headers[numberofHeaders].valid = true;
|
||||
m_headers[numberofHeaders].size = size;
|
||||
numberofHeaders += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unable to open file\n");
|
||||
}
|
||||
}
|
||||
|
||||
void binaryBlob::writeBinaryBlob(const char* _name)
|
||||
{
|
||||
FILE *file = fopen(_name, "wb");
|
||||
if (file != NULL)
|
||||
{
|
||||
fwrite((char*) &m_headers, 1, sizeof(resourceheader) * 128, file);
|
||||
|
||||
for (int i = 0; i < numberofHeaders; i += 1)
|
||||
{
|
||||
fwrite(m_memblocks[i], 1, m_headers[i].size, file);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unable to open new file for writing. Feels bad.\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool binaryBlob::unPackBinary(const char* name)
|
||||
{
|
||||
PHYSFS_sint64 size;
|
||||
|
||||
PHYSFS_File *handle = PHYSFS_openRead(name);
|
||||
if (handle == NULL)
|
||||
{
|
||||
printf("Unable to open file %s\n", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
size = PHYSFS_fileLength(handle);
|
||||
|
||||
PHYSFS_read(handle, &m_headers, 1, sizeof(resourceheader) * 128);
|
||||
|
||||
int offset = 0 + (sizeof(resourceheader) * 128);
|
||||
|
||||
for (int i = 0; i < 128; i += 1)
|
||||
{
|
||||
if (m_headers[i].valid)
|
||||
{
|
||||
PHYSFS_seek(handle, offset);
|
||||
m_memblocks[i] = (char*) malloc(m_headers[i].size);
|
||||
PHYSFS_read(handle, m_memblocks[i], 1, m_headers[i].size);
|
||||
offset += m_headers[i].size;
|
||||
}
|
||||
}
|
||||
PHYSFS_close(handle);
|
||||
|
||||
printf("The complete reloaded file size: %li\n", size);
|
||||
|
||||
for (int i = 0; i < 128; i += 1)
|
||||
{
|
||||
if (m_headers[i].valid == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
printf("%s unpacked\n", m_headers[i].name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int binaryBlob::getIndex(const char* _name)
|
||||
{
|
||||
for (int i = 0; i < 128; i += 1)
|
||||
{
|
||||
if (strcmp(_name, m_headers[i].name) == 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int binaryBlob::getSize(int _index)
|
||||
{
|
||||
return m_headers[_index].size;
|
||||
}
|
||||
|
||||
char* binaryBlob::getAddress(int _index)
|
||||
{
|
||||
return m_memblocks[_index];
|
||||
}
|
||||
41
desktop_version/src/BinaryBlob.h
Normal file
41
desktop_version/src/BinaryBlob.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef BINARYBLOB_H
|
||||
#define BINARYBLOB_H
|
||||
|
||||
/* Laaaazyyyyyyy -flibit */
|
||||
// #define VVV_COMPILEMUSIC
|
||||
|
||||
struct resourceheader
|
||||
{
|
||||
char name[48];
|
||||
int start;
|
||||
int size;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
class binaryBlob
|
||||
{
|
||||
public:
|
||||
binaryBlob();
|
||||
|
||||
#ifdef VVV_COMPILEMUSIC
|
||||
void AddFileToBinaryBlob(const char* _path);
|
||||
|
||||
void writeBinaryBlob(const char* _name);
|
||||
#endif
|
||||
|
||||
bool unPackBinary(const char* _name);
|
||||
|
||||
int getIndex(const char* _name);
|
||||
|
||||
int getSize(int _index);
|
||||
|
||||
char* getAddress(int _index);
|
||||
|
||||
private:
|
||||
int numberofHeaders;
|
||||
resourceheader m_headers[128];
|
||||
char* m_memblocks[128];
|
||||
};
|
||||
|
||||
|
||||
#endif /* BINARYBLOB_H */
|
||||
36
desktop_version/src/BlockV.cpp
Normal file
36
desktop_version/src/BlockV.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "BlockV.h"
|
||||
|
||||
blockclass::blockclass()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void blockclass::clear()
|
||||
{
|
||||
active = false;
|
||||
type = 0;
|
||||
trigger = 0;
|
||||
|
||||
xp = 0;
|
||||
yp = 0;
|
||||
wp = 0;
|
||||
hp = 0;
|
||||
rect.x = xp;
|
||||
rect.y = yp;
|
||||
rect.w = wp;
|
||||
rect.h = hp;
|
||||
|
||||
prompt = "";
|
||||
script = "";
|
||||
r = 0;
|
||||
g = 0;
|
||||
b = 0;
|
||||
}
|
||||
|
||||
void blockclass::rectset(const int xi, const int yi, const int wi, const int hi)
|
||||
{
|
||||
rect.x = xi;
|
||||
rect.y = yi;
|
||||
rect.w = wi;
|
||||
rect.h = hi;
|
||||
}
|
||||
31
desktop_version/src/BlockV.h
Normal file
31
desktop_version/src/BlockV.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef BLOCKV_H
|
||||
#define BLOCKV_H
|
||||
|
||||
#include "SDL.h"
|
||||
#include <string>
|
||||
|
||||
class blockclass
|
||||
{
|
||||
public:
|
||||
blockclass();
|
||||
|
||||
void clear();
|
||||
|
||||
void rectset(const int xi, const int yi, const int wi, const int hi);
|
||||
public:
|
||||
//Fundamentals
|
||||
bool active;
|
||||
SDL_Rect rect;
|
||||
int type;
|
||||
int trigger;
|
||||
int xp, yp, wp, hp;
|
||||
std::string script, prompt;
|
||||
int r, g, b;
|
||||
|
||||
//These would come from the sprite in the flash
|
||||
float x;
|
||||
float y;
|
||||
|
||||
};
|
||||
|
||||
#endif /* BLOCKV_H */
|
||||
88
desktop_version/src/Ent.cpp
Normal file
88
desktop_version/src/Ent.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
#include "Ent.h"
|
||||
|
||||
entclass::entclass()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void entclass::clear()
|
||||
{
|
||||
// Set all values to a default, required for creating a new entity
|
||||
active = false;
|
||||
invis = false;
|
||||
type = 0;
|
||||
size = 0;
|
||||
tile = 0;
|
||||
rule = 0;
|
||||
state = 0;
|
||||
statedelay = 0;
|
||||
life = 0;
|
||||
colour = 0;
|
||||
para = 0;
|
||||
behave = 0;
|
||||
animate = 0;
|
||||
|
||||
xp = 0;
|
||||
yp = 0;
|
||||
ax = 0;
|
||||
ay = 0;
|
||||
vx = 0;
|
||||
vy = 0;
|
||||
w = 16;
|
||||
h = 16;
|
||||
cx = 0;
|
||||
cy = 0;
|
||||
newxp = 0;
|
||||
newyp = 0;
|
||||
|
||||
x1 = 0;
|
||||
y1 = 0;
|
||||
x2 = 320;
|
||||
y2 = 240;
|
||||
|
||||
jumping = false;
|
||||
gravity = false;
|
||||
onground = 0;
|
||||
onroof = 0;
|
||||
jumpframe = 0;
|
||||
|
||||
onentity = 0;
|
||||
harmful = false;
|
||||
onwall = 0;
|
||||
onxwall = 0;
|
||||
onywall = 0;
|
||||
isplatform = false;
|
||||
|
||||
framedelay = 0;
|
||||
drawframe = 0;
|
||||
walkingframe = 0;
|
||||
dir = 0;
|
||||
actionframe = 0;
|
||||
}
|
||||
|
||||
bool entclass::outside()
|
||||
{
|
||||
// Returns true if any point of the entity is outside the map.
|
||||
// Adjusts velocity for a clean collision.
|
||||
if (xp < x1)
|
||||
{
|
||||
xp = x1;
|
||||
return true;
|
||||
}
|
||||
if (yp < y1)
|
||||
{
|
||||
yp = y1;
|
||||
return true;
|
||||
}
|
||||
if (xp + w > x2)
|
||||
{
|
||||
xp = x2 - w;
|
||||
return true;
|
||||
}
|
||||
if (yp + h > y2)
|
||||
{
|
||||
yp = y2 - h;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
44
desktop_version/src/Ent.h
Normal file
44
desktop_version/src/Ent.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef ENT_H
|
||||
#define ENT_H
|
||||
|
||||
class entclass
|
||||
{
|
||||
public:
|
||||
entclass();
|
||||
|
||||
void clear();
|
||||
|
||||
bool outside();
|
||||
|
||||
public:
|
||||
//Fundamentals
|
||||
bool active, invis;
|
||||
int type, size, tile, rule;
|
||||
int state, statedelay;
|
||||
int behave, animate;
|
||||
float para;
|
||||
int life, colour;
|
||||
|
||||
//Position and velocity
|
||||
int oldxp, oldyp;
|
||||
float ax, ay, vx, vy;
|
||||
int cx, cy, w, h;
|
||||
float newxp, newyp;
|
||||
bool isplatform;
|
||||
int x1,y1,x2,y2;
|
||||
//Collision Rules
|
||||
int onentity;
|
||||
bool harmful;
|
||||
int onwall, onxwall, onywall;
|
||||
|
||||
//Platforming specific
|
||||
bool jumping;
|
||||
bool gravity;
|
||||
int onground, onroof;
|
||||
int jumpframe;
|
||||
//Animation
|
||||
int framedelay, drawframe, walkingframe, dir, actionframe;
|
||||
int yp;int xp;
|
||||
};
|
||||
|
||||
#endif /* ENT_H */
|
||||
5528
desktop_version/src/Entity.cpp
Normal file
5528
desktop_version/src/Entity.cpp
Normal file
File diff suppressed because it is too large
Load Diff
245
desktop_version/src/Entity.h
Normal file
245
desktop_version/src/Entity.h
Normal file
@@ -0,0 +1,245 @@
|
||||
#ifndef ENTITY_H
|
||||
#define ENTITY_H
|
||||
|
||||
#include "Maths.h"
|
||||
#include "Ent.h"
|
||||
#include "BlockV.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#define rn( rx, ry) ((rx) + ((ry) * 100))
|
||||
|
||||
enum
|
||||
{
|
||||
BLOCK = 0,
|
||||
TRIGGER = 1,
|
||||
DAMAGE = 2,
|
||||
DIRECTIONAL = 3,
|
||||
SAFE = 4,
|
||||
ACTIVITY = 5
|
||||
};
|
||||
|
||||
class mapclass;
|
||||
class musicclass;
|
||||
class Graphics;
|
||||
class Game;
|
||||
class UtilityClass;
|
||||
|
||||
class entityclass
|
||||
{
|
||||
public:
|
||||
void init();
|
||||
|
||||
void resetallflags();
|
||||
|
||||
void resetflags();
|
||||
|
||||
void confirmflags();
|
||||
|
||||
void changecollect(int t, int s);
|
||||
|
||||
void changecustomcollect(int t, int s);
|
||||
|
||||
void changeflag(int t, int s);
|
||||
|
||||
void fatal_top()
|
||||
{
|
||||
createblock(DAMAGE, -8, -8, 384, 16);
|
||||
}
|
||||
void fatal_bottom()
|
||||
{
|
||||
createblock(DAMAGE, -8, 224, 384, 16);
|
||||
}
|
||||
void fatal_left()
|
||||
{
|
||||
createblock(DAMAGE, -8, -8, 16, 260);
|
||||
}
|
||||
void fatal_right()
|
||||
{
|
||||
createblock(DAMAGE, 312, -8, 16, 260);
|
||||
}
|
||||
|
||||
void setblockcolour(int t, std::string col);
|
||||
|
||||
int swncolour(int t );
|
||||
|
||||
void swnenemiescol(int t);
|
||||
|
||||
void gravcreate(Game& game, int ypos, int dir, int xoff = 0, int yoff = 0);
|
||||
|
||||
void generateswnwave(Game& game, UtilityClass& help, int t);
|
||||
|
||||
void createblock(int t, int xp, int yp, int w, int h, int trig = 0);
|
||||
|
||||
void removeallblocks();
|
||||
|
||||
void removeblock(int t);
|
||||
|
||||
void removeblockat(int x, int y);
|
||||
|
||||
void removetrigger(int t);
|
||||
|
||||
void copylinecross(int t);
|
||||
|
||||
void revertlinecross(int t, int s);
|
||||
|
||||
bool gridmatch(int p1, int p2, int p3, int p4, int p11, int p21, int p31, int p41);
|
||||
|
||||
int crewcolour(int t);
|
||||
|
||||
void setenemyroom(int t, int rx, int ry);
|
||||
|
||||
void setenemy(int t, int r);
|
||||
|
||||
void settreadmillcolour(int t, int rx, int ry);
|
||||
|
||||
void createentity(Game& game, float xp, float yp, int t, float vx = 0, float vy = 0,
|
||||
int p1 = 0, int p2 = 0, int p3 = 320, int p4 = 240 );
|
||||
|
||||
bool updateentities(int i, UtilityClass& help, Game& game, musicclass& music);
|
||||
|
||||
void animateentities(int i, Game& game, UtilityClass& help);
|
||||
|
||||
bool gettype(int t);
|
||||
|
||||
int getcompanion(int t);
|
||||
|
||||
int getplayer();
|
||||
|
||||
int getscm();
|
||||
|
||||
int getlineat(int t);
|
||||
|
||||
int getcrewman(int t);
|
||||
int getcustomcrewman(int t);
|
||||
|
||||
int getteleporter();
|
||||
|
||||
void rectset(int xi, int yi, int wi, int hi);
|
||||
|
||||
void rect2set(int xi, int yi, int wi, int hi);
|
||||
|
||||
bool entitycollide(int a, int b);
|
||||
|
||||
bool checkdirectional(int t);
|
||||
|
||||
bool checkdamage();
|
||||
|
||||
bool scmcheckdamage();
|
||||
|
||||
void settemprect(int t);
|
||||
|
||||
int checktrigger();
|
||||
|
||||
int checkactivity();
|
||||
|
||||
int getgridpoint(int t);
|
||||
|
||||
bool cblocks(int t);
|
||||
|
||||
bool checkplatform();
|
||||
|
||||
bool checkblocks();
|
||||
|
||||
bool checktowerspikes(int t, mapclass& map);
|
||||
|
||||
bool checkwall(mapclass& map);
|
||||
|
||||
float hplatformat();
|
||||
|
||||
int yline(int a, int b);
|
||||
|
||||
bool entityhlinecollide(int t, int l);
|
||||
|
||||
bool entityvlinecollide(int t, int l);
|
||||
|
||||
bool entitywarphlinecollide(int t, int l);
|
||||
bool entitywarpvlinecollide(int t, int l);
|
||||
|
||||
void customwarplinecheck(int i);
|
||||
|
||||
float entitycollideplatformroof(mapclass& map, int t);
|
||||
|
||||
float entitycollideplatformfloor(mapclass& map, int t);
|
||||
|
||||
bool entitycollidefloor(mapclass& map, int t);
|
||||
|
||||
bool entitycollideroof(mapclass& map, int t);
|
||||
|
||||
bool testwallsx(int t, mapclass& map, int tx, int ty);
|
||||
|
||||
bool testwallsy(int t, mapclass& map, float tx, float ty);
|
||||
|
||||
void fixfriction(int t, float xfix, float xrate, float yrate);
|
||||
|
||||
void applyfriction(int t, float xrate, float yrate);
|
||||
|
||||
void cleanup();
|
||||
|
||||
void updateentitylogic(int t, Game& game);
|
||||
|
||||
|
||||
void entitymapcollision(int t, mapclass& map);
|
||||
|
||||
void movingplatformfix(int t, mapclass& map);
|
||||
|
||||
void scmmovingplatformfix(int t, mapclass& map);
|
||||
|
||||
void hormovingplatformfix(int t, mapclass& map);
|
||||
|
||||
void entitycollisioncheck(Graphics& dwgfx, Game& game, mapclass& map, musicclass& music);
|
||||
|
||||
|
||||
std::vector<entclass> entities;
|
||||
|
||||
int nentity;
|
||||
|
||||
std::vector<entclass> linecrosskludge;
|
||||
int nlinecrosskludge;
|
||||
|
||||
point colpoint1, colpoint2;
|
||||
|
||||
int tempx, tempy, tempw, temph, temp, temp2;
|
||||
//public var tempx:int, tempy:int, tempw:int, temph:int, temp:int, temp2:int;
|
||||
int tpx1, tpy1, tpx2, tpy2;
|
||||
|
||||
SDL_Rect temprect, temprect2;
|
||||
|
||||
int x, k;
|
||||
float dx, dy, dr;
|
||||
|
||||
int px, py, linetemp;
|
||||
int activetrigger;
|
||||
|
||||
|
||||
std::vector<blockclass> blocks;
|
||||
std::vector<int> flags;
|
||||
std::vector<int> collect;
|
||||
std::vector<int> customcollect;
|
||||
|
||||
int nblocks;
|
||||
bool skipblocks, skipdirblocks;
|
||||
|
||||
int platformtile;
|
||||
bool vertplatforms, horplatforms;
|
||||
|
||||
// :(
|
||||
bool nearelephant, upsetmode;
|
||||
int upset;
|
||||
|
||||
//Trophy Text
|
||||
int trophytext, trophytype;
|
||||
|
||||
//Secret lab scripts
|
||||
int altstates;
|
||||
|
||||
//Custom stuff
|
||||
int customenemy;
|
||||
int customplatformtile;
|
||||
bool customwarpmode, customwarpmodevon, customwarpmodehon;
|
||||
std::string customscript;
|
||||
int customcrewmoods[6];
|
||||
};
|
||||
|
||||
#endif /* ENTITY_H */
|
||||
11
desktop_version/src/Enums.h
Normal file
11
desktop_version/src/Enums.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef ENUMGAME_H
|
||||
#define ENUMGAME_H
|
||||
|
||||
enum
|
||||
{
|
||||
|
||||
GAMEMODE, TITLEMODE, CLICKTOSTART, FOCUSMODE, MAPMODE, TELEPORTERMODE, GAMECOMPLETE, GAMECOMPLETE2, EDITORMODE, PRELOADER
|
||||
|
||||
};
|
||||
|
||||
#endif /* ENUMGAME_H */
|
||||
363
desktop_version/src/FileSystemUtils.cpp
Normal file
363
desktop_version/src/FileSystemUtils.cpp
Normal file
@@ -0,0 +1,363 @@
|
||||
#include "FileSystemUtils.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <physfs.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
#define mkdir(a, b) CreateDirectory(a, NULL)
|
||||
#define VNEEDS_MIGRATION (mkdirResult != 0)
|
||||
#elif defined(__linux__) || defined(__APPLE__)
|
||||
#include <sys/stat.h>
|
||||
#include <limits.h>
|
||||
#define VNEEDS_MIGRATION (mkdirResult == 0)
|
||||
/* These are needed for PLATFORM_* crap */
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#define MAX_PATH PATH_MAX
|
||||
#endif
|
||||
|
||||
char saveDir[MAX_PATH];
|
||||
char levelDir[MAX_PATH];
|
||||
|
||||
void PLATFORM_getOSDirectory(char* output);
|
||||
void PLATFORM_migrateSaveData(char* output);
|
||||
void PLATFORM_copyFile(const char *oldLocation, const char *newLocation);
|
||||
|
||||
void FILESYSTEM_init(char *argvZero)
|
||||
{
|
||||
char output[MAX_PATH];
|
||||
int mkdirResult;
|
||||
|
||||
PHYSFS_init(argvZero);
|
||||
|
||||
/* Determine the OS user directory */
|
||||
PLATFORM_getOSDirectory(output);
|
||||
|
||||
/* Create base user directory, mount */
|
||||
mkdirResult = mkdir(output, 0777);
|
||||
|
||||
/* Mount our base user directory */
|
||||
PHYSFS_mount(output, NULL, 1);
|
||||
printf("Base directory: %s\n", output);
|
||||
|
||||
/* Create save directory */
|
||||
strcpy(saveDir, output);
|
||||
strcat(saveDir, "saves");
|
||||
strcat(saveDir, PHYSFS_getDirSeparator());
|
||||
mkdir(saveDir, 0777);
|
||||
printf("Save directory: %s\n", saveDir);
|
||||
|
||||
/* Create level directory */
|
||||
strcpy(levelDir, output);
|
||||
strcat(levelDir, "levels");
|
||||
strcat(levelDir, PHYSFS_getDirSeparator());
|
||||
mkdirResult |= mkdir(levelDir, 0777);
|
||||
printf("Level directory: %s\n", levelDir);
|
||||
|
||||
/* We didn't exist until now, migrate files! */
|
||||
if (VNEEDS_MIGRATION)
|
||||
{
|
||||
PLATFORM_migrateSaveData(output);
|
||||
}
|
||||
|
||||
/* Mount the stock content last */
|
||||
#ifdef _WIN32
|
||||
strcpy(output, PHYSFS_getBaseDir());
|
||||
strcat(output, "data.zip");
|
||||
#else
|
||||
strcpy(output, "data.zip");
|
||||
#endif
|
||||
PHYSFS_mount(output, NULL, 1);
|
||||
}
|
||||
|
||||
void FILESYSTEM_deinit()
|
||||
{
|
||||
PHYSFS_deinit();
|
||||
}
|
||||
|
||||
char *FILESYSTEM_getUserSaveDirectory()
|
||||
{
|
||||
return saveDir;
|
||||
}
|
||||
|
||||
char *FILESYSTEM_getUserLevelDirectory()
|
||||
{
|
||||
return levelDir;
|
||||
}
|
||||
|
||||
void FILESYSTEM_loadFileToMemory(const char *name, unsigned char **mem, size_t *len)
|
||||
{
|
||||
PHYSFS_File *handle = PHYSFS_openRead(name);
|
||||
if (handle == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PHYSFS_uint32 length = PHYSFS_fileLength(handle);
|
||||
if (len != NULL)
|
||||
{
|
||||
*len = length;
|
||||
}
|
||||
*mem = (unsigned char*) malloc(length);
|
||||
PHYSFS_read(handle, *mem, 1, length);
|
||||
PHYSFS_close(handle);
|
||||
}
|
||||
|
||||
void FILESYSTEM_freeMemory(unsigned char **mem)
|
||||
{
|
||||
free(*mem);
|
||||
*mem = NULL;
|
||||
}
|
||||
|
||||
std::vector<std::string> FILESYSTEM_getLevelDirFileNames()
|
||||
{
|
||||
std::vector<std::string> list;
|
||||
char **fileList = PHYSFS_enumerateFiles("/levels");
|
||||
char **i;
|
||||
std::string builtLocation;
|
||||
|
||||
for (i = fileList; *i != NULL; i++)
|
||||
{
|
||||
if (strcmp(*i, "data") == 0)
|
||||
{
|
||||
continue; /* FIXME: lolwut -flibit */
|
||||
}
|
||||
builtLocation = "levels/";
|
||||
builtLocation += *i;
|
||||
list.push_back(builtLocation);
|
||||
}
|
||||
|
||||
PHYSFS_freeList(fileList);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void PLATFORM_getOSDirectory(char* output)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
const char *homeDir = getenv("XDG_DATA_HOME");
|
||||
if (homeDir == NULL)
|
||||
{
|
||||
strcpy(output, PHYSFS_getUserDir());
|
||||
strcat(output, ".local/share/VVVVVV/");
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(output, homeDir);
|
||||
strcat(output, "/VVVVVV/");
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
strcpy(output, PHYSFS_getUserDir());
|
||||
strcat(output, "Library/Application Support/VVVVVV/");
|
||||
#elif defined(_WIN32)
|
||||
SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, output);
|
||||
strcat(output, "\\VVVVVV\\");
|
||||
#else
|
||||
#error See PLATFORM_getOSDirectory
|
||||
#endif
|
||||
}
|
||||
|
||||
void PLATFORM_migrateSaveData(char* output)
|
||||
{
|
||||
char oldLocation[MAX_PATH];
|
||||
char newLocation[MAX_PATH];
|
||||
char oldDirectory[MAX_PATH];
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
DIR *dir = NULL;
|
||||
struct dirent *de = NULL;
|
||||
DIR *subDir = NULL;
|
||||
struct dirent *subDe = NULL;
|
||||
char subDirLocation[MAX_PATH];
|
||||
const char *homeDir = getenv("HOME");
|
||||
if (homeDir == NULL)
|
||||
{
|
||||
/* Uhh, I don't want to get near this. -flibit */
|
||||
return;
|
||||
}
|
||||
strcpy(oldDirectory, homeDir);
|
||||
#if defined(__linux__)
|
||||
strcat(oldDirectory, "/.vvvvvv/");
|
||||
#elif defined(__APPLE__)
|
||||
strcat(oldDirectory, "/Documents/VVVVVV/");
|
||||
#endif
|
||||
dir = opendir(oldDirectory);
|
||||
if (!dir)
|
||||
{
|
||||
printf("Could not find directory %s\n", oldDirectory);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Migrating old savedata to new location...\n");
|
||||
for (de = readdir(dir); de != NULL; de = readdir(dir))
|
||||
{
|
||||
if ( strcmp(de->d_name, "..") == 0 ||
|
||||
strcmp(de->d_name, ".") == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#define COPY_SAVEFILE(name) \
|
||||
else if (strcmp(de->d_name, name) == 0) \
|
||||
{ \
|
||||
strcpy(oldLocation, oldDirectory); \
|
||||
strcat(oldLocation, name); \
|
||||
strcpy(newLocation, output); \
|
||||
strcat(newLocation, "saves/"); \
|
||||
strcat(newLocation, name); \
|
||||
PLATFORM_copyFile(oldLocation, newLocation); \
|
||||
}
|
||||
COPY_SAVEFILE("unlock.vvv")
|
||||
COPY_SAVEFILE("tsave.vvv")
|
||||
COPY_SAVEFILE("qsave.vvv")
|
||||
#undef COPY_SAVEFILE
|
||||
else if (strstr(de->d_name, ".vvvvvv.vvv") != NULL)
|
||||
{
|
||||
strcpy(oldLocation, oldDirectory);
|
||||
strcat(oldLocation, de->d_name);
|
||||
strcpy(newLocation, output);
|
||||
strcat(newLocation, "saves/");
|
||||
strcat(newLocation, de->d_name);
|
||||
PLATFORM_copyFile(oldLocation, newLocation);
|
||||
}
|
||||
else if (strstr(de->d_name, ".vvvvvv") != NULL)
|
||||
{
|
||||
strcpy(oldLocation, oldDirectory);
|
||||
strcat(oldLocation, de->d_name);
|
||||
strcpy(newLocation, output);
|
||||
strcat(newLocation, "levels/");
|
||||
strcat(newLocation, de->d_name);
|
||||
PLATFORM_copyFile(oldLocation, newLocation);
|
||||
}
|
||||
else if (strcmp(de->d_name, "Saves") == 0)
|
||||
{
|
||||
strcpy(subDirLocation, oldDirectory);
|
||||
strcat(subDirLocation, "Saves/");
|
||||
subDir = opendir(subDirLocation);
|
||||
if (!subDir)
|
||||
{
|
||||
printf("Could not open Saves/ subdir!\n");
|
||||
continue;
|
||||
}
|
||||
for (
|
||||
subDe = readdir(subDir);
|
||||
subDe != NULL;
|
||||
subDe = readdir(subDir)
|
||||
) {
|
||||
#define COPY_SAVEFILE(name) \
|
||||
(strcmp(subDe->d_name, name) == 0) \
|
||||
{ \
|
||||
strcpy(oldLocation, subDirLocation); \
|
||||
strcat(oldLocation, name); \
|
||||
strcpy(newLocation, output); \
|
||||
strcat(newLocation, "saves/"); \
|
||||
strcat(newLocation, name); \
|
||||
PLATFORM_copyFile(oldLocation, newLocation); \
|
||||
}
|
||||
if COPY_SAVEFILE("unlock.vvv")
|
||||
else if COPY_SAVEFILE("tsave.vvv")
|
||||
else if COPY_SAVEFILE("qsave.vvv")
|
||||
#undef COPY_SAVEFILE
|
||||
}
|
||||
}
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
WIN32_FIND_DATA findHandle;
|
||||
HANDLE hFind = NULL;
|
||||
char fileSearch[MAX_PATH];
|
||||
|
||||
/* Same place, different layout. */
|
||||
strcpy(oldDirectory, output);
|
||||
|
||||
/* In theory we don't need to worry about this, thanks case insensitivity!
|
||||
sprintf(fileSearch, "%s\\Saves\\*.vvv", oldDirectory);
|
||||
hFind = FindFirstFile(fileSearch, &findHandle);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("Could not find directory %s\\Saves\\\n", oldDirectory);
|
||||
}
|
||||
else do
|
||||
{
|
||||
if ((findHandle.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
|
||||
{
|
||||
#define COPY_SAVEFILE(name) \
|
||||
(strcmp(findHandle.cFileName, name) == 0) \
|
||||
{ \
|
||||
strcpy(oldLocation, oldDirectory); \
|
||||
strcat(oldLocation, "Saves\\"); \
|
||||
strcat(oldLocation, name); \
|
||||
strcpy(newLocation, output); \
|
||||
strcat(newLocation, "saves\\"); \
|
||||
strcat(newLocation, name); \
|
||||
PLATFORM_copyFile(oldLocation, newLocation); \
|
||||
}
|
||||
if COPY_SAVEFILE("unlock.vvv")
|
||||
else if COPY_SAVEFILE("tsave.vvv")
|
||||
else if COPY_SAVEFILE("qsave.vvv")
|
||||
#undef COPY_SAVEFILE
|
||||
}
|
||||
} while (FindNextFile(hFind, &findHandle));
|
||||
*/
|
||||
|
||||
sprintf(fileSearch, "%s\\*.vvvvvv", oldDirectory);
|
||||
hFind = FindFirstFile(fileSearch, &findHandle);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("Could not find directory %s\n", oldDirectory);
|
||||
}
|
||||
else do
|
||||
{
|
||||
if ((findHandle.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
|
||||
{
|
||||
strcpy(oldLocation, oldDirectory);
|
||||
strcat(oldLocation, findHandle.cFileName);
|
||||
strcpy(newLocation, output);
|
||||
strcat(newLocation, "levels\\");
|
||||
strcat(newLocation, findHandle.cFileName);
|
||||
PLATFORM_copyFile(oldLocation, newLocation);
|
||||
}
|
||||
} while (FindNextFile(hFind, &findHandle));
|
||||
#else
|
||||
#error See PLATFORM_migrateSaveData
|
||||
#endif
|
||||
}
|
||||
|
||||
void PLATFORM_copyFile(const char *oldLocation, const char *newLocation)
|
||||
{
|
||||
char *data;
|
||||
long int length;
|
||||
|
||||
/* Read data */
|
||||
FILE *file = fopen(oldLocation, "rb");
|
||||
if (!file)
|
||||
{
|
||||
printf("Cannot open/copy %s\n", oldLocation);
|
||||
return;
|
||||
}
|
||||
fseek(file, 0, SEEK_END);
|
||||
length = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
data = (char*) malloc(length);
|
||||
fread(data, 1, length, file);
|
||||
fclose(file);
|
||||
|
||||
/* Write data */
|
||||
file = fopen(newLocation, "wb");
|
||||
if (!file)
|
||||
{
|
||||
printf("Could not write to %s\n", newLocation);
|
||||
free(data);
|
||||
return;
|
||||
}
|
||||
fwrite(data, 1, length, file);
|
||||
fclose(file);
|
||||
free(data);
|
||||
|
||||
/* WTF did we just do */
|
||||
printf("Copied:\n\tOld: %s\n\tNew: %s\n", oldLocation, newLocation);
|
||||
}
|
||||
18
desktop_version/src/FileSystemUtils.h
Normal file
18
desktop_version/src/FileSystemUtils.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef FILESYSTEMUTILS_H
|
||||
#define FILESYSTEMUTILS_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
void FILESYSTEM_init(char *argvZero);
|
||||
void FILESYSTEM_deinit();
|
||||
|
||||
char *FILESYSTEM_getUserSaveDirectory();
|
||||
char *FILESYSTEM_getUserLevelDirectory();
|
||||
|
||||
void FILESYSTEM_loadFileToMemory(const char *name, unsigned char **mem, size_t *len);
|
||||
void FILESYSTEM_freeMemory(unsigned char **mem);
|
||||
|
||||
std::vector<std::string> FILESYSTEM_getLevelDirFileNames();
|
||||
|
||||
#endif /* FILESYSTEMUTILS_H */
|
||||
2317
desktop_version/src/Finalclass.cpp
Normal file
2317
desktop_version/src/Finalclass.cpp
Normal file
File diff suppressed because it is too large
Load Diff
20
desktop_version/src/Finalclass.h
Normal file
20
desktop_version/src/Finalclass.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef FINALCLASS_H
|
||||
#define FINALCLASS_H
|
||||
|
||||
#include "Game.h"
|
||||
#include "Entity.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class finalclass
|
||||
{
|
||||
public:
|
||||
std::vector<std::string> loadlevel(int rx, int ry, Game& game, entityclass& obj);
|
||||
|
||||
std::string roomname;
|
||||
int coin, rcol;
|
||||
bool warpx, warpy;
|
||||
};
|
||||
|
||||
#endif /* FINALCLASS_H */
|
||||
7707
desktop_version/src/Game.cpp
Normal file
7707
desktop_version/src/Game.cpp
Normal file
File diff suppressed because it is too large
Load Diff
359
desktop_version/src/Game.h
Normal file
359
desktop_version/src/Game.h
Normal file
@@ -0,0 +1,359 @@
|
||||
#ifndef GAME_H
|
||||
#define GAME_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "SDL.h"
|
||||
#include "Maths.h"
|
||||
#include "UtilityClass.h"
|
||||
#include "GraphicsUtil.h"
|
||||
|
||||
|
||||
class entityclass;
|
||||
class mapclass;
|
||||
class Graphics;
|
||||
class musicclass;
|
||||
|
||||
class Game
|
||||
{
|
||||
public:
|
||||
Game(void);
|
||||
~Game(void);
|
||||
|
||||
|
||||
void setGlobalSoundVol(const float _vol)
|
||||
{
|
||||
m_globalVol = _vol;
|
||||
}
|
||||
float getGlobalSoundVol()
|
||||
{
|
||||
return m_globalVol;
|
||||
}
|
||||
|
||||
|
||||
int crewrescued();
|
||||
|
||||
std::string unrescued();
|
||||
|
||||
void resetgameclock();
|
||||
|
||||
void customsavequick(std::string savfile, mapclass& map, entityclass& obj, musicclass& music);
|
||||
void savequick(mapclass& map, entityclass& obj, musicclass& music);
|
||||
|
||||
void gameclock();
|
||||
|
||||
std::string giventimestring(int hrs, int min, int sec, UtilityClass& help );
|
||||
|
||||
std::string timestring(UtilityClass& help);
|
||||
|
||||
std::string partimestring(UtilityClass& help);
|
||||
|
||||
std::string resulttimestring(UtilityClass& help);
|
||||
|
||||
std::string timetstring(int t, UtilityClass& help);
|
||||
|
||||
void createmenu(std::string t);
|
||||
|
||||
void lifesequence(entityclass& obj);
|
||||
|
||||
void gethardestroom(mapclass& map);
|
||||
|
||||
void updatestate(Graphics& dwgfx, mapclass& map, entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
void unlocknum(int t, mapclass& map, Graphics& dwgfx);
|
||||
|
||||
void loadstats(mapclass& map, Graphics& dwgfx);
|
||||
|
||||
void savestats(mapclass& map, Graphics& dwgfx);
|
||||
|
||||
void deletestats(mapclass& map, Graphics& dwgfx);
|
||||
|
||||
void deletequick();
|
||||
|
||||
void savetele(mapclass& map, entityclass& obj, musicclass& music);
|
||||
|
||||
void loadtele(mapclass& map, entityclass& obj, musicclass& music);
|
||||
|
||||
void deletetele();
|
||||
|
||||
void customstart(entityclass& obj, musicclass& music );
|
||||
|
||||
void start(entityclass& obj, musicclass& music );
|
||||
|
||||
void startspecial(int t, entityclass& obj, musicclass& music);
|
||||
|
||||
void starttrial(int t, entityclass& obj, musicclass& music);
|
||||
|
||||
void telegotoship()
|
||||
{
|
||||
//Special function to move the telesave to the ship teleporter.
|
||||
//telecookie.data.savex = 13*8;
|
||||
//telecookie.data.savey = 129;
|
||||
//telecookie.data.saverx = 102;
|
||||
//telecookie.data.savery = 111;
|
||||
//telecookie.data.savegc = 0;
|
||||
//telecookie.data.savedir = 1;
|
||||
//telecookie.data.savepoint = 0;
|
||||
|
||||
//telecookie.data.currentsong = 4;
|
||||
//telecookie.data.companion = 0;
|
||||
|
||||
//telecookie.data.finalmode = false;
|
||||
//telecookie.data.finalstretch = false;
|
||||
}
|
||||
|
||||
void swnpenalty();
|
||||
|
||||
void deathsequence(mapclass& map, entityclass& obj, musicclass& music);
|
||||
|
||||
void customloadquick(std::string savfile, mapclass& map, entityclass& obj, musicclass& music);
|
||||
void loadquick(mapclass& map, entityclass& obj, musicclass& music);
|
||||
|
||||
void loadsummary(mapclass& map, UtilityClass& help);
|
||||
|
||||
void initteleportermode(mapclass& map);
|
||||
|
||||
std::string saveFilePath;
|
||||
|
||||
|
||||
int door_left;
|
||||
int door_right;
|
||||
int door_up;
|
||||
int door_down;
|
||||
int roomx, roomy, roomchangedir;
|
||||
int temp, j, k;
|
||||
|
||||
int savex, savey, saverx, savery;
|
||||
int savegc, savedir;
|
||||
|
||||
//Added for port
|
||||
int edsavex, edsavey, edsaverx, edsavery;
|
||||
int edsavegc, edsavedir;
|
||||
|
||||
//State logic stuff
|
||||
int state, statedelay;
|
||||
|
||||
bool glitchrunkludge;
|
||||
|
||||
int usingmmmmmm;
|
||||
|
||||
int gamestate;
|
||||
bool hascontrol, jumpheld;
|
||||
int jumppressed;
|
||||
int gravitycontrol;
|
||||
|
||||
bool infocus;
|
||||
bool muted;
|
||||
int mutebutton;
|
||||
private:
|
||||
float m_globalVol;
|
||||
|
||||
public:
|
||||
|
||||
int tapleft, tapright;
|
||||
|
||||
//Menu interaction stuff
|
||||
bool mapheld;
|
||||
int menupage;
|
||||
//public var crewstats:Array = new Array();
|
||||
int lastsaved;
|
||||
int deathcounts;
|
||||
int timerStartTime;
|
||||
|
||||
int frames, seconds, minutes, hours;
|
||||
bool gamesaved;
|
||||
std::string savetime;
|
||||
std::string savearea;
|
||||
int savetrinkets;
|
||||
bool startscript;
|
||||
std::string newscript;
|
||||
|
||||
int mainmenu;
|
||||
bool menustart;
|
||||
|
||||
//Teleporting
|
||||
bool teleport_to_new_area;
|
||||
int teleport_to_x, teleport_to_y;
|
||||
std::string teleportscript;
|
||||
bool useteleporter;
|
||||
int teleport_to_teleporter;
|
||||
|
||||
//Main Menu Variables
|
||||
std::vector<std::string> menuoptions;
|
||||
std::vector<bool> menuoptionsactive;
|
||||
int nummenuoptions, currentmenuoption ;
|
||||
std::string menuselection, currentmenuname, previousmenuname;
|
||||
int menuxoff, menuyoff;
|
||||
|
||||
int menucountdown;
|
||||
std::string menudest;
|
||||
|
||||
int creditposx, creditposy, creditposdelay;
|
||||
|
||||
|
||||
//60 fps mode!
|
||||
bool sfpsmode;
|
||||
|
||||
//Sine Wave Ninja Minigame
|
||||
bool swnmode;
|
||||
int swngame, swnstate, swnstate2, swnstate3, swnstate4, swndelay, swndeaths;
|
||||
int swntimer, swncolstate, swncoldelay;
|
||||
int swnrecord, swnbestrank, swnrank, swnmessage;
|
||||
|
||||
//SuperCrewMate Stuff
|
||||
bool supercrewmate, scmhurt, scmmoveme;
|
||||
int scmprogress;
|
||||
|
||||
//Accessibility Options
|
||||
bool colourblindmode;
|
||||
bool noflashingmode;
|
||||
int slowdown;
|
||||
Uint32 gameframerate;
|
||||
|
||||
bool nodeathmode;
|
||||
int gameoverdelay;
|
||||
bool nocutscenes;
|
||||
|
||||
//Time Trials
|
||||
bool intimetrial, timetrialparlost;
|
||||
int timetrialcountdown, timetrialshinytarget, timetriallevel;
|
||||
int timetrialpar, timetrialresulttime, timetrialrank;
|
||||
|
||||
int creditposition;
|
||||
bool insecretlab;
|
||||
|
||||
bool inintermission;
|
||||
|
||||
std::vector<bool> crewstats;
|
||||
|
||||
bool alarmon;
|
||||
int alarmdelay;
|
||||
bool blackout;
|
||||
|
||||
std::vector<bool> tele_crewstats;
|
||||
|
||||
std::vector<bool> quick_crewstats;
|
||||
|
||||
std::vector<int> unlock;
|
||||
std::vector<int> unlocknotify;
|
||||
std::vector<int> temp_unlock;
|
||||
std::vector<int> temp_unlocknotify;
|
||||
int stat_trinkets;
|
||||
bool fullscreen;
|
||||
int bestgamedeaths;
|
||||
|
||||
bool stat_screenshakes;
|
||||
bool stat_backgrounds;
|
||||
bool stat_flipmode;
|
||||
bool stat_invincibility;
|
||||
int stat_slowdown;
|
||||
|
||||
|
||||
std::vector<int>besttimes;
|
||||
std::vector<int>besttrinkets;
|
||||
std::vector<int>bestlives;
|
||||
std::vector<int> bestrank;
|
||||
|
||||
bool telecookieexists;
|
||||
bool quickcookieexists;
|
||||
|
||||
std::string tele_gametime;
|
||||
int tele_trinkets;
|
||||
std::string tele_currentarea;
|
||||
std::string quick_gametime;
|
||||
int quick_trinkets;
|
||||
std::string quick_currentarea;
|
||||
|
||||
int mx, my;
|
||||
int screenshake, flashlight;
|
||||
bool test;
|
||||
std::string teststring, tempstring;
|
||||
bool advancetext, pausescript;
|
||||
|
||||
int deathseq, lifeseq;
|
||||
|
||||
int coins, trinkets, crewmates, trinkencollect;
|
||||
int savepoint, teleport, teleportxpos;
|
||||
int edteleportent;
|
||||
bool completestop;
|
||||
|
||||
float inertia;
|
||||
|
||||
int companion;
|
||||
bool roomchange;
|
||||
SDL_Rect teleblock;
|
||||
bool activetele;
|
||||
int readytotele;
|
||||
int activity_r, activity_g, activity_b;
|
||||
std::string activity_lastprompt;
|
||||
|
||||
std::string telesummary, quicksummary, customquicksummary;
|
||||
|
||||
bool backgroundtext;
|
||||
|
||||
int activeactivity, act_fade;
|
||||
|
||||
bool press_left, press_right, press_action, press_map;
|
||||
|
||||
//Some stats:
|
||||
int totalflips;
|
||||
std::string hardestroom;
|
||||
int hardestroomdeaths, currentroomdeaths;
|
||||
|
||||
bool savemystats;
|
||||
|
||||
|
||||
bool advanced_mode;
|
||||
bool fullScreenEffect_badSignal;
|
||||
bool useLinearFilter;
|
||||
int stretchMode;
|
||||
int controllerSensitivity;
|
||||
|
||||
//Screenrecording stuff, for beta/trailer
|
||||
int recording;
|
||||
std::string recordstring;
|
||||
bool combomode;
|
||||
int combolen;
|
||||
std::string comboaction;
|
||||
std::string currentaction;
|
||||
bool recordinit;
|
||||
|
||||
std::vector<int> playback;
|
||||
int playbackpos;
|
||||
int playbacksize;
|
||||
int playmove;
|
||||
int playcombo;
|
||||
bool playbackfinished;
|
||||
|
||||
bool menukludge;
|
||||
bool quickrestartkludge;
|
||||
|
||||
bool paused;
|
||||
int globalsound;
|
||||
|
||||
//Custom stuff
|
||||
std::string customscript[50];
|
||||
int customcol;
|
||||
int levelpage;
|
||||
int playcustomlevel;
|
||||
std::string customleveltitle;
|
||||
std::string customlevelfilename;
|
||||
|
||||
void clearcustomlevelstats();
|
||||
void loadcustomlevelstats();
|
||||
void savecustomlevelstats();
|
||||
void updatecustomlevelstats(std::string clevel, int cscore);
|
||||
|
||||
std::string customlevelstats[200]; //string array containing level filenames
|
||||
int customlevelscore[200];//0 - not played, 1 - finished, 2 - all trinkets, 3 - finished, all trinkets
|
||||
int numcustomlevelstats;
|
||||
bool customlevelstatsloaded;
|
||||
|
||||
|
||||
std::vector<SDL_GameControllerButton> controllerButton_map;
|
||||
std::vector<SDL_GameControllerButton> controllerButton_flip;
|
||||
std::vector<SDL_GameControllerButton> controllerButton_esc;
|
||||
|
||||
};
|
||||
|
||||
#endif /* GAME_H */
|
||||
3207
desktop_version/src/Graphics.cpp
Normal file
3207
desktop_version/src/Graphics.cpp
Normal file
File diff suppressed because it is too large
Load Diff
280
desktop_version/src/Graphics.h
Normal file
280
desktop_version/src/Graphics.h
Normal file
@@ -0,0 +1,280 @@
|
||||
#ifndef GRAPHICS_H
|
||||
#define GRAPHICS_H
|
||||
|
||||
#include "GraphicsResources.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
#include "Maths.h"
|
||||
#include "Textbox.h"
|
||||
#include "UtilityClass.h"
|
||||
#include "Game.h"
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#include "GraphicsUtil.h"
|
||||
#include "Screen.h"
|
||||
|
||||
class map;
|
||||
|
||||
class Graphics
|
||||
{
|
||||
public:
|
||||
Graphics();
|
||||
~Graphics();
|
||||
|
||||
GraphicsResources grphx;
|
||||
|
||||
void Makebfont();
|
||||
|
||||
void drawhuetile(int x, int y, int t, int c);
|
||||
|
||||
void drawgravityline(int t, entityclass& obj);
|
||||
|
||||
void MakeTileArray();
|
||||
|
||||
void MakeSpriteArray();
|
||||
|
||||
void maketelearray();
|
||||
|
||||
void drawcoloredtile(int x, int y, int t, int r, int g, int b);
|
||||
|
||||
void drawmenu(Game& game, int cr, int cg, int cb, int division = 30);
|
||||
void drawlevelmenu(Game& game, int cr, int cg, int cb, int division = 30);
|
||||
|
||||
void processfade();
|
||||
|
||||
void drawfade();
|
||||
|
||||
void setwarprect(int a, int b, int c, int d);
|
||||
|
||||
void createtextbox(std::string t, int xp, int yp, int r= 255, int g= 255, int b = 255);
|
||||
|
||||
void textboxcleanup();
|
||||
|
||||
void textboxcenter();
|
||||
|
||||
void textboxcenterx();
|
||||
|
||||
int textboxwidth();
|
||||
|
||||
void textboxmove(int xo, int yo);
|
||||
|
||||
void textboxmoveto(int xo);
|
||||
|
||||
void textboxcentery();
|
||||
|
||||
void textboxadjust();
|
||||
|
||||
void addline(std::string t);
|
||||
|
||||
void textboxtimer(int t);
|
||||
|
||||
void textboxremove();
|
||||
|
||||
void textboxremovefast();
|
||||
|
||||
void textboxactive();
|
||||
|
||||
void drawtextbox(int x, int y, int w, int h, int r, int g, int b);
|
||||
|
||||
void drawpixeltextbox(int x, int y, int w, int h, int w2, int h2, int r, int g, int b, int xo, int yo);
|
||||
void drawcustompixeltextbox(int x, int y, int w, int h, int w2, int h2, int r, int g, int b, int xo, int yo);
|
||||
|
||||
void drawcrewman(int x, int y, int t, bool act, UtilityClass& help, bool noshift =false);
|
||||
|
||||
int crewcolour(const int t);
|
||||
|
||||
void cutscenebars();
|
||||
|
||||
void drawpartimage(int t, int xp, int yp, int wp, int hp);
|
||||
|
||||
void drawimage(int t, int xp, int yp, bool cent=false);
|
||||
|
||||
void drawimagecol(int t, int xp, int yp, int r, int g, int b, bool cent= false);
|
||||
|
||||
void drawgui(UtilityClass& help);
|
||||
|
||||
void drawsprite(int x, int y, int t, int r, int g, int b);
|
||||
|
||||
void printcrewname(int x, int y, int t);
|
||||
|
||||
void printcrewnamestatus(int x, int y, int t);
|
||||
|
||||
void printcrewnamedark(int x, int y, int t);
|
||||
|
||||
void Print(int _x, int _y, std::string _s, int r, int g, int b, bool cen = false);
|
||||
|
||||
void RPrint(int _x, int _y, std::string _s, int r, int g, int b, bool cen = false);
|
||||
|
||||
void PrintOff(int _x, int _y, std::string _s, int r, int g, int b, bool cen = false);
|
||||
|
||||
void bprint(int x, int y, std::string t, int r, int g, int b, bool cen = false);
|
||||
|
||||
int len(std::string t);
|
||||
void bigprint( int _x, int _y, std::string _s, int r, int g, int b, bool cen = false, int sc = 2 );
|
||||
void drawspritesetcol(int x, int y, int t, int c, UtilityClass& help);
|
||||
|
||||
|
||||
void flashlight();
|
||||
void screenshake();
|
||||
|
||||
void render();
|
||||
|
||||
bool Hitest(SDL_Surface* surface1, point p1, int col, SDL_Surface* surface2, point p2, int col2);
|
||||
|
||||
void drawentities(mapclass& map, entityclass& obj, UtilityClass& help);
|
||||
|
||||
void drawtrophytext(entityclass&, UtilityClass& help);
|
||||
|
||||
void bigrprint(int x, int y, std::string& t, int r, int g, int b, bool cen = false, float sc = 2);
|
||||
|
||||
|
||||
void drawtele(int x, int y, int t, int c, UtilityClass& help);
|
||||
|
||||
Uint32 getRGB(Uint8 r, Uint8 g, Uint8 b);
|
||||
|
||||
Uint32 getBGR(Uint8 r, Uint8 g, Uint8 b);
|
||||
|
||||
Uint32 getRGB(Uint32 _col);
|
||||
|
||||
Uint32 RGBflip(Uint8 r, Uint8 g, Uint8 b);
|
||||
|
||||
|
||||
Uint32 RGBf(int r, int g, int b);
|
||||
|
||||
void setcolreal(Uint32 t);
|
||||
|
||||
void drawbackground(int t, mapclass& map);
|
||||
void drawtile3( int x, int y, int t, int off );
|
||||
void drawentcolours( int x, int y, int t);
|
||||
void drawtile2( int x, int y, int t, int r, int g, int b );
|
||||
void drawtile( int x, int y, int t, int r, int g, int b );
|
||||
void drawtowertile( int x, int y, int t );
|
||||
void drawtowertile3( int x, int y, int t, int off );
|
||||
|
||||
void drawtile(int x, int y, int t);
|
||||
|
||||
void drawmap(mapclass& map);
|
||||
|
||||
void drawforetile(int x, int y, int t);
|
||||
|
||||
void drawforetile2(int x, int y, int t);
|
||||
|
||||
void drawforetile3(int x, int y, int t, int off);
|
||||
|
||||
void drawrect(int x, int y, int w, int h, int r, int g, int b);
|
||||
|
||||
void drawtowermap(mapclass& map);
|
||||
|
||||
void drawtowermap_nobackground(mapclass& map);
|
||||
|
||||
void drawtowerspikes(mapclass& map);
|
||||
|
||||
void drawtowerentities(mapclass& map, entityclass& obj, UtilityClass& help);
|
||||
|
||||
bool onscreen(int t);
|
||||
|
||||
void drawtowerbackgroundsolo(mapclass& map);
|
||||
|
||||
|
||||
void menuoffrender();
|
||||
|
||||
void drawtowerbackground(mapclass& map);
|
||||
|
||||
void setcol(int t, UtilityClass& help);
|
||||
void drawfinalmap(mapclass & map);
|
||||
|
||||
colourTransform ct;
|
||||
|
||||
std::string tempstring;
|
||||
|
||||
int bcol, bcol2, rcol;
|
||||
|
||||
|
||||
|
||||
int j, k, m;
|
||||
|
||||
std::vector <SDL_Surface*> backgrounds;
|
||||
std::vector <SDL_Surface*> images;
|
||||
|
||||
std::vector <SDL_Surface*> tele;
|
||||
std::vector <SDL_Surface*> tiles;
|
||||
std::vector <SDL_Surface*> tiles2;
|
||||
std::vector <SDL_Surface*> tiles3;
|
||||
std::vector <SDL_Surface*> entcolours;
|
||||
std::vector <SDL_Surface*> sprites;
|
||||
std::vector <SDL_Surface*> flipsprites;
|
||||
std::vector <SDL_Surface*> bfont;
|
||||
std::vector <SDL_Surface*> bfontmask;
|
||||
std::vector <SDL_Surface*> flipbfont;
|
||||
std::vector <SDL_Surface*> flipbfontmask;
|
||||
std::vector <int> bfontlen;
|
||||
|
||||
bool flipmode;
|
||||
bool setflipmode;
|
||||
point tl;
|
||||
//buffer objects. //TODO refactor buffer objects
|
||||
SDL_Surface* backBuffer;
|
||||
Screen* screenbuffer;
|
||||
SDL_Surface* menubuffer;
|
||||
SDL_Surface* towerbuffer;
|
||||
SDL_Surface* forgroundBuffer;
|
||||
SDL_Surface* tempBuffer;
|
||||
|
||||
SDL_Rect bfont_rect;
|
||||
SDL_Rect tiles_rect;
|
||||
SDL_Rect sprites_rect;
|
||||
SDL_Rect bfontmask_rect;
|
||||
SDL_Rect images_rect;
|
||||
SDL_Rect bg_rect;
|
||||
SDL_Rect line_rect;
|
||||
SDL_Rect tele_rect;
|
||||
|
||||
SDL_Rect foot_rect;
|
||||
SDL_Rect prect;
|
||||
SDL_Rect footerrect;
|
||||
|
||||
int linestate, linedelay;
|
||||
int backoffset;
|
||||
bool backgrounddrawn, foregrounddrawn;
|
||||
|
||||
int menuoffset;
|
||||
bool resumegamemode;
|
||||
|
||||
SDL_Rect warprect;
|
||||
|
||||
int crewframe;
|
||||
int crewframedelay;
|
||||
|
||||
int fademode;
|
||||
int fadeamount;
|
||||
std::vector <int> fadebars;
|
||||
|
||||
bool trinketcolset;
|
||||
int trinketr, trinketg, trinketb;
|
||||
|
||||
std::vector <textboxclass> textbox;
|
||||
int ntextbox;
|
||||
|
||||
bool showcutscenebars;
|
||||
int cutscenebarspos;
|
||||
|
||||
std::vector<SDL_Rect> stars;
|
||||
std::vector<int> starsspeed;
|
||||
|
||||
int spcol, spcoldel;
|
||||
std::vector<SDL_Rect> backboxes;
|
||||
std::vector<int> backboxvx;
|
||||
std::vector<int> backboxvy;
|
||||
std::vector<float> backboxint;
|
||||
SDL_Rect backboxrect;
|
||||
|
||||
int warpskip, warpfcol, warpbcol;
|
||||
|
||||
};
|
||||
|
||||
#endif /* GRAPHICS_H */
|
||||
113
desktop_version/src/GraphicsResources.cpp
Normal file
113
desktop_version/src/GraphicsResources.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
#include "GraphicsResources.h"
|
||||
#include "FileSystemUtils.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Used to load PNG data
|
||||
extern "C"
|
||||
{
|
||||
extern unsigned lodepng_decode24(
|
||||
unsigned char** out,
|
||||
unsigned* w,
|
||||
unsigned* h,
|
||||
const unsigned char* in,
|
||||
size_t insize
|
||||
);
|
||||
extern unsigned lodepng_decode32(
|
||||
unsigned char** out,
|
||||
unsigned* w,
|
||||
unsigned* h,
|
||||
const unsigned char* in,
|
||||
size_t insize
|
||||
);
|
||||
}
|
||||
|
||||
SDL_Surface* LoadImage(const char *filename, bool noBlend = true, bool noAlpha = false)
|
||||
{
|
||||
//Temporary storage for the image that's loaded
|
||||
SDL_Surface* loadedImage = NULL;
|
||||
//The optimized image that will be used
|
||||
SDL_Surface* optimizedImage = NULL;
|
||||
|
||||
unsigned char *data;
|
||||
unsigned int width, height;
|
||||
|
||||
unsigned char *fileIn = NULL;
|
||||
size_t length = 0;
|
||||
FILESYSTEM_loadFileToMemory(filename, &fileIn, &length);
|
||||
if (noAlpha)
|
||||
{
|
||||
lodepng_decode24(&data, &width, &height, fileIn, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
lodepng_decode32(&data, &width, &height, fileIn, length);
|
||||
}
|
||||
FILESYSTEM_freeMemory(&fileIn);
|
||||
|
||||
loadedImage = SDL_CreateRGBSurfaceFrom(
|
||||
data,
|
||||
width,
|
||||
height,
|
||||
noAlpha ? 24 : 32,
|
||||
width * (noAlpha ? 3 : 4),
|
||||
0x000000FF,
|
||||
0x0000FF00,
|
||||
0x00FF0000,
|
||||
noAlpha ? 0x00000000 : 0xFF000000
|
||||
);
|
||||
|
||||
if (loadedImage != NULL)
|
||||
{
|
||||
optimizedImage = SDL_ConvertSurfaceFormat(
|
||||
loadedImage,
|
||||
SDL_PIXELFORMAT_ABGR8888, // FIXME: Format? -flibit
|
||||
0
|
||||
);
|
||||
SDL_FreeSurface( loadedImage );
|
||||
free(data);
|
||||
if (noBlend)
|
||||
{
|
||||
SDL_SetSurfaceBlendMode(optimizedImage, SDL_BLENDMODE_BLEND);
|
||||
}
|
||||
return optimizedImage;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"Image not found: %s\n", filename);
|
||||
SDL_assert(0 && "Image not found! See stderr.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GraphicsResources::GraphicsResources(void)
|
||||
{
|
||||
im_tiles = LoadImage("graphics/tiles.png");
|
||||
im_tiles2 = LoadImage("graphics/tiles2.png");
|
||||
im_tiles3 = LoadImage("graphics/tiles3.png");
|
||||
im_entcolours = LoadImage("graphics/entcolours.png");
|
||||
im_sprites = LoadImage("graphics/sprites.png");
|
||||
im_flipsprites = LoadImage("graphics/flipsprites.png");
|
||||
im_bfont = LoadImage("graphics/font.png");
|
||||
im_bfontmask = LoadImage("graphics/fontmask.png");
|
||||
im_teleporter = LoadImage("graphics/teleporter.png");
|
||||
|
||||
im_image0 = LoadImage("graphics/levelcomplete.png", false);
|
||||
im_image1 = LoadImage("graphics/minimap.png", true, true);
|
||||
im_image2 = LoadImage("graphics/covered.png", true, true);
|
||||
im_image3 = LoadImage("graphics/elephant.png");
|
||||
im_image4 = LoadImage("graphics/gamecomplete.png", false);
|
||||
im_image5 = LoadImage("graphics/fliplevelcomplete.png", false);
|
||||
im_image6 = LoadImage("graphics/flipgamecomplete.png", false);
|
||||
im_image7 = LoadImage("graphics/site.png", false);
|
||||
im_image8 = LoadImage("graphics/site2.png");
|
||||
im_image9 = LoadImage("graphics/site3.png");
|
||||
im_image10 = LoadImage("graphics/ending.png");
|
||||
im_image11 = LoadImage("graphics/site4.png");
|
||||
im_image12 = LoadImage("graphics/minimap.png");
|
||||
}
|
||||
|
||||
|
||||
GraphicsResources::~GraphicsResources(void)
|
||||
{
|
||||
}
|
||||
36
desktop_version/src/GraphicsResources.h
Normal file
36
desktop_version/src/GraphicsResources.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef GRAPHICSRESOURCES_H
|
||||
#define GRAPHICSRESOURCES_H
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
class GraphicsResources
|
||||
{
|
||||
public:
|
||||
GraphicsResources(void);
|
||||
~GraphicsResources(void);
|
||||
|
||||
SDL_Surface* im_tiles;
|
||||
SDL_Surface* im_tiles2;
|
||||
SDL_Surface* im_tiles3;
|
||||
SDL_Surface* im_entcolours;
|
||||
SDL_Surface* im_sprites;
|
||||
SDL_Surface* im_flipsprites;
|
||||
SDL_Surface* im_bfont;
|
||||
SDL_Surface* im_bfontmask;
|
||||
SDL_Surface* im_teleporter;
|
||||
SDL_Surface* im_image0;
|
||||
SDL_Surface* im_image1;
|
||||
SDL_Surface* im_image2;
|
||||
SDL_Surface* im_image3;
|
||||
SDL_Surface* im_image4;
|
||||
SDL_Surface* im_image5;
|
||||
SDL_Surface* im_image6;
|
||||
SDL_Surface* im_image7;
|
||||
SDL_Surface* im_image8;
|
||||
SDL_Surface* im_image9;
|
||||
SDL_Surface* im_image10;
|
||||
SDL_Surface* im_image11;
|
||||
SDL_Surface* im_image12;
|
||||
};
|
||||
|
||||
#endif /* GRAPHICSRESOURCES_H */
|
||||
525
desktop_version/src/GraphicsUtil.cpp
Normal file
525
desktop_version/src/GraphicsUtil.cpp
Normal file
@@ -0,0 +1,525 @@
|
||||
#include "Graphics.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void setRect( SDL_Rect& _r, int x, int y, int w, int h )
|
||||
{
|
||||
_r.x = x;
|
||||
_r.y = y;
|
||||
_r.w = w;
|
||||
_r.h = h;
|
||||
}
|
||||
|
||||
unsigned int endian_swap( unsigned int x )
|
||||
{
|
||||
return (x>>24) |
|
||||
((x<<8) & 0x00FF0000) |
|
||||
((x>>8) & 0x0000FF00) |
|
||||
(x<<24);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void endian_swap(T *objp)
|
||||
{
|
||||
unsigned char *memp = reinterpret_cast<unsigned char*>(objp);
|
||||
std::reverse(memp, memp + sizeof(T));
|
||||
}
|
||||
|
||||
|
||||
SDL_Surface* GetSubSurface( SDL_Surface* metaSurface, int x, int y, int width, int height )
|
||||
{
|
||||
// Create an SDL_Rect with the area of the _surface
|
||||
SDL_Rect area;
|
||||
area.x = x;
|
||||
area.y = y;
|
||||
area.w = width;
|
||||
area.h = height;
|
||||
|
||||
// Set the RGBA mask values.
|
||||
Uint32 r, g, b, a;
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
r = 0xff000000;
|
||||
g = 0x00ff0000;
|
||||
b = 0x0000ff00;
|
||||
a = 0x000000ff;
|
||||
#else
|
||||
r = 0x000000ff;
|
||||
g = 0x0000ff00;
|
||||
b = 0x00ff0000;
|
||||
a = 0xff000000;
|
||||
#endif
|
||||
|
||||
//Convert to the correct display format after nabbing the new _surface or we will slow things down.
|
||||
SDL_Surface* preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, r, g, b, a);
|
||||
//SDL_Surface* subSurface = SDL_DisplayFormatAlpha(preSurface);
|
||||
|
||||
//SDL_FreeSurface(preSurface);
|
||||
|
||||
// Lastly, apply the area from the meta _surface onto the whole of the sub _surface.
|
||||
SDL_BlitSurface(metaSurface, &area, preSurface, 0);
|
||||
|
||||
// Return the new Bitmap _surface
|
||||
return preSurface;
|
||||
}
|
||||
|
||||
void DrawPixel( SDL_Surface *_surface, int x, int y, Uint32 pixel )
|
||||
{
|
||||
int bpp = _surface->format->BytesPerPixel;
|
||||
/* Here p is the address to the pixel we want to set */
|
||||
Uint8 *p = (Uint8 *)_surface->pixels + y * _surface->pitch + x * bpp;
|
||||
|
||||
switch(bpp)
|
||||
{
|
||||
case 1:
|
||||
*p = pixel;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*(Uint16 *)p = pixel;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if(SDL_BYTEORDER != SDL_BIG_ENDIAN)
|
||||
{
|
||||
p[0] = (pixel >> 16) & 0xff;
|
||||
p[1] = (pixel >> 8) & 0xff;
|
||||
p[2] = pixel & 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
p[0] = pixel & 0xff;
|
||||
p[1] = (pixel >> 8) & 0xff;
|
||||
p[2] = (pixel >> 16) & 0xff;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
*(Uint32 *)p = pixel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 ReadPixel( SDL_Surface *_surface, int x, int y )
|
||||
{
|
||||
int bpp = _surface->format->BytesPerPixel;
|
||||
/* Here p is the address to the pixel we want to retrieve */
|
||||
Uint8 *p = (Uint8 *)_surface->pixels + y * _surface->pitch + x * bpp;
|
||||
|
||||
switch(bpp)
|
||||
{
|
||||
case 1:
|
||||
return *p;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
return *(Uint16 *)p;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
return p[0] << 16 | p[1] << 8 | p[2];
|
||||
else
|
||||
return p[0] | p[1] << 8 | p[2] << 16;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
return *(Uint32 *)p;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0; /* shouldn't happen, but avoids warnings */
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Surface * ScaleSurface( SDL_Surface *_surface, int Width, int Height, SDL_Surface * Dest )
|
||||
{
|
||||
if(!_surface || !Width || !Height)
|
||||
return 0;
|
||||
|
||||
SDL_Surface *_ret;
|
||||
if(Dest == NULL)
|
||||
{
|
||||
_ret = SDL_CreateRGBSurface(_surface->flags, Width, Height, _surface->format->BitsPerPixel,
|
||||
_surface->format->Rmask, _surface->format->Gmask, _surface->format->Bmask, _surface->format->Amask);
|
||||
if(_ret == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_ret = Dest;
|
||||
}
|
||||
|
||||
float _stretch_factor_x = (static_cast<double>(Width) / static_cast<double>(_surface->w)), _stretch_factor_y = (static_cast<double>(Height) / static_cast<double>(_surface->h));
|
||||
|
||||
|
||||
SDL_Rect gigantoPixel;
|
||||
for(Sint32 y = 0; y < _surface->h; y++)
|
||||
for(Sint32 x = 0; x < _surface->w; x++)
|
||||
{
|
||||
setRect(gigantoPixel, static_cast<Sint32>((float(x)*_stretch_factor_x) -1), static_cast<Sint32>((float(y) *_stretch_factor_y)-1), static_cast<Sint32>(_stretch_factor_x +1.0),static_cast<Sint32>( _stretch_factor_y+1.0)) ;
|
||||
SDL_FillRect(_ret, &gigantoPixel, ReadPixel(_surface, x, y));
|
||||
}
|
||||
|
||||
// DrawPixel(_ret, static_cast<Sint32>(_stretch_factor_x * x) + o_x,
|
||||
//static_cast<Sint32>(_stretch_factor_y * y) + o_y, ReadPixel(_surface, x, y));
|
||||
|
||||
return _ret;
|
||||
}
|
||||
|
||||
SDL_Surface * ScaleSurfaceSlow( SDL_Surface *_surface, int Width, int Height)
|
||||
{
|
||||
if(!_surface || !Width || !Height)
|
||||
return 0;
|
||||
|
||||
SDL_Surface *_ret;
|
||||
|
||||
_ret = SDL_CreateRGBSurface(_surface->flags, Width, Height, _surface->format->BitsPerPixel,
|
||||
_surface->format->Rmask, _surface->format->Gmask, _surface->format->Bmask, _surface->format->Amask);
|
||||
if(_ret == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float _stretch_factor_x = (static_cast<double>(Width) / static_cast<double>(_surface->w)), _stretch_factor_y = (static_cast<double>(Height) / static_cast<double>(_surface->h));
|
||||
|
||||
|
||||
for(Sint32 y = 0; y < _surface->h; y++)
|
||||
for(Sint32 x = 0; x < _surface->w; x++)
|
||||
for(Sint32 o_y = 0; o_y < _stretch_factor_y; ++o_y)
|
||||
for(Sint32 o_x = 0; o_x < _stretch_factor_x; ++o_x)
|
||||
DrawPixel(_ret, static_cast<Sint32>(_stretch_factor_x * x) + o_x,
|
||||
static_cast<Sint32>(_stretch_factor_y * y) + o_y, ReadPixel(_surface, x, y));
|
||||
|
||||
// DrawPixel(_ret, static_cast<Sint32>(_stretch_factor_x * x) + o_x,
|
||||
//static_cast<Sint32>(_stretch_factor_y * y) + o_y, ReadPixel(_surface, x, y));
|
||||
|
||||
return _ret;
|
||||
}
|
||||
|
||||
SDL_Surface * FlipSurfaceHorizontal(SDL_Surface* _src)
|
||||
{
|
||||
SDL_Surface * ret = SDL_CreateRGBSurface(_src->flags, _src->w, _src->h, _src->format->BitsPerPixel,
|
||||
_src->format->Rmask, _src->format->Gmask, _src->format->Bmask, _src->format->Amask);
|
||||
if(ret == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(Sint32 y = 0; y < _src->h; y++)
|
||||
{
|
||||
for(Sint32 x = 0; x < _src->w; x++)
|
||||
{
|
||||
DrawPixel(ret,(_src->w -1) -x,y,ReadPixel(_src, x, y));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SDL_Surface * FlipSurfaceVerticle(SDL_Surface* _src)
|
||||
{
|
||||
SDL_Surface * ret = SDL_CreateRGBSurface(_src->flags, _src->w, _src->h, _src->format->BitsPerPixel,
|
||||
_src->format->Rmask, _src->format->Gmask, _src->format->Bmask, _src->format->Amask);
|
||||
if(ret == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(Sint32 y = 0; y < _src->h; y++)
|
||||
{
|
||||
for(Sint32 x = 0; x < _src->w; x++)
|
||||
{
|
||||
DrawPixel(ret, x ,(_src->h-1) - y ,ReadPixel(_src, x, y));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void BlitSurfaceStandard( SDL_Surface* _src, SDL_Rect* _srcRect, SDL_Surface* _dest, SDL_Rect* _destRect )
|
||||
{
|
||||
//SDL_Rect tempRect = *_destRect;
|
||||
//tempRect.w ;
|
||||
//tempRect.h ;
|
||||
//tempRect.x *=globalScale;
|
||||
//tempRect.y *=globalScale;
|
||||
|
||||
|
||||
//if(globalScale != 1)
|
||||
//{
|
||||
// SDL_Surface* tempScaled = ScaleSurface(_src, tempRect.w, tempRect.h);
|
||||
|
||||
// SDL_BlitSurface( tempScaled, _srcRect, _dest, &tempRect );
|
||||
|
||||
// SDL_FreeSurface(tempScaled);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
SDL_BlitSurface( _src, _srcRect, _dest, _destRect );
|
||||
//}
|
||||
}
|
||||
|
||||
void BlitSurfaceColoured(
|
||||
SDL_Surface* _src,
|
||||
SDL_Rect* _srcRect,
|
||||
SDL_Surface* _dest,
|
||||
SDL_Rect* _destRect,
|
||||
colourTransform& ct
|
||||
) {
|
||||
SDL_Rect *tempRect = _destRect;
|
||||
|
||||
const SDL_PixelFormat& fmt = *(_src->format);
|
||||
// const SDL_PixelFormat& destfmt = *(_dest->format);
|
||||
|
||||
SDL_Surface* tempsurface = SDL_CreateRGBSurface(
|
||||
SDL_SWSURFACE,
|
||||
_src->w,
|
||||
_src->h,
|
||||
fmt.BitsPerPixel,
|
||||
fmt.Rmask,
|
||||
fmt.Gmask,
|
||||
fmt.Bmask,
|
||||
fmt.Amask
|
||||
);
|
||||
|
||||
for(int x = 0; x < tempsurface->w; x++)
|
||||
{
|
||||
for(int y = 0; y < tempsurface->h; y++)
|
||||
{
|
||||
Uint32 pixel = ReadPixel(_src, x, y);
|
||||
Uint32 Alpha = pixel & fmt.Amask;
|
||||
Uint32 result = ct.colour & 0x00FFFFFF;
|
||||
DrawPixel(tempsurface, x, y, result | Alpha);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_BlitSurface(tempsurface, _srcRect, _dest, tempRect);
|
||||
SDL_FreeSurface(tempsurface);
|
||||
}
|
||||
|
||||
|
||||
int scrollamount = 0;
|
||||
bool isscrolling = 0;
|
||||
SDL_Surface* ApplyFilter( SDL_Surface* _src )
|
||||
{
|
||||
SDL_Surface* _ret = SDL_CreateRGBSurface(_src->flags, _src->w, _src->h, 32,
|
||||
_src->format->Rmask, _src->format->Gmask, _src->format->Bmask, _src->format->Amask);
|
||||
|
||||
if (rand() % 4000 < 8)
|
||||
{
|
||||
isscrolling = true;
|
||||
}
|
||||
|
||||
if(isscrolling == true)
|
||||
{
|
||||
scrollamount += 20;
|
||||
if(scrollamount > 240)
|
||||
{
|
||||
scrollamount = 0;
|
||||
isscrolling = false;
|
||||
}
|
||||
}
|
||||
|
||||
int redOffset = rand() % 4;
|
||||
|
||||
for(int x = 0; x < _src->w; x++)
|
||||
{
|
||||
for(int y = 0; y < _src->h; y++)
|
||||
{
|
||||
int sampley = (y + scrollamount )% 240;
|
||||
|
||||
Uint32 pixel = ReadPixel(_src, x,sampley);
|
||||
|
||||
Uint8 green = (pixel & _src->format->Gmask) >> 8;
|
||||
Uint8 blue = (pixel & _src->format->Bmask) >> 0;
|
||||
|
||||
Uint32 pixelOffset = ReadPixel(_src, std::min(x+redOffset, 319), sampley) ;
|
||||
Uint8 red = (pixelOffset & _src->format->Rmask) >> 16 ;
|
||||
|
||||
if(isscrolling && sampley > 220 && ((rand() %10) < 4))
|
||||
{
|
||||
red = std::min(int(red+(fRandom() * 0.6) * 254) , 255);
|
||||
green = std::min(int(green+(fRandom() * 0.6) * 254) , 255);
|
||||
blue = std::min(int(blue+(fRandom() * 0.6) * 254) , 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
red = std::min(int(red+(fRandom() * 0.2) * 254) , 255);
|
||||
green = std::min(int(green+(fRandom() * 0.2) * 254) , 255);
|
||||
blue = std::min(int(blue+(fRandom() * 0.2) * 254) , 255);
|
||||
}
|
||||
|
||||
|
||||
if(y % 2 == 0)
|
||||
{
|
||||
red = static_cast<Uint8>(red / 1.2f);
|
||||
green = static_cast<Uint8>(green / 1.2f);
|
||||
blue = static_cast<Uint8>(blue / 1.2f);
|
||||
}
|
||||
|
||||
int distX = static_cast<int>((abs (160.0f -x ) / 160.0f) *16);
|
||||
int distY = static_cast<int>((abs (120.0f -y ) / 120.0f)*32);
|
||||
|
||||
red = std::max(red - ( distX +distY), 0);
|
||||
green = std::max(green - ( distX +distY), 0);
|
||||
blue = std::max(blue - ( distX +distY), 0);
|
||||
|
||||
Uint32 finalPixel = ((red<<16) + (green<<8) + (blue<<0)) | (pixel &_src->format->Amask);
|
||||
DrawPixel(_ret,x,y, finalPixel);
|
||||
|
||||
}
|
||||
}
|
||||
return _ret;
|
||||
}
|
||||
|
||||
void FillRect( SDL_Surface* _surface, const int _x, const int _y, const int _w, const int _h, const int r, int g, int b )
|
||||
{
|
||||
SDL_Rect rect = {Sint16(_x),Sint16(_y),Sint16(_w),Sint16(_h)};
|
||||
Uint32 color;
|
||||
color = SDL_MapRGB(_surface->format, r, g, b);
|
||||
SDL_FillRect(_surface, &rect, color);
|
||||
}
|
||||
|
||||
void FillRect( SDL_Surface* _surface, const int r, int g, int b )
|
||||
{
|
||||
SDL_Rect rect = {0,0,Uint16(_surface->w) ,Uint16(_surface->h) };
|
||||
Uint32 color;
|
||||
color = SDL_MapRGB(_surface->format, r, g, b);
|
||||
SDL_FillRect(_surface, &rect, color);
|
||||
}
|
||||
|
||||
void FillRect( SDL_Surface* _surface, const int color )
|
||||
{
|
||||
SDL_Rect rect = {0,0,Uint16(_surface->w) ,Uint16(_surface->h) };
|
||||
SDL_FillRect(_surface, &rect, color);
|
||||
}
|
||||
|
||||
void FillRect( SDL_Surface* _surface, const int x, const int y, const int w, const int h, int rgba )
|
||||
{
|
||||
SDL_Rect rect = {Sint16(x) ,Sint16(y) ,Sint16(w) ,Sint16(h) };
|
||||
SDL_FillRect(_surface, &rect, rgba);
|
||||
}
|
||||
|
||||
void FillRect( SDL_Surface* _surface, SDL_Rect& _rect, const int r, int g, int b )
|
||||
{
|
||||
Uint32 color;
|
||||
color = SDL_MapRGB(_surface->format, r, g, b);
|
||||
SDL_FillRect(_surface, &_rect, color);
|
||||
}
|
||||
|
||||
void FillRect( SDL_Surface* _surface, SDL_Rect rect, int rgba )
|
||||
{
|
||||
SDL_FillRect(_surface, &rect, rgba);
|
||||
}
|
||||
|
||||
bool intersectRect( float left1, float right1, float bottom1, float top1, float left2, float right2, float bottom2, float top2 )
|
||||
{
|
||||
return !( left2 > right1 || right2 < left1 || top2 < bottom1 || bottom2 > top1);
|
||||
}
|
||||
|
||||
void OverlaySurfaceKeyed( SDL_Surface* _src, SDL_Surface* _dest, Uint32 _key )
|
||||
{
|
||||
// const SDL_PixelFormat& fmt = *(_src->format);
|
||||
for(int x = 0; x < _src->w; x++)
|
||||
{
|
||||
for(int y = 0; y < _src->h; y++)
|
||||
{
|
||||
Uint32 pixel = ReadPixel(_src, x,y);
|
||||
//endian_swap(pixel);
|
||||
if (( pixel != _key))
|
||||
{
|
||||
DrawPixel(_dest,x,y, pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollSurface( SDL_Surface* _src, int _pX, int _pY )
|
||||
{
|
||||
SDL_Surface* part1 = NULL;
|
||||
|
||||
SDL_Rect rect1;
|
||||
SDL_Rect rect2;
|
||||
//scrolling up;
|
||||
if(_pY < 0)
|
||||
{
|
||||
setRect(rect2, 0, 0, _src->w, _src->h - _pY);
|
||||
|
||||
part1 = GetSubSurface(_src, rect2.x, rect2.y, rect2.w, rect2.h);
|
||||
|
||||
SDL_Rect destrect1;
|
||||
|
||||
SDL_SetSurfaceBlendMode(part1, SDL_BLENDMODE_NONE);
|
||||
|
||||
setRect(destrect1, 0, _pY, _pX, _src->h);
|
||||
|
||||
SDL_BlitSurface (part1, NULL, _src, &destrect1);
|
||||
}
|
||||
|
||||
else if(_pY > 0)
|
||||
{
|
||||
|
||||
setRect(rect1, 0, 0, _src->w, _src->h - _pY);
|
||||
|
||||
part1 = GetSubSurface(_src, rect1.x, rect1.y, rect1.w, rect1.h);
|
||||
|
||||
SDL_Rect destrect1;
|
||||
|
||||
SDL_SetSurfaceBlendMode(part1, SDL_BLENDMODE_NONE);
|
||||
|
||||
setRect(destrect1, _pX, _pY, _src->w, _src->h - _pY);
|
||||
|
||||
SDL_BlitSurface (part1, NULL, _src, &destrect1);
|
||||
|
||||
}
|
||||
|
||||
//Right
|
||||
else if(_pX <= 0)
|
||||
{
|
||||
setRect(rect2, 0, 0, _src->w - _pX, _src->h );
|
||||
|
||||
part1 = GetSubSurface(_src, rect2.x, rect2.y, rect2.w, rect2.h);
|
||||
|
||||
SDL_Rect destrect1;
|
||||
|
||||
SDL_SetSurfaceBlendMode(part1, SDL_BLENDMODE_NONE);
|
||||
|
||||
setRect(destrect1, _pX, 0, _src->w - _pX, _src->h);
|
||||
|
||||
SDL_BlitSurface (part1, NULL, _src, &destrect1);
|
||||
}
|
||||
|
||||
else if(_pX > 0)
|
||||
{
|
||||
|
||||
setRect(rect1, _pX, 0, _src->w - _pX, _src->h );
|
||||
|
||||
part1 = GetSubSurface(_src, rect1.x, rect1.y, rect1.w, rect1.h);
|
||||
|
||||
SDL_Rect destrect1;
|
||||
|
||||
SDL_SetSurfaceBlendMode(part1, SDL_BLENDMODE_NONE);
|
||||
|
||||
setRect(destrect1, 0, 0, _src->w - _pX, _src->h);
|
||||
|
||||
SDL_BlitSurface (part1, NULL, _src, &destrect1);
|
||||
|
||||
}
|
||||
//Cleanup temp surface
|
||||
if (part1)
|
||||
{
|
||||
SDL_FreeSurface(part1);
|
||||
}
|
||||
|
||||
}
|
||||
51
desktop_version/src/GraphicsUtil.h
Normal file
51
desktop_version/src/GraphicsUtil.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef GRAPHICSUTIL_H
|
||||
#define GRAPHICSUTIL_H
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
struct colourTransform
|
||||
{
|
||||
Uint32 colour;
|
||||
};
|
||||
|
||||
|
||||
void setRect(SDL_Rect& _r, int x, int y, int w, int h);
|
||||
|
||||
unsigned int endian_swap(unsigned int x);
|
||||
|
||||
SDL_Surface* GetSubSurface( SDL_Surface* metaSurface, int x, int y, int width, int height );
|
||||
|
||||
void DrawPixel( SDL_Surface *surface, int x, int y, Uint32 pixel );
|
||||
|
||||
Uint32 ReadPixel( SDL_Surface *surface, int x, int y );
|
||||
|
||||
SDL_Surface * ScaleSurface( SDL_Surface *Surface, int Width, int Height, SDL_Surface * Dest = NULL );
|
||||
|
||||
void BlitSurfaceStandard( SDL_Surface* _src, SDL_Rect* _srcRect, SDL_Surface* _dest, SDL_Rect* _destRect );
|
||||
|
||||
void BlitSurfaceColoured( SDL_Surface* _src, SDL_Rect* _srcRect, SDL_Surface* _dest, SDL_Rect* _destRect, colourTransform& ct );
|
||||
|
||||
void FillRect( SDL_Surface* surface, const int x, const int y, const int w, const int h, const int r, int g, int b );
|
||||
|
||||
void FillRect( SDL_Surface* surface, const int r, int g, int b );
|
||||
|
||||
void FillRect( SDL_Surface* surface, const int color );
|
||||
|
||||
void FillRect( SDL_Surface* surface, const int x, const int y, const int w, const int h, int rgba );
|
||||
|
||||
void FillRect( SDL_Surface* surface, SDL_Rect& rect, const int r, int g, int b );
|
||||
|
||||
void FillRect( SDL_Surface* surface, SDL_Rect rect, int rgba );
|
||||
|
||||
bool intersectRect(float left1, float right1, float bottom1, float top1, float left2, float right2, float bottom2, float top2);
|
||||
|
||||
void OverlaySurfaceKeyed(SDL_Surface* _src, SDL_Surface* _dest, Uint32 _key);
|
||||
|
||||
void ScrollSurface(SDL_Surface* _src, int pX, int py);
|
||||
|
||||
SDL_Surface * FlipSurfaceHorizontal(SDL_Surface* _src);
|
||||
SDL_Surface * FlipSurfaceVerticle(SDL_Surface* _src);
|
||||
SDL_Surface * ScaleSurfaceSlow( SDL_Surface *_surface, int Width, int Height );
|
||||
SDL_Surface* ApplyFilter( SDL_Surface* _src );
|
||||
|
||||
#endif /* GRAPHICSUTIL_H */
|
||||
2546
desktop_version/src/Input.cpp
Normal file
2546
desktop_version/src/Input.cpp
Normal file
File diff suppressed because it is too large
Load Diff
30
desktop_version/src/Input.h
Normal file
30
desktop_version/src/Input.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef INPUT_H
|
||||
#define INPUT_H
|
||||
|
||||
#include "KeyPoll.h"
|
||||
#include "Graphics.h"
|
||||
#include "Game.h"
|
||||
#include "Entity.h"
|
||||
#include "UtilityClass.h"
|
||||
#include "Music.h"
|
||||
#include "Map.h"
|
||||
|
||||
void titleinput(KeyPoll& key, Graphics& dwgfx, mapclass& map, Game& game,
|
||||
entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
void gameinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
|
||||
entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
void mapinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
|
||||
entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
void teleporterinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
|
||||
entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
void gamecompleteinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
|
||||
entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
void gamecompleteinput2(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
|
||||
entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
#endif /* INPUT_H */
|
||||
333
desktop_version/src/KeyPoll.cpp
Normal file
333
desktop_version/src/KeyPoll.cpp
Normal file
@@ -0,0 +1,333 @@
|
||||
#include "KeyPoll.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void KeyPoll::setSensitivity(int _value)
|
||||
{
|
||||
switch (_value)
|
||||
{
|
||||
case 0:
|
||||
sensitivity = 28000;
|
||||
break;
|
||||
case 1:
|
||||
sensitivity = 16000;
|
||||
break;
|
||||
case 2:
|
||||
sensitivity = 8000;
|
||||
break;
|
||||
case 3:
|
||||
sensitivity = 4000;
|
||||
break;
|
||||
case 4:
|
||||
sensitivity = 2000;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
KeyPoll::KeyPoll()
|
||||
{
|
||||
xVel = 0;
|
||||
yVel = 0;
|
||||
setSensitivity(2);
|
||||
|
||||
quitProgram = 0;
|
||||
textentrymode=true;
|
||||
keybuffer="";
|
||||
leftbutton=0; rightbutton=0; middlebutton=0;
|
||||
mx=0; my=0;
|
||||
resetWindow = 0;
|
||||
toggleFullscreen = false;
|
||||
pressedbackspace=false;
|
||||
|
||||
useFullscreenSpaces = false;
|
||||
if (strcmp(SDL_GetPlatform(), "Mac OS X") == 0)
|
||||
{
|
||||
useFullscreenSpaces = true;
|
||||
const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES);
|
||||
if (hint != NULL)
|
||||
{
|
||||
useFullscreenSpaces = (strcmp(hint, "1") == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KeyPoll::enabletextentry()
|
||||
{
|
||||
keybuffer="";
|
||||
textentrymode = true;
|
||||
SDL_StartTextInput();
|
||||
}
|
||||
|
||||
void KeyPoll::disabletextentry()
|
||||
{
|
||||
textentrymode = false;
|
||||
SDL_StopTextInput();
|
||||
}
|
||||
|
||||
void KeyPoll::Poll()
|
||||
{
|
||||
SDL_Event evt;
|
||||
while (SDL_PollEvent(&evt))
|
||||
{
|
||||
/* Keyboard Input */
|
||||
if (evt.type == SDL_KEYDOWN)
|
||||
{
|
||||
keymap[evt.key.keysym.sym] = true;
|
||||
if (evt.key.keysym.sym == SDLK_BACKSPACE)
|
||||
{
|
||||
pressedbackspace = true;
|
||||
}
|
||||
else if ( ( evt.key.keysym.sym == SDLK_RETURN ||
|
||||
evt.key.keysym.sym == SDLK_f ) &&
|
||||
#ifdef __APPLE__ /* OSX prefers the command key over the alt keys. -flibit */
|
||||
keymap[SDLK_LGUI] )
|
||||
#else
|
||||
( keymap[SDLK_LALT] ||
|
||||
keymap[SDLK_RALT] ) )
|
||||
#endif
|
||||
{
|
||||
toggleFullscreen = true;
|
||||
}
|
||||
|
||||
if (textentrymode)
|
||||
{
|
||||
if (evt.key.keysym.sym == SDLK_BACKSPACE)
|
||||
{
|
||||
keybuffer = keybuffer.substr(0, keybuffer.length() - 1);
|
||||
}
|
||||
else if ( evt.key.keysym.sym == SDLK_v &&
|
||||
keymap[SDLK_LCTRL] )
|
||||
{
|
||||
keybuffer += SDL_GetClipboardText();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (evt.type == SDL_KEYUP)
|
||||
{
|
||||
keymap[evt.key.keysym.sym] = false;
|
||||
if (evt.key.keysym.sym == SDLK_BACKSPACE)
|
||||
{
|
||||
pressedbackspace = false;
|
||||
}
|
||||
}
|
||||
else if (evt.type == SDL_TEXTINPUT)
|
||||
{
|
||||
keybuffer += evt.text.text;
|
||||
}
|
||||
|
||||
/* Mouse Input */
|
||||
else if (evt.type == SDL_MOUSEMOTION)
|
||||
{
|
||||
mx = evt.motion.x;
|
||||
my = evt.motion.y;
|
||||
}
|
||||
else if (evt.type == SDL_MOUSEBUTTONDOWN)
|
||||
{
|
||||
if (evt.button.button == SDL_BUTTON_LEFT)
|
||||
{
|
||||
mx = evt.button.x;
|
||||
my = evt.button.y;
|
||||
leftbutton = 1;
|
||||
}
|
||||
else if (evt.button.button == SDL_BUTTON_RIGHT)
|
||||
{
|
||||
mx = evt.button.x;
|
||||
my = evt.button.y;
|
||||
rightbutton = 1;
|
||||
}
|
||||
else if (evt.button.button == SDL_BUTTON_MIDDLE)
|
||||
{
|
||||
mx = evt.button.x;
|
||||
my = evt.button.y;
|
||||
middlebutton = 1;
|
||||
}
|
||||
}
|
||||
else if (evt.type == SDL_MOUSEBUTTONUP)
|
||||
{
|
||||
if (evt.button.button == SDL_BUTTON_LEFT)
|
||||
{
|
||||
mx = evt.button.x;
|
||||
my = evt.button.y;
|
||||
leftbutton=0;
|
||||
}
|
||||
else if (evt.button.button == SDL_BUTTON_RIGHT)
|
||||
{
|
||||
mx = evt.button.x;
|
||||
my = evt.button.y;
|
||||
rightbutton=0;
|
||||
}
|
||||
else if (evt.button.button == SDL_BUTTON_MIDDLE)
|
||||
{
|
||||
mx = evt.button.x;
|
||||
my = evt.button.y;
|
||||
middlebutton=0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Controller Input */
|
||||
else if (evt.type == SDL_CONTROLLERBUTTONDOWN)
|
||||
{
|
||||
buttonmap[(SDL_GameControllerButton) evt.cbutton.button] = true;
|
||||
}
|
||||
else if (evt.type == SDL_CONTROLLERBUTTONUP)
|
||||
{
|
||||
buttonmap[(SDL_GameControllerButton) evt.cbutton.button] = false;
|
||||
}
|
||||
else if (evt.type == SDL_CONTROLLERAXISMOTION)
|
||||
{
|
||||
if (evt.caxis.axis == SDL_CONTROLLER_AXIS_LEFTX)
|
||||
{
|
||||
if ( evt.caxis.value > -sensitivity &&
|
||||
evt.caxis.value < sensitivity )
|
||||
{
|
||||
xVel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
xVel = (evt.caxis.value > 0) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
if (evt.caxis.axis == SDL_CONTROLLER_AXIS_LEFTY)
|
||||
{
|
||||
if ( evt.caxis.value > -sensitivity &&
|
||||
evt.caxis.value < sensitivity )
|
||||
{
|
||||
yVel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
yVel = (evt.caxis.value > 0) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (evt.type == SDL_CONTROLLERDEVICEADDED)
|
||||
{
|
||||
SDL_GameController *toOpen = SDL_GameControllerOpen(evt.cdevice.which);
|
||||
printf(
|
||||
"Opened SDL_GameController ID #%i, %s\n",
|
||||
evt.cdevice.which,
|
||||
SDL_GameControllerName(toOpen)
|
||||
);
|
||||
controllers[SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(toOpen))] = toOpen;
|
||||
}
|
||||
else if (evt.type == SDL_CONTROLLERDEVICEREMOVED)
|
||||
{
|
||||
SDL_GameController *toClose = controllers[evt.cdevice.which];
|
||||
controllers.erase(evt.cdevice.which);
|
||||
printf("Closing %s\n", SDL_GameControllerName(toClose));
|
||||
SDL_GameControllerClose(toClose);
|
||||
}
|
||||
|
||||
/* Window Events */
|
||||
else if (evt.type == SDL_WINDOWEVENT)
|
||||
{
|
||||
/* Window Resize */
|
||||
if (evt.window.event == SDL_WINDOWEVENT_RESIZED)
|
||||
{
|
||||
resetWindow = true;
|
||||
}
|
||||
|
||||
/* Window Focus */
|
||||
else if (evt.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
||||
{
|
||||
isActive = true;
|
||||
if (!useFullscreenSpaces)
|
||||
{
|
||||
SDL_Window *window = SDL_GetWindowFromID(evt.window.windowID);
|
||||
wasFullscreen = SDL_GetWindowFlags(window);
|
||||
SDL_SetWindowFullscreen(window, 0);
|
||||
}
|
||||
SDL_DisableScreenSaver();
|
||||
}
|
||||
else if (evt.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||
{
|
||||
isActive = false;
|
||||
if (!useFullscreenSpaces)
|
||||
{
|
||||
SDL_SetWindowFullscreen(
|
||||
SDL_GetWindowFromID(evt.window.windowID),
|
||||
wasFullscreen
|
||||
);
|
||||
}
|
||||
SDL_EnableScreenSaver();
|
||||
}
|
||||
|
||||
/* Mouse Focus */
|
||||
else if (evt.window.event == SDL_WINDOWEVENT_ENTER)
|
||||
{
|
||||
SDL_DisableScreenSaver();
|
||||
}
|
||||
else if (evt.window.event == SDL_WINDOWEVENT_LEAVE)
|
||||
{
|
||||
SDL_EnableScreenSaver();
|
||||
}
|
||||
}
|
||||
|
||||
/* Quit Event */
|
||||
else if (evt.type == SDL_QUIT)
|
||||
{
|
||||
quitProgram = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool KeyPoll::isDown(SDL_Keycode key)
|
||||
{
|
||||
return keymap[key];
|
||||
}
|
||||
|
||||
bool KeyPoll::isUp(SDL_Keycode key)
|
||||
{
|
||||
return !keymap[key];
|
||||
}
|
||||
|
||||
bool KeyPoll::isDown(std::vector<SDL_GameControllerButton> buttons)
|
||||
{
|
||||
for (size_t i = 0; i < buttons.size(); i += 1)
|
||||
{
|
||||
if (buttonmap[buttons[i]])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KeyPoll::isDown(SDL_GameControllerButton button)
|
||||
{
|
||||
return buttonmap[button];
|
||||
}
|
||||
|
||||
bool KeyPoll::controllerButtonDown()
|
||||
{
|
||||
for (
|
||||
SDL_GameControllerButton button = SDL_CONTROLLER_BUTTON_A;
|
||||
button < SDL_CONTROLLER_BUTTON_DPAD_UP;
|
||||
button = (SDL_GameControllerButton) (button + 1)
|
||||
) {
|
||||
if (isDown(button))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KeyPoll::controllerWantsLeft(bool includeVert)
|
||||
{
|
||||
return ( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_LEFT] ||
|
||||
xVel < 0 ||
|
||||
( includeVert &&
|
||||
( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_UP] ||
|
||||
yVel < 0 ) ) );
|
||||
}
|
||||
|
||||
bool KeyPoll::controllerWantsRight(bool includeVert)
|
||||
{
|
||||
return ( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_RIGHT] ||
|
||||
xVel > 0 ||
|
||||
( includeVert &&
|
||||
( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_DOWN] ||
|
||||
yVel > 0 ) ) );
|
||||
}
|
||||
83
desktop_version/src/KeyPoll.h
Normal file
83
desktop_version/src/KeyPoll.h
Normal file
@@ -0,0 +1,83 @@
|
||||
#ifndef KEYPOLL_H
|
||||
#define KEYPOLL_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map> // FIXME: I should feel very bad for using C++ -flibit
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
enum Kybrd
|
||||
{
|
||||
KEYBOARD_UP = SDLK_UP,
|
||||
KEYBOARD_DOWN = SDLK_DOWN,
|
||||
KEYBOARD_LEFT = SDLK_LEFT,
|
||||
KEYBOARD_RIGHT = SDLK_RIGHT,
|
||||
KEYBOARD_ENTER = SDLK_RETURN,
|
||||
KEYBOARD_SPACE = SDLK_SPACE,
|
||||
|
||||
KEYBOARD_w = SDLK_w,
|
||||
KEYBOARD_s = SDLK_s,
|
||||
KEYBOARD_a = SDLK_a,
|
||||
KEYBOARD_d = SDLK_d,
|
||||
KEYBOARD_m = SDLK_m,
|
||||
|
||||
KEYBOARD_v = SDLK_v,
|
||||
KEYBOARD_z = SDLK_z,
|
||||
|
||||
KEYBOARD_BACKSPACE = SDLK_BACKSPACE
|
||||
};
|
||||
|
||||
class KeyPoll
|
||||
{
|
||||
public:
|
||||
std::map<SDL_Keycode, bool> keymap;
|
||||
|
||||
bool isActive;
|
||||
|
||||
bool resetWindow;
|
||||
|
||||
bool escapeWasPressedPreviously;
|
||||
bool quitProgram;
|
||||
bool toggleFullscreen;
|
||||
|
||||
int sensitivity;
|
||||
|
||||
void setSensitivity(int _value);
|
||||
|
||||
KeyPoll();
|
||||
|
||||
void enabletextentry();
|
||||
|
||||
void disabletextentry();
|
||||
|
||||
void Poll();
|
||||
|
||||
bool isDown(SDL_Keycode key);
|
||||
|
||||
bool isUp(SDL_Keycode key);
|
||||
|
||||
bool isDown(std::vector<SDL_GameControllerButton> buttons);
|
||||
bool isDown(SDL_GameControllerButton button);
|
||||
bool controllerButtonDown();
|
||||
bool controllerWantsLeft(bool includeVert);
|
||||
bool controllerWantsRight(bool includeVert);
|
||||
|
||||
int leftbutton, rightbutton, middlebutton;
|
||||
int mx, my;
|
||||
|
||||
bool textentrymode;
|
||||
int keyentered, keybufferlen;
|
||||
bool pressedbackspace;
|
||||
std::string keybuffer;
|
||||
|
||||
private:
|
||||
std::map<SDL_JoystickID, SDL_GameController*> controllers;
|
||||
std::map<SDL_GameControllerButton, bool> buttonmap;
|
||||
int xVel, yVel;
|
||||
bool useFullscreenSpaces;
|
||||
Uint32 wasFullscreen;
|
||||
};
|
||||
|
||||
|
||||
#endif /* KEYPOLL_H */
|
||||
1862
desktop_version/src/Labclass.cpp
Normal file
1862
desktop_version/src/Labclass.cpp
Normal file
File diff suppressed because it is too large
Load Diff
18
desktop_version/src/Labclass.h
Normal file
18
desktop_version/src/Labclass.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef LABCLASS_H
|
||||
#define LABCLASS_H
|
||||
|
||||
#include "Game.h"
|
||||
#include "Entity.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class labclass
|
||||
{
|
||||
public:
|
||||
std::vector<std::string> loadlevel(int rx, int ry , Game& game, entityclass& obj);
|
||||
|
||||
std::string roomname;
|
||||
int coin, rcol;
|
||||
};
|
||||
#endif /* LABCLASS_H */
|
||||
1547
desktop_version/src/Logic.cpp
Normal file
1547
desktop_version/src/Logic.cpp
Normal file
File diff suppressed because it is too large
Load Diff
23
desktop_version/src/Logic.h
Normal file
23
desktop_version/src/Logic.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef LOGIC_H
|
||||
#define LOGIC_H
|
||||
|
||||
#include "Graphics.h"
|
||||
#include "Game.h"
|
||||
#include "Entity.h"
|
||||
#include "UtilityClass.h"
|
||||
#include "Music.h"
|
||||
#include "Map.h"
|
||||
|
||||
void titlelogic(Graphics& dwgfx, Game& game, entityclass& obj, UtilityClass& help, musicclass& music, mapclass& map);
|
||||
|
||||
void maplogic(Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music, mapclass& map, UtilityClass& help);
|
||||
|
||||
void gamecompletelogic(Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music, mapclass& map, UtilityClass& help);
|
||||
|
||||
void gamecompletelogic2(Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music, mapclass& map, UtilityClass& help);
|
||||
|
||||
void towerlogic(Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music, mapclass& map, UtilityClass& help);
|
||||
|
||||
void gamelogic(Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music, mapclass& map, UtilityClass& help);
|
||||
|
||||
#endif /* LOGIC_H */
|
||||
10
desktop_version/src/MakeAndPlay.h
Normal file
10
desktop_version/src/MakeAndPlay.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef MAKEANDPLAY_H
|
||||
#define MAKEANDPLAY_H
|
||||
|
||||
/* This is a cheap way to deal with the MAKEANDPLAY def when recompiling.
|
||||
* It's heaps faster than rebuilding everything, so here we are.
|
||||
* -flibit
|
||||
*/
|
||||
// #define MAKEANDPLAY
|
||||
|
||||
#endif /* MAKEANDPLAY_H */
|
||||
1997
desktop_version/src/Map.cpp
Normal file
1997
desktop_version/src/Map.cpp
Normal file
File diff suppressed because it is too large
Load Diff
182
desktop_version/src/Map.h
Normal file
182
desktop_version/src/Map.h
Normal file
@@ -0,0 +1,182 @@
|
||||
#ifndef MAPGAME_H
|
||||
#define MAPGAME_H
|
||||
|
||||
#include "Tower.h"
|
||||
#include "WarpClass.h"
|
||||
#include "Finalclass.h"
|
||||
#include "Labclass.h"
|
||||
#include "Spacestation2.h"
|
||||
#include "Otherlevel.h"
|
||||
#include "Entity.h"
|
||||
#include "Graphics.h"
|
||||
#include <vector>
|
||||
#include "Music.h"
|
||||
#include "editor.h"
|
||||
|
||||
extern editorclass ed;
|
||||
|
||||
class mapclass
|
||||
{
|
||||
public:
|
||||
mapclass();
|
||||
|
||||
int RGB(int red,int green,int blue);
|
||||
|
||||
int intpol(int a, int b, float c);
|
||||
|
||||
void setteleporter(int t, int x, int y);
|
||||
|
||||
void settrinket(int t, int x, int y);
|
||||
|
||||
void resetmap();
|
||||
|
||||
void resetnames();
|
||||
|
||||
void transformname(int t);
|
||||
|
||||
std::string getglitchname(int x, int y);
|
||||
|
||||
void initmapdata();
|
||||
|
||||
int finalat(int x, int y);
|
||||
|
||||
int maptiletoenemycol(int t);
|
||||
|
||||
void changefinalcol(int t, entityclass& obj, Game& game);
|
||||
|
||||
void setcol(const int r1, const int g1, const int b1 , const int r2, const int g2, const int b2, const int c);
|
||||
|
||||
void updatetowerglow();
|
||||
|
||||
void nexttowercolour();
|
||||
|
||||
void settowercolour(int t);
|
||||
|
||||
bool spikecollide(int x, int y);
|
||||
|
||||
bool collide(int x, int y);
|
||||
|
||||
void fillareamap(std::vector<std::string>& tmap);
|
||||
|
||||
void settile(int xp, int yp, int t);
|
||||
|
||||
void fillcontent(std::vector<std::string>& tmap);
|
||||
|
||||
|
||||
int area(int _rx, int _ry);
|
||||
|
||||
void exploretower();
|
||||
|
||||
void hideship();
|
||||
|
||||
void showship();
|
||||
|
||||
void resetplayer(Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music);
|
||||
|
||||
void warpto(int rx, int ry , int t, int tx, int ty, Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music);
|
||||
|
||||
void gotoroom(int rx, int ry, Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music);
|
||||
|
||||
std::string currentarea(int t);
|
||||
|
||||
void loadlevel(int rx, int ry, Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music);
|
||||
|
||||
|
||||
std::vector <int> roomdeaths;
|
||||
std::vector <int> roomdeathsfinal;
|
||||
std::vector <int> areamap;
|
||||
std::vector <int> contents;
|
||||
std::vector <int> explored;
|
||||
std::vector <int> vmult;
|
||||
std::vector <std::string> tmap;
|
||||
|
||||
int temp;
|
||||
int temp2;
|
||||
int j;
|
||||
int background;
|
||||
int rcol;
|
||||
int tileset;
|
||||
bool warpx;
|
||||
bool warpy;
|
||||
|
||||
|
||||
std::string roomname;
|
||||
|
||||
//Special tower stuff
|
||||
bool towermode;
|
||||
float ypos;
|
||||
int bypos;
|
||||
int cameramode;
|
||||
int cameraseek, cameraseekframe;
|
||||
int resumedelay;
|
||||
bool minitowermode;
|
||||
int scrolldir;
|
||||
|
||||
//This is the old colour cycle
|
||||
int r, g,b;
|
||||
int check, cmode;
|
||||
int towercol;
|
||||
int colstate, colstatedelay;
|
||||
int colsuperstate;
|
||||
int spikeleveltop, spikelevelbottom;
|
||||
bool tdrawback;
|
||||
int bscroll;
|
||||
//final level navigation
|
||||
int finalx;
|
||||
int finaly;
|
||||
bool finalmode;
|
||||
bool finalstretch;
|
||||
|
||||
//Variables for playing custom levels
|
||||
bool custommode;
|
||||
bool custommodeforreal;
|
||||
int customx, customy;
|
||||
int customwidth, customheight;
|
||||
int customtrinkets;
|
||||
int customcrewmates;
|
||||
int custommmxoff, custommmyoff, custommmxsize, custommmysize;
|
||||
int customzoom;
|
||||
bool customshowmm;
|
||||
|
||||
std::vector<std::string> specialnames;
|
||||
int glitchmode;
|
||||
int glitchdelay;
|
||||
std::string glitchname;
|
||||
|
||||
//final level colour cycling stuff
|
||||
bool final_colormode;
|
||||
int final_mapcol;
|
||||
int final_aniframe;
|
||||
int final_aniframedelay;
|
||||
int final_colorframe, final_colorframedelay;
|
||||
|
||||
//Teleporters and Trinkets on the map
|
||||
std::vector<point> teleporters;
|
||||
std::vector<point> shinytrinkets;
|
||||
|
||||
int numteleporters, numshinytrinkets;
|
||||
bool showteleporters, showtargets, showtrinkets;
|
||||
|
||||
//Roomtext
|
||||
int roomtextx[100], roomtexty[100];
|
||||
bool roomtexton;
|
||||
std::vector<std::string> roomtext;
|
||||
int roomtextnumlines;
|
||||
|
||||
//Levels
|
||||
otherlevelclass otherlevel;
|
||||
spacestation2class spacestation2;
|
||||
labclass lablevel;
|
||||
finalclass finallevel;
|
||||
warpclass warplevel;
|
||||
towerclass tower;
|
||||
int extrarow;
|
||||
|
||||
//Accessibility options
|
||||
bool invincibility;
|
||||
|
||||
//Map cursor
|
||||
int cursorstate, cursordelay;
|
||||
};
|
||||
|
||||
#endif /* MAPGAME_H */
|
||||
28
desktop_version/src/Maths.h
Normal file
28
desktop_version/src/Maths.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef MATHGAME_H
|
||||
#define MATHGAME_H
|
||||
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
|
||||
//// This header holds Maths functions that emulate the functionality of flash's
|
||||
|
||||
|
||||
//random
|
||||
//Returns 0..1
|
||||
float inline fRandom()
|
||||
{
|
||||
return ( float(rand()) / float(RAND_MAX)) ;
|
||||
}
|
||||
|
||||
inline int clamp(int x, int a, int b)
|
||||
{
|
||||
return x < a ? a : (x > b ? b : x);
|
||||
}
|
||||
|
||||
struct point
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
#endif /* MATHGAME_H */
|
||||
454
desktop_version/src/Music.cpp
Normal file
454
desktop_version/src/Music.cpp
Normal file
@@ -0,0 +1,454 @@
|
||||
#include <SDL.h>
|
||||
#include <stdio.h>
|
||||
#include "Music.h"
|
||||
#include "BinaryBlob.h"
|
||||
|
||||
musicclass::musicclass()
|
||||
{
|
||||
soundTracks.push_back(SoundTrack( "sounds/jump.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/jump2.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/hurt.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/souleyeminijingle.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/coin.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/save.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crumble.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/vanish.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/blip.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/preteleport.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/teleport.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crew1.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crew2.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crew3.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crew4.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crew5.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crew6.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/terminal.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/gamesaved.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crashing.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/blip2.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/countdown.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/go.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/crash.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/combine.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/newrecord.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/trophy.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/rescue.wav" ));
|
||||
|
||||
#ifdef VVV_COMPILEMUSIC
|
||||
binaryBlob musicWriteBlob;
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/0levelcomplete.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/1pushingonwards.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/2positiveforce.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/3potentialforanything.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/4passionforexploring.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/5intermission.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/6presentingvvvvvv.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/7gamecomplete.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/8predestinedfate.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/9positiveforcereversed.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/10popularpotpourri.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/11pipedream.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/12pressurecooker.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/13pacedenergy.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/14piercingthesky.ogg");
|
||||
musicWriteBlob.AddFileToBinaryBlob("data/music/predestinedfatefinallevel.ogg");
|
||||
|
||||
musicWriteBlob.writeBinaryBlob("data/BinaryMusic.vvv");
|
||||
#endif
|
||||
|
||||
binaryBlob musicReadBlob;
|
||||
if (!musicReadBlob.unPackBinary("mmmmmm.vvv"))
|
||||
{
|
||||
mmmmmm = false;
|
||||
usingmmmmmm=false;
|
||||
bool ohCrap = musicReadBlob.unPackBinary("vvvvvvmusic.vvv");
|
||||
SDL_assert(ohCrap && "Music not found!");
|
||||
}
|
||||
else
|
||||
{
|
||||
mmmmmm = true;
|
||||
usingmmmmmm = true;
|
||||
int index = musicReadBlob.getIndex("data/music/0levelcomplete.ogg");
|
||||
SDL_RWops *rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/1pushingonwards.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/2positiveforce.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/3potentialforanything.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/4passionforexploring.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/5intermission.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/6presentingvvvvvv.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/7gamecomplete.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/8predestinedfate.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/9positiveforcereversed.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/10popularpotpourri.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/11pipedream.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/12pressurecooker.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/13pacedenergy.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/14piercingthesky.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/predestinedfatefinallevel.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
bool ohCrap = musicReadBlob.unPackBinary("vvvvvvmusic.vvv");
|
||||
SDL_assert(ohCrap && "Music not found!");
|
||||
}
|
||||
|
||||
int index = musicReadBlob.getIndex("data/music/0levelcomplete.ogg");
|
||||
SDL_RWops *rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/1pushingonwards.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/2positiveforce.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/3potentialforanything.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/4passionforexploring.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/5intermission.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/6presentingvvvvvv.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/7gamecomplete.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/8predestinedfate.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/9positiveforcereversed.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/10popularpotpourri.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/11pipedream.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/12pressurecooker.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/13pacedenergy.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/14piercingthesky.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
index = musicReadBlob.getIndex("data/music/predestinedfatefinallevel.ogg");
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index));
|
||||
musicTracks.push_back(MusicTrack( rw ));
|
||||
|
||||
safeToProcessMusic= false;
|
||||
m_doFadeInVol = false;
|
||||
musicVolume = 128;
|
||||
FadeVolAmountPerFrame = 0;
|
||||
|
||||
custompd = false;
|
||||
// currentsong = -1;
|
||||
// nicefade = 0;
|
||||
}
|
||||
|
||||
void musicclass::play(int t)
|
||||
{
|
||||
t = (t % 16);
|
||||
|
||||
if(mmmmmm)
|
||||
{
|
||||
if(!usingmmmmmm)
|
||||
{
|
||||
t += 16;
|
||||
}
|
||||
}
|
||||
safeToProcessMusic = true;
|
||||
Mix_VolumeMusic(128);
|
||||
if (currentsong !=t)
|
||||
{
|
||||
if (currentsong != -1)
|
||||
{
|
||||
// Stop the old song first
|
||||
// musicchannel.stop();
|
||||
if (currentsong != 0)
|
||||
{
|
||||
// musicchannel.removeEventListener(Event.SOUND_COMPLETE, loopmusic);
|
||||
}
|
||||
}
|
||||
if (t != -1)
|
||||
{
|
||||
// musicfade = 0;
|
||||
currentsong = t;
|
||||
if (currentsong == 0 || currentsong == 7)
|
||||
{
|
||||
// Level Complete theme, no fade in or repeat
|
||||
// musicchannel = musicchan[currentsong].play(0);
|
||||
// musicchannel.soundTransform = new SoundTransform(1.0);
|
||||
if(Mix_FadeInMusic(musicTracks[t].m_music, 0, 0)==-1)
|
||||
{
|
||||
printf("Mix_PlayMusic: %s\n", Mix_GetError());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// musicfadein = 90;
|
||||
// musicchannel = musicchan[currentsong].play(0);
|
||||
// musicchannel.soundTransform = new SoundTransform(0);
|
||||
// musicchannel.addEventListener(Event.SOUND_COMPLETE, loopmusic);
|
||||
if(Mix_FadeInMusic(musicTracks[t].m_music, -1, 3000)==-1)
|
||||
{
|
||||
printf("Mix_FadeInMusic: %s\n", Mix_GetError());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentsong = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void musicclass::loopmusic()
|
||||
{
|
||||
//musicchannel.removeEventListener(Event.SOUND_COMPLETE, loopmusic);
|
||||
//if(currentsong>-1){
|
||||
// musicchannel = musicchan[currentsong].play();
|
||||
// musicchannel.addEventListener(Event.SOUND_COMPLETE, loopmusic);
|
||||
//}
|
||||
}
|
||||
|
||||
void musicclass::stopmusic()
|
||||
{
|
||||
// musicchannel.removeEventListener(Event.SOUND_COMPLETE, stopmusic);
|
||||
// musicchannel.stop();
|
||||
Mix_HaltMusic();
|
||||
currentsong = -1;
|
||||
}
|
||||
|
||||
void musicclass::haltdasmusik()
|
||||
{
|
||||
// musicchannel.removeEventListener(Event.SOUND_COMPLETE, stopmusic);
|
||||
// musicchannel.stop();
|
||||
// resumesong = currentsong;
|
||||
Mix_HaltMusic();
|
||||
currentsong = -1;
|
||||
}
|
||||
|
||||
void musicclass::silencedasmusik()
|
||||
{
|
||||
//if(currentsong>-1){
|
||||
// musicchannel.soundTransform = new SoundTransform(0);
|
||||
//}
|
||||
Mix_VolumeMusic(0) ;
|
||||
musicVolume = 0;
|
||||
}
|
||||
|
||||
void musicclass::fadeMusicVolumeIn(int ms)
|
||||
{
|
||||
m_doFadeInVol = true;
|
||||
FadeVolAmountPerFrame = MIX_MAX_VOLUME / (ms / 33);
|
||||
}
|
||||
|
||||
void musicclass::fadeout()
|
||||
{
|
||||
//if(currentsong>-1){
|
||||
// if (musicfade == 0) {
|
||||
// musicchannel.removeEventListener(Event.SOUND_COMPLETE, stopmusic);
|
||||
// musicfade = 61;
|
||||
// }
|
||||
//}
|
||||
|
||||
Mix_FadeOutMusic(2000);
|
||||
currentsong = -1;
|
||||
}
|
||||
|
||||
void musicclass::processmusicfade()
|
||||
{
|
||||
//musicfade--;
|
||||
//if (musicfade > 0) {
|
||||
// musicchannel.soundTransform = new SoundTransform(musicfade / 60);
|
||||
//}else {
|
||||
// musicchannel.stop();
|
||||
// currentsong = -1;
|
||||
//}
|
||||
}
|
||||
|
||||
void musicclass::processmusicfadein()
|
||||
{
|
||||
musicVolume += FadeVolAmountPerFrame;
|
||||
Mix_VolumeMusic(musicVolume);
|
||||
if (musicVolume >= MIX_MAX_VOLUME)
|
||||
{
|
||||
m_doFadeInVol = false;
|
||||
}
|
||||
}
|
||||
|
||||
void musicclass::processmusic()
|
||||
{
|
||||
if(!safeToProcessMusic)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//if (musicfade > 0) processmusicfade();
|
||||
//if (musicfadein > 0) processmusicfadein();
|
||||
|
||||
if (nicefade == 1 && Mix_PlayingMusic() == 0)
|
||||
{
|
||||
play(nicechange);
|
||||
nicechange = -1; nicefade = 0;
|
||||
}
|
||||
|
||||
if(m_doFadeInVol)
|
||||
{
|
||||
processmusicfadein();
|
||||
}
|
||||
|
||||
//musicstopother--;
|
||||
//if (musicstopother == 1) {
|
||||
// musicstopother = 0;
|
||||
// if (currentmusicchan == 0) musicchannel2.stop();
|
||||
// if (currentmusicchan == 1) musicchannel.stop();
|
||||
//}
|
||||
//if (musicstopother < 0) musicstopother = 0;
|
||||
|
||||
//musicchancur--;
|
||||
//if (musicchancur <= 0 && currentsong > -1 && musicchanlen > 0) {
|
||||
// musicchancur = musicchanlen;
|
||||
// if (currentmusicchan == 0) {
|
||||
// musicchannel2 = musicchan[currentsong].play();
|
||||
// musicstopother = 3;
|
||||
// currentmusicchan = 1;
|
||||
// }else {
|
||||
// musicchannel = musicchan[currentsong].play();
|
||||
// musicstopother = 3;
|
||||
// currentmusicchan = 0;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
void musicclass::niceplay(int t)
|
||||
{
|
||||
// important: do nothing if the correct song is playing!
|
||||
if(currentsong!=t)
|
||||
{
|
||||
if(currentsong!=-1) fadeout();
|
||||
nicefade = 1;
|
||||
nicechange = t;
|
||||
}
|
||||
}
|
||||
|
||||
void musicclass::changemusicarea(int x, int y)
|
||||
{
|
||||
switch(musicroom(x, y))
|
||||
{
|
||||
case musicroom(11, 4):
|
||||
niceplay(2);
|
||||
break;
|
||||
|
||||
case musicroom(2, 4):
|
||||
case musicroom(7, 15):
|
||||
niceplay(3);
|
||||
break;
|
||||
|
||||
case musicroom(18, 1):
|
||||
case musicroom(15, 0):
|
||||
niceplay(12);
|
||||
break;
|
||||
|
||||
case musicroom(0, 0):
|
||||
case musicroom(0, 16):
|
||||
case musicroom(2, 11):
|
||||
case musicroom(7, 9):
|
||||
case musicroom(8, 11):
|
||||
case musicroom(13, 2):
|
||||
case musicroom(17, 12):
|
||||
case musicroom(14, 19):
|
||||
case musicroom(17, 17):
|
||||
niceplay(4);
|
||||
break;
|
||||
|
||||
default:
|
||||
niceplay(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void musicclass::initefchannels()
|
||||
{
|
||||
// for (var i:int = 0; i < 16; i++) efchannel.push(new SoundChannel);
|
||||
}
|
||||
|
||||
void musicclass::playef(int t, int offset)
|
||||
{
|
||||
// efchannel[currentefchan] = efchan[t].play(offset);
|
||||
// currentefchan++;
|
||||
// if (currentefchan > 15) currentefchan -= 16;
|
||||
int channel;
|
||||
|
||||
channel = Mix_PlayChannel(-1, soundTracks[t].sound, 0);
|
||||
if(channel == -1)
|
||||
{
|
||||
fprintf(stderr, "Unable to play WAV file: %s\n", Mix_GetError());
|
||||
}
|
||||
}
|
||||
65
desktop_version/src/Music.h
Normal file
65
desktop_version/src/Music.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef MUSIC_H
|
||||
#define MUSIC_H
|
||||
|
||||
#include "SoundSystem.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#define musicroom(rx, ry) ((rx) + ((ry) * 20))
|
||||
|
||||
class musicclass
|
||||
{
|
||||
public:
|
||||
musicclass();
|
||||
|
||||
void play(int t);
|
||||
void loopmusic();
|
||||
void stopmusic();
|
||||
void haltdasmusik();
|
||||
void silencedasmusik();
|
||||
void fadeMusicVolumeIn(int ms);
|
||||
void fadeout();
|
||||
void processmusicfade();
|
||||
void processmusicfadein();
|
||||
void processmusic();
|
||||
void niceplay(int t);
|
||||
|
||||
void changemusicarea(int x, int y);
|
||||
|
||||
// public var musicchan:Array = new Array();
|
||||
// public var musicchannel:SoundChannel, musicchannel2:SoundChannel;
|
||||
// public var currentmusicchan:int, musicchanlen:int, musicchancur:int, musicstopother:int, resumesong:int;
|
||||
// public var currentsong:int, musicfade:int, musicfadein:int;
|
||||
int currentsong, musicfade, musicfadein;
|
||||
int resumesong;
|
||||
|
||||
//public var nicefade:int, nicechange:int;
|
||||
|
||||
// Play a sound effect! There are 16 channels, which iterate
|
||||
void initefchannels();
|
||||
|
||||
void playef(int t, int offset = 0);
|
||||
|
||||
std::vector<SoundTrack> soundTracks;
|
||||
std::vector<MusicTrack> musicTracks;
|
||||
SoundSystem soundSystem;
|
||||
bool safeToProcessMusic;
|
||||
|
||||
int nicechange;
|
||||
int nicefade;
|
||||
|
||||
bool m_doFadeInVol;
|
||||
int FadeVolAmountPerFrame;
|
||||
int musicVolume;
|
||||
|
||||
float volume;
|
||||
|
||||
bool custompd;
|
||||
|
||||
// MMMMMM mod settings
|
||||
bool mmmmmm;
|
||||
bool usingmmmmmm;
|
||||
};
|
||||
|
||||
|
||||
#endif /* MUSIC_H */
|
||||
28
desktop_version/src/Network.h
Normal file
28
desktop_version/src/Network.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef VNETWORK_H
|
||||
#define VNETWORK_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int NETWORK_init();
|
||||
|
||||
void NETWORK_shutdown();
|
||||
|
||||
void NETWORK_update();
|
||||
|
||||
void NETWORK_unlockAchievement(const char *name);
|
||||
|
||||
int32_t NETWORK_getAchievementProgress(const char *name);
|
||||
|
||||
void NETWORK_setAchievementProgress(const char *name, int32_t stat);
|
||||
|
||||
/* TODO: Steam Workshop? */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* VNETWORK_H */
|
||||
8099
desktop_version/src/Otherlevel.cpp
Normal file
8099
desktop_version/src/Otherlevel.cpp
Normal file
File diff suppressed because it is too large
Load Diff
38
desktop_version/src/Otherlevel.h
Normal file
38
desktop_version/src/Otherlevel.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef OTHERLEVEL_H
|
||||
#define OTHERLEVEL_H
|
||||
|
||||
#include "Game.h"
|
||||
#include "Entity.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class otherlevelclass
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
BLOCK = 0,
|
||||
TRIGGER,
|
||||
DAMAGE,
|
||||
DIRECTIONAL,
|
||||
SAFE,
|
||||
ACTIVITY
|
||||
};
|
||||
|
||||
otherlevelclass();
|
||||
void addline(std::string t);
|
||||
std::vector<std::string> loadlevel(int rx, int ry , Game& game, entityclass& obj);
|
||||
|
||||
std::string roomname;
|
||||
|
||||
int roomtileset;
|
||||
int i;
|
||||
|
||||
// roomtext thing in other level
|
||||
bool roomtexton;
|
||||
int roomtextx, roomtexty, roomtextnumlines;
|
||||
std::vector<std::string> roomtext;
|
||||
};
|
||||
|
||||
#endif /* OTHERLEVEL_H */
|
||||
212
desktop_version/src/Screen.cpp
Normal file
212
desktop_version/src/Screen.cpp
Normal file
@@ -0,0 +1,212 @@
|
||||
#include "Screen.h"
|
||||
|
||||
#include "FileSystemUtils.h"
|
||||
#include "GraphicsUtil.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// Used to create the window icon
|
||||
extern "C"
|
||||
{
|
||||
extern unsigned lodepng_decode24(
|
||||
unsigned char** out,
|
||||
unsigned* w,
|
||||
unsigned* h,
|
||||
const unsigned char* in,
|
||||
size_t insize
|
||||
);
|
||||
}
|
||||
|
||||
Screen::Screen()
|
||||
{
|
||||
m_window = NULL;
|
||||
m_renderer = NULL;
|
||||
m_screenTexture = NULL;
|
||||
m_screen = NULL;
|
||||
isWindowed = true;
|
||||
stretchMode = 0;
|
||||
isFiltered = false;
|
||||
filterSubrect.x = 1;
|
||||
filterSubrect.y = 1;
|
||||
filterSubrect.w = 318;
|
||||
filterSubrect.h = 238;
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
|
||||
|
||||
// Uncomment this next line when you need to debug -flibit
|
||||
// SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, "software", SDL_HINT_OVERRIDE);
|
||||
SDL_CreateWindowAndRenderer(
|
||||
640,
|
||||
480,
|
||||
SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE,
|
||||
&m_window,
|
||||
&m_renderer
|
||||
);
|
||||
SDL_SetWindowTitle(m_window, "VVVVVV");
|
||||
|
||||
unsigned char *fileIn = NULL;
|
||||
size_t length = 0;
|
||||
unsigned char *data;
|
||||
unsigned int width, height;
|
||||
FILESYSTEM_loadFileToMemory("VVVVVV.png", &fileIn, &length);
|
||||
lodepng_decode24(&data, &width, &height, fileIn, length);
|
||||
FILESYSTEM_freeMemory(&fileIn);
|
||||
SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(
|
||||
data,
|
||||
width,
|
||||
height,
|
||||
24,
|
||||
width * 3,
|
||||
0x000000FF,
|
||||
0x0000FF00,
|
||||
0x00FF0000,
|
||||
0x00000000
|
||||
);
|
||||
SDL_SetWindowIcon(m_window, icon);
|
||||
SDL_FreeSurface(icon);
|
||||
free(data);
|
||||
|
||||
// FIXME: This surface should be the actual backbuffer! -flibit
|
||||
m_screen = SDL_CreateRGBSurface(
|
||||
0,
|
||||
320,
|
||||
240,
|
||||
32,
|
||||
0x00FF0000,
|
||||
0x0000FF00,
|
||||
0x000000FF,
|
||||
0xFF000000
|
||||
);
|
||||
m_screenTexture = SDL_CreateTexture(
|
||||
m_renderer,
|
||||
SDL_PIXELFORMAT_ARGB8888,
|
||||
SDL_TEXTUREACCESS_STREAMING,
|
||||
320,
|
||||
240
|
||||
);
|
||||
|
||||
badSignalEffect = false;
|
||||
|
||||
glScreen = true;
|
||||
}
|
||||
|
||||
void Screen::ResizeScreen(int x , int y)
|
||||
{
|
||||
static int resX = 320;
|
||||
static int resY = 240;
|
||||
if (x != -1 && y != -1)
|
||||
{
|
||||
// This is a user resize!
|
||||
resX = x;
|
||||
resY = y;
|
||||
}
|
||||
|
||||
if(!isWindowed)
|
||||
{
|
||||
SDL_SetWindowFullscreen(m_window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_SetWindowFullscreen(m_window, 0);
|
||||
if (x != -1 && y != -1)
|
||||
{
|
||||
SDL_SetWindowSize(m_window, resX, resY);
|
||||
SDL_SetWindowPosition(m_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
}
|
||||
}
|
||||
if (stretchMode == 1)
|
||||
{
|
||||
int winX, winY;
|
||||
SDL_GetWindowSize(m_window, &winX, &winY);
|
||||
SDL_RenderSetLogicalSize(m_renderer, winX, winY);
|
||||
SDL_RenderSetIntegerScale(m_renderer, SDL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_RenderSetLogicalSize(m_renderer, 320, 240);
|
||||
SDL_RenderSetIntegerScale(m_renderer, (SDL_bool) (stretchMode == 2));
|
||||
}
|
||||
SDL_ShowWindow(m_window);
|
||||
}
|
||||
|
||||
void Screen::GetWindowSize(int* x, int* y)
|
||||
{
|
||||
SDL_GetWindowSize(m_window, x, y);
|
||||
}
|
||||
|
||||
void Screen::UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect )
|
||||
{
|
||||
if((buffer == NULL) && (m_screen == NULL) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(badSignalEffect)
|
||||
{
|
||||
buffer = ApplyFilter(buffer);
|
||||
}
|
||||
|
||||
|
||||
FillRect(m_screen, 0x000);
|
||||
BlitSurfaceStandard(buffer,NULL,m_screen,rect);
|
||||
|
||||
if(badSignalEffect)
|
||||
{
|
||||
SDL_FreeSurface(buffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const SDL_PixelFormat* Screen::GetFormat()
|
||||
{
|
||||
return m_screen->format;
|
||||
}
|
||||
|
||||
void Screen::FlipScreen()
|
||||
{
|
||||
SDL_UpdateTexture(
|
||||
m_screenTexture,
|
||||
NULL,
|
||||
m_screen->pixels,
|
||||
m_screen->pitch
|
||||
);
|
||||
SDL_RenderCopy(
|
||||
m_renderer,
|
||||
m_screenTexture,
|
||||
isFiltered ? &filterSubrect : NULL,
|
||||
NULL
|
||||
);
|
||||
SDL_RenderPresent(m_renderer);
|
||||
SDL_RenderClear(m_renderer);
|
||||
SDL_FillRect(m_screen, NULL, 0x00000000);
|
||||
}
|
||||
|
||||
void Screen::toggleFullScreen()
|
||||
{
|
||||
isWindowed = !isWindowed;
|
||||
ResizeScreen(-1, -1);
|
||||
}
|
||||
|
||||
void Screen::toggleStretchMode()
|
||||
{
|
||||
stretchMode = (stretchMode + 1) % 3;
|
||||
ResizeScreen(-1, -1);
|
||||
}
|
||||
|
||||
void Screen::toggleLinearFilter()
|
||||
{
|
||||
isFiltered = !isFiltered;
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, isFiltered ? "linear" : "nearest");
|
||||
SDL_DestroyTexture(m_screenTexture);
|
||||
m_screenTexture = SDL_CreateTexture(
|
||||
m_renderer,
|
||||
SDL_PIXELFORMAT_ARGB8888,
|
||||
SDL_TEXTUREACCESS_STREAMING,
|
||||
320,
|
||||
240
|
||||
);
|
||||
}
|
||||
|
||||
void Screen::ClearScreen( int colour )
|
||||
{
|
||||
//FillRect(m_screen, colour) ;
|
||||
}
|
||||
40
desktop_version/src/Screen.h
Normal file
40
desktop_version/src/Screen.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef SCREEN_H
|
||||
#define SCREEN_H
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
class Screen
|
||||
{
|
||||
public:
|
||||
Screen();
|
||||
|
||||
void ResizeScreen(int x, int y);
|
||||
void GetWindowSize(int* x, int* y);
|
||||
|
||||
void UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect);
|
||||
void ClearScreen(int colour);
|
||||
void FlipScreen();
|
||||
|
||||
const SDL_PixelFormat* GetFormat();
|
||||
|
||||
void toggleFullScreen();
|
||||
void toggleStretchMode();
|
||||
void toggleLinearFilter();
|
||||
|
||||
bool isWindowed;
|
||||
bool isFiltered;
|
||||
bool badSignalEffect;
|
||||
bool glScreen;
|
||||
int stretchMode;
|
||||
|
||||
SDL_Window *m_window;
|
||||
SDL_Renderer *m_renderer;
|
||||
SDL_Texture *m_screenTexture;
|
||||
SDL_Surface* m_screen;
|
||||
|
||||
SDL_Rect filterSubrect;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* SCREEN_H */
|
||||
3545
desktop_version/src/Script.cpp
Normal file
3545
desktop_version/src/Script.cpp
Normal file
File diff suppressed because it is too large
Load Diff
75
desktop_version/src/Script.h
Normal file
75
desktop_version/src/Script.h
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifndef SCRIPT_H
|
||||
#define SCRIPT_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Enums.h"
|
||||
|
||||
|
||||
class KeyPoll; class Graphics; class Game; class mapclass; class entityclass; class UtilityClass;class musicclass;
|
||||
|
||||
|
||||
class scriptclass
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
scriptclass();
|
||||
|
||||
void load(std::string t);
|
||||
void loadother(std::string t);
|
||||
|
||||
|
||||
void inline add(std::string t)
|
||||
{
|
||||
commands[scriptlength] = t;
|
||||
scriptlength++;
|
||||
}
|
||||
|
||||
void clearcustom();
|
||||
|
||||
void tokenize(std::string t);
|
||||
|
||||
void run(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
|
||||
entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
void resetgametomenu(Graphics& dwgfx, Game& game,mapclass& map,
|
||||
entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
void startgamemode(int t, KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
|
||||
entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
void teleport(Graphics& dwgfx, Game& game, mapclass& map,
|
||||
entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
void hardreset(KeyPoll& key, Graphics& dwgfx, Game& game,mapclass& map,
|
||||
entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
//Script contents
|
||||
std::vector<std::string> commands;
|
||||
std::vector<std::string> words;
|
||||
std::vector<std::string> txt;
|
||||
std::string scriptname;
|
||||
int position, scriptlength;
|
||||
int looppoint, loopcount;
|
||||
|
||||
int scriptdelay;
|
||||
bool running;
|
||||
std::string tempword;
|
||||
std::string currentletter;
|
||||
|
||||
//Textbox stuff
|
||||
int textx;
|
||||
int texty;
|
||||
int r,g,b;
|
||||
int txtnumlines;
|
||||
|
||||
//Misc
|
||||
int i, j, k;
|
||||
|
||||
//Custom level stuff
|
||||
std::vector <std::string> customscript;
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_H */
|
||||
6580
desktop_version/src/Scripts.cpp
Normal file
6580
desktop_version/src/Scripts.cpp
Normal file
File diff suppressed because it is too large
Load Diff
68
desktop_version/src/SoundSystem.cpp
Normal file
68
desktop_version/src/SoundSystem.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#include <SDL.h>
|
||||
#include "SoundSystem.h"
|
||||
#include "FileSystemUtils.h"
|
||||
|
||||
MusicTrack::MusicTrack(const char* fileName)
|
||||
{
|
||||
m_music = Mix_LoadMUS(fileName);
|
||||
m_isValid = true;
|
||||
if(m_music == NULL)
|
||||
{
|
||||
fprintf(stderr, "Unable to load Ogg Music file: %s\n", Mix_GetError());;
|
||||
m_isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
MusicTrack::MusicTrack(SDL_RWops *rw)
|
||||
{
|
||||
m_music = Mix_LoadMUS_RW(rw, 0);
|
||||
m_isValid = true;
|
||||
if(m_music == NULL)
|
||||
{
|
||||
fprintf(stderr, "Unable to load Magic Binary Music file: %s\n", Mix_GetError());
|
||||
m_isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
SoundTrack::SoundTrack(const char* fileName)
|
||||
{
|
||||
sound = NULL;
|
||||
|
||||
unsigned char *mem;
|
||||
size_t length = 0;
|
||||
FILESYSTEM_loadFileToMemory(fileName, &mem, &length);
|
||||
SDL_RWops *fileIn = SDL_RWFromMem(mem, length);
|
||||
sound = Mix_LoadWAV_RW(fileIn, 1);
|
||||
FILESYSTEM_freeMemory(&mem);
|
||||
|
||||
if (sound == NULL)
|
||||
{
|
||||
fprintf(stderr, "Unable to load WAV file: %s\n", Mix_GetError());
|
||||
}
|
||||
}
|
||||
|
||||
SoundSystem::SoundSystem()
|
||||
{
|
||||
int audio_rate = 44100;
|
||||
Uint16 audio_format = AUDIO_S16SYS;
|
||||
int audio_channels = 2;
|
||||
int audio_buffers = 1024;
|
||||
|
||||
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0)
|
||||
{
|
||||
fprintf(stderr, "Unable to initialize audio: %s\n", Mix_GetError());
|
||||
SDL_assert(0 && "Unable to initialize audio!");
|
||||
}
|
||||
}
|
||||
|
||||
void SoundSystem::playMusic(MusicTrack* music)
|
||||
{
|
||||
if(!music->m_isValid)
|
||||
{
|
||||
fprintf(stderr, "Invalid mix specified: %s\n", Mix_GetError());
|
||||
}
|
||||
if(Mix_PlayMusic(music->m_music, 0) == -1)
|
||||
{
|
||||
fprintf(stderr, "Unable to play Ogg file: %s\n", Mix_GetError());
|
||||
}
|
||||
}
|
||||
29
desktop_version/src/SoundSystem.h
Normal file
29
desktop_version/src/SoundSystem.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef SOUNDSYSTEM_H
|
||||
#define SOUNDSYSTEM_H
|
||||
|
||||
#include <SDL_mixer.h>
|
||||
|
||||
class MusicTrack
|
||||
{
|
||||
public:
|
||||
MusicTrack(const char* fileName);
|
||||
MusicTrack(SDL_RWops *rw);
|
||||
Mix_Music *m_music;
|
||||
bool m_isValid;
|
||||
};
|
||||
|
||||
class SoundTrack
|
||||
{
|
||||
public:
|
||||
SoundTrack(const char* fileName);
|
||||
Mix_Chunk *sound;
|
||||
};
|
||||
|
||||
class SoundSystem
|
||||
{
|
||||
public:
|
||||
SoundSystem();
|
||||
void playMusic(MusicTrack* music);
|
||||
};
|
||||
|
||||
#endif /* SOUNDSYSTEM_H */
|
||||
3220
desktop_version/src/Spacestation2.cpp
Normal file
3220
desktop_version/src/Spacestation2.cpp
Normal file
File diff suppressed because it is too large
Load Diff
17
desktop_version/src/Spacestation2.h
Normal file
17
desktop_version/src/Spacestation2.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef SPACESTATION2_H
|
||||
#define SPACESTATION2_H
|
||||
|
||||
#include "Game.h"
|
||||
#include "Entity.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class spacestation2class
|
||||
{
|
||||
public:
|
||||
std::vector<std::string> loadlevel(int rx, int ry, Game& game, entityclass& obj);
|
||||
std::string roomname;
|
||||
};
|
||||
|
||||
#endif /* SPACESTATION2_H */
|
||||
219
desktop_version/src/SteamNetwork.c
Normal file
219
desktop_version/src/SteamNetwork.c
Normal file
@@ -0,0 +1,219 @@
|
||||
#include "Network.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <SDL.h>
|
||||
|
||||
/* Steamworks interface versions */
|
||||
|
||||
#define VVVVVV_STEAMCLIENT "SteamClient017"
|
||||
#define VVVVVV_STEAMUSERSTATS "STEAMUSERSTATS_INTERFACE_VERSION011"
|
||||
|
||||
/* Shared object file name */
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define NETWORK_LIBRARY "steam_api.dll"
|
||||
#elif defined(__APPLE__)
|
||||
#define NETWORK_LIBRARY "libsteam_api.dylib"
|
||||
#elif defined(__linux__)
|
||||
#define NETWORK_LIBRARY "libsteam_api.so"
|
||||
#else
|
||||
#error NETWORK_LIBRARY: Unrecognized platform!
|
||||
#endif
|
||||
|
||||
/* Function Pointer Types */
|
||||
|
||||
typedef uint8_t (*SteamAPI_InitFunc)();
|
||||
typedef void (*SteamAPI_ShutdownFunc)();
|
||||
typedef void (*SteamAPI_RunCallbacksFunc)();
|
||||
typedef intptr_t (*SteamInternal_CreateInterfaceFunc)(const char*);
|
||||
typedef int32_t (*SteamAPI_GetHSteamUserFunc)();
|
||||
typedef int32_t (*SteamAPI_GetHSteamPipeFunc)();
|
||||
typedef intptr_t (*SteamAPI_ISteamClient_GetISteamUserStatsFunc)(
|
||||
intptr_t,
|
||||
int32_t,
|
||||
int32_t,
|
||||
const char*
|
||||
);
|
||||
typedef uint8_t (*SteamAPI_ISteamUserStats_RequestCurrentStatsFunc)(intptr_t);
|
||||
typedef uint8_t (*SteamAPI_ISteamUserStats_StoreStatsFunc)(intptr_t);
|
||||
typedef uint8_t (*SteamAPI_ISteamUserStats_GetStatFunc)(
|
||||
intptr_t,
|
||||
const char*,
|
||||
int32_t*
|
||||
);
|
||||
typedef uint8_t (*SteamAPI_ISteamUserStats_SetStatFunc)(
|
||||
intptr_t,
|
||||
const char*,
|
||||
int32_t
|
||||
);
|
||||
typedef uint8_t (*SteamAPI_ISteamUserStats_SetAchievementFunc)(
|
||||
intptr_t,
|
||||
const char*
|
||||
);
|
||||
|
||||
/* DLL, Entry Points */
|
||||
|
||||
static void *libHandle = NULL;
|
||||
static intptr_t steamUserStats = (intptr_t) NULL;
|
||||
|
||||
#define DEFINE_FUNC(name) static name##Func name = NULL;
|
||||
DEFINE_FUNC(SteamAPI_Init)
|
||||
DEFINE_FUNC(SteamAPI_Shutdown)
|
||||
DEFINE_FUNC(SteamAPI_RunCallbacks)
|
||||
DEFINE_FUNC(SteamInternal_CreateInterface)
|
||||
DEFINE_FUNC(SteamAPI_GetHSteamUser)
|
||||
DEFINE_FUNC(SteamAPI_GetHSteamPipe)
|
||||
DEFINE_FUNC(SteamAPI_ISteamClient_GetISteamUserStats)
|
||||
DEFINE_FUNC(SteamAPI_ISteamUserStats_RequestCurrentStats)
|
||||
DEFINE_FUNC(SteamAPI_ISteamUserStats_StoreStats)
|
||||
DEFINE_FUNC(SteamAPI_ISteamUserStats_GetStat)
|
||||
DEFINE_FUNC(SteamAPI_ISteamUserStats_SetStat)
|
||||
DEFINE_FUNC(SteamAPI_ISteamUserStats_SetAchievement)
|
||||
#undef DEFINE_FUNC
|
||||
|
||||
/* Clean up after ourselves... */
|
||||
|
||||
static void ClearPointers()
|
||||
{
|
||||
SDL_UnloadObject(libHandle);
|
||||
libHandle = NULL;
|
||||
steamUserStats = (intptr_t) NULL;
|
||||
SteamAPI_Init = NULL;
|
||||
SteamAPI_Shutdown = NULL;
|
||||
SteamAPI_RunCallbacks = NULL;
|
||||
SteamInternal_CreateInterface = NULL;
|
||||
SteamAPI_GetHSteamUser = NULL;
|
||||
SteamAPI_GetHSteamPipe = NULL;
|
||||
SteamAPI_ISteamClient_GetISteamUserStats = NULL;
|
||||
SteamAPI_ISteamUserStats_RequestCurrentStats = NULL;
|
||||
SteamAPI_ISteamUserStats_StoreStats = NULL;
|
||||
SteamAPI_ISteamUserStats_GetStat = NULL;
|
||||
SteamAPI_ISteamUserStats_SetStat = NULL;
|
||||
SteamAPI_ISteamUserStats_SetAchievement = NULL;
|
||||
}
|
||||
|
||||
/* NETWORK API Implementation */
|
||||
|
||||
int NETWORK_init()
|
||||
{
|
||||
intptr_t steamClient;
|
||||
int32_t steamUser, steamPipe;
|
||||
|
||||
libHandle = SDL_LoadObject(NETWORK_LIBRARY);
|
||||
if (!libHandle)
|
||||
{
|
||||
printf("%s not found!\n", NETWORK_LIBRARY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define LOAD_FUNC(name) \
|
||||
name = (name##Func) SDL_LoadFunction(libHandle, #name); \
|
||||
if (!name) \
|
||||
{ \
|
||||
printf("%s symbol %s not found!\n", NETWORK_LIBRARY, #name); \
|
||||
ClearPointers(); \
|
||||
return 0; \
|
||||
}
|
||||
LOAD_FUNC(SteamAPI_Init)
|
||||
LOAD_FUNC(SteamAPI_Shutdown)
|
||||
LOAD_FUNC(SteamAPI_RunCallbacks)
|
||||
LOAD_FUNC(SteamInternal_CreateInterface)
|
||||
LOAD_FUNC(SteamAPI_GetHSteamUser)
|
||||
LOAD_FUNC(SteamAPI_GetHSteamPipe)
|
||||
LOAD_FUNC(SteamAPI_ISteamClient_GetISteamUserStats)
|
||||
LOAD_FUNC(SteamAPI_ISteamUserStats_RequestCurrentStats)
|
||||
LOAD_FUNC(SteamAPI_ISteamUserStats_StoreStats)
|
||||
LOAD_FUNC(SteamAPI_ISteamUserStats_GetStat)
|
||||
LOAD_FUNC(SteamAPI_ISteamUserStats_SetStat)
|
||||
LOAD_FUNC(SteamAPI_ISteamUserStats_SetAchievement)
|
||||
#undef LOAD_FUNC
|
||||
|
||||
if (!SteamAPI_Init())
|
||||
{
|
||||
printf("Steamworks not initialized!\n");
|
||||
ClearPointers();
|
||||
return 0;
|
||||
}
|
||||
steamClient = SteamInternal_CreateInterface(VVVVVV_STEAMCLIENT);
|
||||
steamUser = SteamAPI_GetHSteamUser();
|
||||
steamPipe = SteamAPI_GetHSteamPipe();
|
||||
if (!steamClient || !steamUser || !steamPipe)
|
||||
{
|
||||
SteamAPI_Shutdown();
|
||||
printf(VVVVVV_STEAMCLIENT " not created!\n");
|
||||
ClearPointers();
|
||||
return 0;
|
||||
}
|
||||
steamUserStats = SteamAPI_ISteamClient_GetISteamUserStats(
|
||||
steamClient,
|
||||
steamUser,
|
||||
steamPipe,
|
||||
VVVVVV_STEAMUSERSTATS
|
||||
);
|
||||
if (!steamUserStats)
|
||||
{
|
||||
SteamAPI_Shutdown();
|
||||
printf(VVVVVV_STEAMUSERSTATS " not created!\n");
|
||||
ClearPointers();
|
||||
return 0;
|
||||
}
|
||||
SteamAPI_ISteamUserStats_RequestCurrentStats(steamUserStats);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void NETWORK_shutdown()
|
||||
{
|
||||
if (libHandle)
|
||||
{
|
||||
SteamAPI_Shutdown();
|
||||
ClearPointers();
|
||||
}
|
||||
}
|
||||
|
||||
void NETWORK_update()
|
||||
{
|
||||
if (libHandle)
|
||||
{
|
||||
SteamAPI_RunCallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
void NETWORK_unlockAchievement(const char *name)
|
||||
{
|
||||
if (libHandle)
|
||||
{
|
||||
SteamAPI_ISteamUserStats_SetAchievement(
|
||||
steamUserStats,
|
||||
name
|
||||
);
|
||||
SteamAPI_ISteamUserStats_StoreStats(steamUserStats);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t NETWORK_getAchievementProgress(const char *name)
|
||||
{
|
||||
int32_t result = -1;
|
||||
if (libHandle)
|
||||
{
|
||||
SteamAPI_ISteamUserStats_GetStat(
|
||||
steamUserStats,
|
||||
name,
|
||||
&result
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void NETWORK_setAchievementProgress(const char *name, int32_t stat)
|
||||
{
|
||||
if (libHandle)
|
||||
{
|
||||
SteamAPI_ISteamUserStats_SetStat(
|
||||
steamUserStats,
|
||||
name,
|
||||
stat
|
||||
);
|
||||
SteamAPI_ISteamUserStats_StoreStats(steamUserStats);
|
||||
}
|
||||
}
|
||||
903
desktop_version/src/TerminalScripts.cpp
Normal file
903
desktop_version/src/TerminalScripts.cpp
Normal file
@@ -0,0 +1,903 @@
|
||||
#ifndef TERMINALSCRIPTS_H
|
||||
#define TERMINALSCRIPTS_H
|
||||
|
||||
#include "Script.h"
|
||||
|
||||
void scriptclass::loadother(std::string t)
|
||||
{
|
||||
//loads script name t into the array
|
||||
if (t == "terminal_station_1")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,60,1)");
|
||||
add(" -= PERSONAL LOG =- ");
|
||||
add("position(centerx)");
|
||||
add("backgroundtext");
|
||||
add("flipme");
|
||||
add("speak");
|
||||
|
||||
add("text(gray,0,120,6)");
|
||||
add(" Almost everyone has been ");
|
||||
add(" evacuated from the space ");
|
||||
add(" station now. The rest of us ");
|
||||
add(" are leaving in a couple of ");
|
||||
add(" days, once our research has ");
|
||||
add(" been completed. ");
|
||||
add("position(center)");
|
||||
add("speak");
|
||||
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "alreadyvisited")
|
||||
{
|
||||
add("squeak(player)");
|
||||
add("text(cyan,0,0,1)");
|
||||
add("...oh, I've already found this.");
|
||||
add("position(player,above)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_outside_1")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,60,1)");
|
||||
add(" -= Research Notes =- ");
|
||||
add("position(centerx)");
|
||||
add("backgroundtext");
|
||||
add("flipme");
|
||||
add("speak");
|
||||
|
||||
add("text(gray,0,114,5)");
|
||||
add(" ... our first breakthrough was ");
|
||||
add(" the creation of the inversion ");
|
||||
add(" plane, which creates a ");
|
||||
add(" mirrored dimension beyond a ");
|
||||
add(" given event horizon ... ");
|
||||
add("position(center)");
|
||||
add("speak");
|
||||
|
||||
add("endtextfast");
|
||||
add("delay(10)");
|
||||
|
||||
add("ifexplored(2,16,alreadyvisited)");
|
||||
|
||||
add("gamemode(teleporter)");
|
||||
add("delay(20)");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("showcoordinates(2,16)");
|
||||
add("delay(10)");
|
||||
add("hidecoordinates(2,16)");
|
||||
add("delay(10)");
|
||||
add("showcoordinates(2,16)");
|
||||
add("delay(10)");
|
||||
add("hidecoordinates(2,16)");
|
||||
add("delay(10)");
|
||||
add("showcoordinates(2,16)");
|
||||
add("delay(45)");
|
||||
|
||||
add("gamemode(game)");
|
||||
add("delay(20)");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_outside_2")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,60,1)");
|
||||
add(" -= Research Notes =- ");
|
||||
add("position(centerx)");
|
||||
add("backgroundtext");
|
||||
add("flipme");
|
||||
add("speak");
|
||||
|
||||
add("text(gray,0,114,3)");
|
||||
add("...with just a small modification to");
|
||||
add("the usual parameters, we were able ");
|
||||
add("to stabilise an infinite tunnel! ");
|
||||
add("position(center)");
|
||||
add("speak");
|
||||
|
||||
add("endtextfast");
|
||||
add("delay(10)");
|
||||
|
||||
add("ifexplored(8,9,alreadyvisited)");
|
||||
|
||||
add("gamemode(teleporter)");
|
||||
add("delay(20)");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("showcoordinates(8,9)");
|
||||
add("delay(10)");
|
||||
add("hidecoordinates(8,9)");
|
||||
add("delay(10)");
|
||||
add("showcoordinates(8,9)");
|
||||
add("delay(10)");
|
||||
add("hidecoordinates(8,9)");
|
||||
add("delay(10)");
|
||||
add("showcoordinates(8,9)");
|
||||
add("delay(45)");
|
||||
|
||||
add("gamemode(game)");
|
||||
add("delay(20)");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_outside_3")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,60,1)");
|
||||
add(" -= Research Notes =- ");
|
||||
add("position(centerx)");
|
||||
add("backgroundtext");
|
||||
add("flipme");
|
||||
add("speak");
|
||||
|
||||
add("text(gray,0,114,3)");
|
||||
add(" ... the final step in creating ");
|
||||
add(" the dimensional stabiliser was ");
|
||||
add(" to create a feedback loop ... ");
|
||||
add("position(center)");
|
||||
add("speak");
|
||||
|
||||
add("endtextfast");
|
||||
add("delay(10)");
|
||||
|
||||
add("ifexplored(14,1,alreadyvisited)");
|
||||
|
||||
add("gamemode(teleporter)");
|
||||
add("delay(20)");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("showcoordinates(14,1)");
|
||||
add("delay(10)");
|
||||
add("hidecoordinates(14,1)");
|
||||
add("delay(10)");
|
||||
add("showcoordinates(14,1)");
|
||||
add("delay(10)");
|
||||
add("hidecoordinates(14,1)");
|
||||
add("delay(10)");
|
||||
add("showcoordinates(14,1)");
|
||||
add("delay(45)");
|
||||
|
||||
add("gamemode(game)");
|
||||
add("delay(20)");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_outside_4")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,60,1)");
|
||||
add(" -= Research Notes =- ");
|
||||
add("position(centerx)");
|
||||
add("backgroundtext");
|
||||
add("flipme");
|
||||
add("speak");
|
||||
|
||||
add("text(gray,0,114,4)");
|
||||
add(" ...despite our best efforts, ");
|
||||
add(" the dimensional stabiliser ");
|
||||
add(" won't hold out forever. Its ");
|
||||
add(" collapse is inevitable... ");
|
||||
add("position(center)");
|
||||
add("speak");
|
||||
|
||||
add("endtextfast");
|
||||
add("delay(10)");
|
||||
|
||||
add("squeak(player)");
|
||||
add("text(cyan,0,0,2)");
|
||||
add("Huh? These coordinates aren't");
|
||||
add("even in this dimension!");
|
||||
add("position(player,above)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_outside_5")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,60,1)");
|
||||
add(" -= Personal Log =- ");
|
||||
add("position(centerx)");
|
||||
add("backgroundtext");
|
||||
add("flipme");
|
||||
add("speak");
|
||||
|
||||
add("text(gray,0,114,5)");
|
||||
add(" ... I've had to seal off ");
|
||||
add(" access to most of our ");
|
||||
add(" research. Who knows what ");
|
||||
add(" could happen if it fell ");
|
||||
add(" into the wrong hands? ... ");
|
||||
add("position(center)");
|
||||
add("speak");
|
||||
|
||||
add("endtextfast");
|
||||
add("delay(10)");
|
||||
|
||||
add("gamemode(teleporter)");
|
||||
add("delay(20)");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("showsecretlab()");
|
||||
add("delay(10)");
|
||||
add("hidesecretlab()");
|
||||
add("delay(10)");
|
||||
add("showsecretlab()");
|
||||
add("delay(10)");
|
||||
add("hidesecretlab()");
|
||||
add("delay(10)");
|
||||
add("showsecretlab()");
|
||||
add("delay(45)");
|
||||
|
||||
add("gamemode(game)");
|
||||
add("delay(20)");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_outside_6")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,60,1)");
|
||||
add(" -= Research Notes =- ");
|
||||
add("position(centerx)");
|
||||
add("backgroundtext");
|
||||
add("flipme");
|
||||
add("speak");
|
||||
|
||||
add("text(gray,0,114,3)");
|
||||
add("... access to the control center");
|
||||
add("is still possible through the ");
|
||||
add("main atmospheric filters ... ");
|
||||
add("position(center)");
|
||||
add("speak");
|
||||
|
||||
add("endtextfast");
|
||||
add("delay(10)");
|
||||
|
||||
add("ifexplored(12,14,alreadyvisited)");
|
||||
|
||||
add("gamemode(teleporter)");
|
||||
add("delay(20)");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("showcoordinates(12,14)");
|
||||
add("delay(10)");
|
||||
add("hidecoordinates(12,14)");
|
||||
add("delay(10)");
|
||||
add("showcoordinates(12,14)");
|
||||
add("delay(10)");
|
||||
add("hidecoordinates(12,14)");
|
||||
add("delay(10)");
|
||||
add("showcoordinates(12,14)");
|
||||
add("delay(45)");
|
||||
|
||||
add("gamemode(game)");
|
||||
add("delay(20)");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_finallevel")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,9)");
|
||||
add("* DIMENSIONAL STABILITY GENERATOR *");
|
||||
add("");
|
||||
add(" [ Currently Generating ] ");
|
||||
add(" Maximum Stability ");
|
||||
add("");
|
||||
add(" [ Status ]");
|
||||
add(" Online");
|
||||
add("");
|
||||
add("READY _");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("endtextfast");
|
||||
add("delay(10)");
|
||||
|
||||
add("squeak(player)");
|
||||
add("text(cyan,0,0,2)");
|
||||
add("Aha! This must be what's" );
|
||||
add("causing the interference!");
|
||||
add("position(player,above)");
|
||||
add("speak_active");
|
||||
|
||||
add("squeak(player)");
|
||||
add("text(cyan,0,0,1)");
|
||||
add("I wonder if I can turn it off?");
|
||||
add("position(player,above)");
|
||||
add("speak_active");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add("WARNING: Disabling the Dimensional");
|
||||
add("Stability Generator may lead to");
|
||||
add("instability! Are you sure you want");
|
||||
add("to do this?");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("squeak(player)");
|
||||
add("text(cyan,0,0,1)");
|
||||
add("Yes!");
|
||||
add("position(player,above)");
|
||||
add("speak_active");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,6)");
|
||||
add("Seriously! The whole dimension");
|
||||
add("could collapse! Just think about");
|
||||
add("this for a minute!");
|
||||
add("");
|
||||
add("Are you really sure you want");
|
||||
add("to do this?");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("squeak(player)");
|
||||
add("text(cyan,0,0,1)");
|
||||
add("Yes!");
|
||||
add("position(player,above)");
|
||||
add("speak_active");
|
||||
|
||||
add("endtext");
|
||||
|
||||
add("stopmusic");
|
||||
add("gamestate(200)");
|
||||
}
|
||||
else if (t == "finalterminal_finish")
|
||||
{
|
||||
|
||||
|
||||
//add("delay(15)"); add("flash(5)"); add("shake(20)"); add("playef(9,10)");
|
||||
|
||||
add("text(gray,0,114,3)");
|
||||
add(" -= WARNING =- ");
|
||||
add("");
|
||||
add(" DIMENSIONAL STABILISER OFFLINE ");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("squeak(cry)");
|
||||
add("changemood(player,1)");
|
||||
add("text(cyan,0,0,1)");
|
||||
add("Uh oh...");
|
||||
add("position(player,above)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("play(2)");
|
||||
add("changemood(player,0)");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_station_2")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,60,1)");
|
||||
add(" -= Research Notes =- ");
|
||||
add("position(centerx)");
|
||||
add("backgroundtext");
|
||||
add("flipme");
|
||||
add("speak");
|
||||
|
||||
add("text(gray,0,114,3)");
|
||||
add(" ...everything collapses, ");
|
||||
add(" eventually. It's the way ");
|
||||
add(" of the universe. ");
|
||||
add("position(center)");
|
||||
add("speak");
|
||||
|
||||
add("endtextfast");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_station_3")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,3)");
|
||||
add("I wonder if the generator we set");
|
||||
add("up in the polar dimension is");
|
||||
add("what's affecting our teleporters?");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,1)");
|
||||
add("No, it's probably just a glitch.");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_station_4")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,60,1)");
|
||||
add(" -= PERSONAL LOG =- ");
|
||||
add("position(centerx)");
|
||||
add("backgroundtext");
|
||||
add("flipme");
|
||||
add("speak");
|
||||
|
||||
add("text(gray,0,114,2)");
|
||||
add(" Hah! Nobody will ever ");
|
||||
add(" get this one. ");
|
||||
add("position(center)");
|
||||
add("speak");
|
||||
|
||||
add("endtextfast");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_warp_1")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,3)");
|
||||
add("...The other day I was chased");
|
||||
add("down a hallway by a giant cube");
|
||||
add("with the word AVOID on it.");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,1)");
|
||||
add("These security measures go too far!");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_warp_2")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,2)");
|
||||
add("The only way into my private lab");
|
||||
add("anymore is by teleporter.");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,3)");
|
||||
add("I've made sure that it's");
|
||||
add("difficult for unauthorised");
|
||||
add("personnel to gain access.");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_lab_1")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add("... it turns out the key to");
|
||||
add("stabilising this dimension was");
|
||||
add("to create a balancing force");
|
||||
add("outside of it!");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,2)");
|
||||
add("Though it looks like that's just");
|
||||
add("a temporary solution, at best.");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add("I've been working on");
|
||||
add("something more permanent,");
|
||||
add("but it seems it's going");
|
||||
add("to be too late...");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_lab_2")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,1)");
|
||||
add("?SYNTAX ERROR");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_secretlab")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add(" -= WARNING =-");
|
||||
add("");
|
||||
add(" The Super-Gravitron is intended ");
|
||||
add(" for entertainment purposes only. ");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add("Anyone found using the Super");
|
||||
add("Gravitron for educational");
|
||||
add("purposes may be asked to");
|
||||
add("stand in the naughty corner.");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_shipcomputer")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,3)");
|
||||
add(" -= D.S.S. SOULEYE =- ");
|
||||
add("");
|
||||
add(" Ship Navigation Controls ");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("ifflag(67,terminal_letsgo)");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,3)");
|
||||
add("Error! Error! Cannot isolate");
|
||||
add("dimensional coordinates!");
|
||||
add("Interference detected!");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_letsgo")
|
||||
{
|
||||
add("squeak(player)");
|
||||
add("text(player,0,0,2)");
|
||||
add("Now that the ship is fixed,");
|
||||
add("we can leave anytime we want!");
|
||||
add("position(player,above)");
|
||||
add("speak_active");
|
||||
|
||||
add("squeak(player)");
|
||||
add("text(player,0,0,3)");
|
||||
add("We've all agreed to");
|
||||
add("keep exploring this");
|
||||
add("dimension, though.");
|
||||
add("position(player,above)");
|
||||
add("speak_active");
|
||||
|
||||
add("squeak(player)");
|
||||
add("text(player,0,0,1)");
|
||||
add("Who knows what we'll find?");
|
||||
add("position(player,above)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_radio")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add(" -= SHIP RADIO =- ");
|
||||
add("");
|
||||
add(" [ Status ]");
|
||||
add(" Broadcasting");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_jukebox")
|
||||
{
|
||||
add("cutscene()");
|
||||
add("untilbars()");
|
||||
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,7)");
|
||||
add(" -= JUKEBOX =- ");
|
||||
add("");
|
||||
add(" Songs will continue to play ");
|
||||
add(" until you leave the ship.");
|
||||
add("");
|
||||
add(" Collect trinkets to");
|
||||
add(" unlock new songs!");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
|
||||
add("endtext");
|
||||
|
||||
add("iftrinketsless(5,terminal_jukeunlock1)");
|
||||
add("iftrinketsless(8,terminal_jukeunlock2)");
|
||||
add("iftrinketsless(10,terminal_jukeunlock3)");
|
||||
add("iftrinketsless(12,terminal_jukeunlock4)");
|
||||
add("iftrinketsless(14,terminal_jukeunlock41)");
|
||||
add("iftrinketsless(16,terminal_jukeunlock5)");
|
||||
add("iftrinketsless(18,terminal_jukeunlock6)");
|
||||
add("iftrinketsless(20,terminal_jukeunlock7)");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_jukeunlock1")
|
||||
{
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add(" NEXT UNLOCK: ");
|
||||
add(" 5 Trinkets");
|
||||
add("");
|
||||
add(" Pushing onwards ");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_jukeunlock2")
|
||||
{
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add(" NEXT UNLOCK: ");
|
||||
add(" 8 Trinkets");
|
||||
add("");
|
||||
add(" Positive force ");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_jukeunlock3")
|
||||
{
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add(" NEXT UNLOCK: ");
|
||||
add(" 10 Trinkets");
|
||||
add("");
|
||||
add(" Presenting VVVVVV ");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_jukeunlock4")
|
||||
{
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add(" NEXT UNLOCK: ");
|
||||
add(" 12 Trinkets");
|
||||
add("");
|
||||
add(" Potential for anything ");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_jukeunlock41")
|
||||
{
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add(" NEXT UNLOCK: ");
|
||||
add(" 14 Trinkets");
|
||||
add("");
|
||||
add(" Pressure Cooker ");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_jukeunlock5")
|
||||
{
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add(" NEXT UNLOCK: ");
|
||||
add(" 16 Trinkets");
|
||||
add("");
|
||||
add(" Predestined fate ");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_jukeunlock6")
|
||||
{
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add(" NEXT UNLOCK: ");
|
||||
add(" 18 Trinkets");
|
||||
add("");
|
||||
add(" Popular Potpourri ");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_jukeunlock7")
|
||||
{
|
||||
add("squeak(terminal)");
|
||||
add("text(gray,0,114,4)");
|
||||
add(" NEXT UNLOCK: ");
|
||||
add(" 20 Trinkets");
|
||||
add("");
|
||||
add(" Pipe Dream ");
|
||||
add("position(center)");
|
||||
add("speak_active");
|
||||
add("endtext");
|
||||
|
||||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
else if (t == "terminal_juke1")
|
||||
{
|
||||
add("play(4)");
|
||||
add("squeak(terminal)");
|
||||
add("jukebox(1)");
|
||||
}
|
||||
else if (t == "terminal_juke2")
|
||||
{
|
||||
add("play(1)");
|
||||
add("squeak(terminal)");
|
||||
add("jukebox(2)");
|
||||
}
|
||||
else if (t == "terminal_juke3")
|
||||
{
|
||||
add("play(2)");
|
||||
add("squeak(terminal)");
|
||||
add("jukebox(3)");
|
||||
}
|
||||
else if (t == "terminal_juke4")
|
||||
{
|
||||
add("play(6)");
|
||||
add("squeak(terminal)");
|
||||
add("jukebox(4)");
|
||||
}
|
||||
else if (t == "terminal_juke5")
|
||||
{
|
||||
add("play(3)");
|
||||
add("squeak(terminal)");
|
||||
add("jukebox(5)");
|
||||
}
|
||||
else if (t == "terminal_juke6")
|
||||
{
|
||||
add("play(8)");
|
||||
add("squeak(terminal)");
|
||||
add("jukebox(6)");
|
||||
}
|
||||
else if (t == "terminal_juke7")
|
||||
{
|
||||
add("play(11)");
|
||||
add("squeak(terminal)");
|
||||
add("jukebox(7)");
|
||||
}
|
||||
else if (t == "terminal_juke8")
|
||||
{
|
||||
add("play(10)");
|
||||
add("squeak(terminal)");
|
||||
add("jukebox(8)");
|
||||
}
|
||||
else if (t == "terminal_juke9")
|
||||
{
|
||||
add("play(12)");
|
||||
add("squeak(terminal)");
|
||||
add("jukebox(9)");
|
||||
}
|
||||
else if (t == "terminal_juke10")
|
||||
{
|
||||
add("play(9)");
|
||||
add("squeak(terminal)");
|
||||
add("jukebox(10)");
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* TERMINALSCRIPTS_H */
|
||||
154
desktop_version/src/Textbox.cpp
Normal file
154
desktop_version/src/Textbox.cpp
Normal file
@@ -0,0 +1,154 @@
|
||||
#include "Textbox.h"
|
||||
|
||||
textboxclass::textboxclass()
|
||||
{
|
||||
firstcreate();
|
||||
}
|
||||
|
||||
void textboxclass::firstcreate()
|
||||
{
|
||||
//Like clear, only it creates the actual arrays, etc
|
||||
for (int iter = 0; iter < 10; iter++)
|
||||
{
|
||||
std::string t;
|
||||
t = "";
|
||||
line.push_back(t);
|
||||
}
|
||||
x = 0;
|
||||
y = 0;
|
||||
w = 0;
|
||||
h = 0;
|
||||
numlines = 0;
|
||||
lw = 0;
|
||||
tl = 0;
|
||||
tm = 0;
|
||||
active = false;
|
||||
timer = 0;
|
||||
}
|
||||
|
||||
void textboxclass::clear()
|
||||
{
|
||||
//Set all values to a default, required for creating a new entity
|
||||
for (size_t iter = 0; iter < line.size(); iter++)
|
||||
{
|
||||
line[iter]="";
|
||||
}
|
||||
xp = 0;
|
||||
yp = 0;
|
||||
w = 0;
|
||||
h = 0;
|
||||
numlines = 1;
|
||||
lw = 0;
|
||||
tl = 0;
|
||||
tm = 0;
|
||||
active = true;
|
||||
timer = 0;
|
||||
}
|
||||
|
||||
void textboxclass::centerx()
|
||||
{
|
||||
resize();
|
||||
xp = 160 - (w / 2);
|
||||
resize();
|
||||
}
|
||||
void textboxclass::centery()
|
||||
{
|
||||
resize();
|
||||
yp = 120 - (h / 2);
|
||||
resize();
|
||||
}
|
||||
|
||||
void textboxclass::adjust()
|
||||
{
|
||||
resize();
|
||||
if (xp < 10) xp = 10;
|
||||
if (yp < 10) yp = 10;
|
||||
if (xp + w > 310) xp = 310 - w;
|
||||
if (yp + h > 230) yp = 230 - h;
|
||||
resize();
|
||||
}
|
||||
|
||||
void textboxclass::initcol(int rr, int gg, int bb)
|
||||
{
|
||||
tr = rr;
|
||||
tg = gg;
|
||||
tb = bb;
|
||||
r = 0;
|
||||
g = 0;
|
||||
b = 0;
|
||||
tl = 0.5;
|
||||
}
|
||||
|
||||
void textboxclass::setcol(int rr, int gg, int bb)
|
||||
{
|
||||
r = rr;
|
||||
g = gg;
|
||||
b = bb;
|
||||
}
|
||||
|
||||
void textboxclass::update()
|
||||
{
|
||||
if (tm == 0)
|
||||
{
|
||||
tl += .1f;
|
||||
if (tl >= 1)
|
||||
{
|
||||
tl = 1;
|
||||
tm = 1;
|
||||
}
|
||||
setcol(int(tr * tl), int(tg * tl), int(tb * tl));
|
||||
}
|
||||
else if (tm == 2)
|
||||
{
|
||||
tl -= .1f;
|
||||
if (tl <= 0.5)
|
||||
{
|
||||
tl = 0.5;
|
||||
active = false;
|
||||
}
|
||||
setcol(int(tr * tl), int(tg * tl), int(tb * tl));
|
||||
}
|
||||
if (timer > 0)
|
||||
{
|
||||
timer--;
|
||||
if (timer == 0) tm = 2;
|
||||
}
|
||||
}
|
||||
|
||||
void textboxclass::remove()
|
||||
{
|
||||
tm = 2;
|
||||
tl = 1.0f; //Remove mode
|
||||
}
|
||||
|
||||
void textboxclass::removefast()
|
||||
{
|
||||
tm = 2;
|
||||
tl = 0.4f; //Remove mode
|
||||
}
|
||||
|
||||
void textboxclass::resize()
|
||||
{
|
||||
//Set the width and height to the correct sizes
|
||||
max = 0;
|
||||
for (int iter = 0; iter < numlines; iter++)
|
||||
{
|
||||
if (line[iter].length() > (unsigned int)max) max = line[iter].length();
|
||||
}
|
||||
|
||||
lw = max;
|
||||
w = (max +2) * 8;
|
||||
h = (numlines + 2) * 8;
|
||||
textrect.x = xp;
|
||||
textrect.y = yp;
|
||||
textrect.w = w;
|
||||
textrect.h = h;
|
||||
}
|
||||
|
||||
void textboxclass::addline(std::string t)
|
||||
{
|
||||
line[numlines] = t;
|
||||
numlines++;
|
||||
resize();
|
||||
if (numlines >= 12) numlines = 0;
|
||||
}
|
||||
54
desktop_version/src/Textbox.h
Normal file
54
desktop_version/src/Textbox.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef TEXTBOX_H
|
||||
#define TEXTBOX_H
|
||||
|
||||
#include "SDL.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class textboxclass
|
||||
{
|
||||
public:
|
||||
textboxclass();
|
||||
|
||||
void firstcreate();
|
||||
|
||||
void clear();
|
||||
|
||||
void centerx();
|
||||
|
||||
void centery();
|
||||
|
||||
void adjust();
|
||||
|
||||
void initcol(int rr, int gg, int bb);
|
||||
|
||||
void setcol(int rr, int gg, int bb);
|
||||
|
||||
void update();
|
||||
|
||||
void remove();
|
||||
|
||||
void removefast();
|
||||
|
||||
void resize();
|
||||
|
||||
void addline(std::string t);
|
||||
public:
|
||||
//Fundamentals
|
||||
std::vector<std::string> line;
|
||||
int xp, yp, lw, w, h, numlines;
|
||||
int x,y;
|
||||
int r,g,b;
|
||||
int tr,tg,tb;
|
||||
SDL_Rect textrect;
|
||||
bool active;
|
||||
int timer;
|
||||
|
||||
float tl;
|
||||
int tm;
|
||||
|
||||
int max;
|
||||
|
||||
};
|
||||
|
||||
#endif /* TEXTBOX_H */
|
||||
1192
desktop_version/src/Tower.cpp
Normal file
1192
desktop_version/src/Tower.cpp
Normal file
File diff suppressed because it is too large
Load Diff
51
desktop_version/src/Tower.h
Normal file
51
desktop_version/src/Tower.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef TOWER_H
|
||||
#define TOWER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class towerclass
|
||||
{
|
||||
public:
|
||||
towerclass();
|
||||
|
||||
int backat(int xp, int yp, int yoff);
|
||||
|
||||
int at(int xp, int yp, int yoff);
|
||||
|
||||
int miniat(int xp, int yp, int yoff);
|
||||
|
||||
void fillbackground(std::vector<std::string>& tmap);
|
||||
|
||||
void fillminitower(std::vector<std::string>& tmap);
|
||||
|
||||
void loadminitower1();
|
||||
|
||||
void loadminitower2();
|
||||
|
||||
void loadbackground();
|
||||
|
||||
void fillcontents(std::vector<std::string>& tmap);
|
||||
|
||||
void loadmap();
|
||||
|
||||
//public var back:Array = new Array();
|
||||
//public var contents:Array = new Array();
|
||||
//public var minitower:Array = new Array();
|
||||
//public var vmult:Array = new Array();
|
||||
|
||||
std::vector<int> back;
|
||||
std::vector<int> contents;
|
||||
std::vector<int> minitower;
|
||||
std::vector<int> vmult;
|
||||
|
||||
bool minitowermode;
|
||||
int i;
|
||||
int k;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* TOWER_H */
|
||||
360
desktop_version/src/UtilityClass.cpp
Normal file
360
desktop_version/src/UtilityClass.cpp
Normal file
@@ -0,0 +1,360 @@
|
||||
#include "UtilityClass.h"
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
/* Used by UtilityClass::GCString to generate a button list */
|
||||
const char *GCChar(SDL_GameControllerButton button)
|
||||
{
|
||||
if (button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
return "A";
|
||||
}
|
||||
else if (button == SDL_CONTROLLER_BUTTON_B)
|
||||
{
|
||||
return "B";
|
||||
}
|
||||
else if (button == SDL_CONTROLLER_BUTTON_X)
|
||||
{
|
||||
return "X";
|
||||
}
|
||||
else if (button == SDL_CONTROLLER_BUTTON_Y)
|
||||
{
|
||||
return "Y";
|
||||
}
|
||||
else if (button == SDL_CONTROLLER_BUTTON_BACK)
|
||||
{
|
||||
return "BACK";
|
||||
}
|
||||
else if (button == SDL_CONTROLLER_BUTTON_GUIDE)
|
||||
{
|
||||
return "GUIDE";
|
||||
}
|
||||
else if (button == SDL_CONTROLLER_BUTTON_START)
|
||||
{
|
||||
return "START";
|
||||
}
|
||||
else if (button == SDL_CONTROLLER_BUTTON_LEFTSTICK)
|
||||
{
|
||||
return "L3";
|
||||
}
|
||||
else if (button == SDL_CONTROLLER_BUTTON_RIGHTSTICK)
|
||||
{
|
||||
return "R3";
|
||||
}
|
||||
else if (button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER)
|
||||
{
|
||||
return "LB";
|
||||
}
|
||||
else if (button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)
|
||||
{
|
||||
return "RB";
|
||||
}
|
||||
SDL_assert(0 && "Unhandled button!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ss_toi( std::string _s )
|
||||
{
|
||||
std::istringstream i(_s);
|
||||
int x;
|
||||
i >> x;
|
||||
return x;
|
||||
}
|
||||
|
||||
std::vector<std::string> split( const std::string &s, char delim, std::vector<std::string> &elems )
|
||||
{
|
||||
std::stringstream ss(s);
|
||||
std::string item;
|
||||
while(std::getline(ss, item, delim))
|
||||
{
|
||||
elems.push_back(item);
|
||||
}
|
||||
return elems;
|
||||
}
|
||||
|
||||
std::vector<std::string> split( const std::string &s, char delim )
|
||||
{
|
||||
std::vector<std::string> elems;
|
||||
return split(s, delim, elems);
|
||||
}
|
||||
|
||||
UtilityClass::UtilityClass() :
|
||||
glow(0),
|
||||
glowdir(0)
|
||||
{
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
splitseconds.push_back(int((i * 100) / 30));
|
||||
}
|
||||
|
||||
slowsine = 0;
|
||||
}
|
||||
|
||||
std::string UtilityClass::String( int _v )
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << _v;
|
||||
return(os.str());
|
||||
}
|
||||
|
||||
std::string UtilityClass::GCString(std::vector<SDL_GameControllerButton> buttons)
|
||||
{
|
||||
std::string retval = "";
|
||||
for (size_t i = 0; i < buttons.size(); i += 1)
|
||||
{
|
||||
retval += GCChar(buttons[i]);
|
||||
if ((i + 1) < buttons.size())
|
||||
{
|
||||
retval += ",";
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
std::string UtilityClass::twodigits( int t )
|
||||
{
|
||||
if (t < 10)
|
||||
{
|
||||
return "0" + String(t);
|
||||
}
|
||||
if (t >= 100)
|
||||
{
|
||||
return "??";
|
||||
}
|
||||
return String(t);
|
||||
}
|
||||
|
||||
std::string UtilityClass::timestring( int t )
|
||||
{
|
||||
//given a time t in frames, return a time in seconds
|
||||
tempstring = "";
|
||||
temp = (t - (t % 30)) / 30;
|
||||
if (temp < 60) //less than one minute
|
||||
{
|
||||
t = t % 30;
|
||||
tempstring = String(temp) + ":" + twodigits(splitseconds[t]);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp2 = (temp - (temp % 60)) / 60;
|
||||
temp = temp % 60;
|
||||
t = t % 30;
|
||||
tempstring = String(temp2) + ":" + twodigits(temp) + ":" + twodigits(splitseconds[t]);
|
||||
}
|
||||
return tempstring;
|
||||
}
|
||||
|
||||
std::string UtilityClass::number( int _t )
|
||||
{
|
||||
switch(_t)
|
||||
{
|
||||
case 0:
|
||||
return "Zero";
|
||||
break;
|
||||
case 1:
|
||||
return "One";
|
||||
break;
|
||||
case 2:
|
||||
return "Two";
|
||||
break;
|
||||
case 3:
|
||||
return "Three";
|
||||
break;
|
||||
case 4:
|
||||
return "Four";
|
||||
break;
|
||||
case 5:
|
||||
return "Five";
|
||||
break;
|
||||
case 6:
|
||||
return "Six";
|
||||
break;
|
||||
case 7:
|
||||
return "Seven";
|
||||
break;
|
||||
case 8:
|
||||
return "Eight";
|
||||
break;
|
||||
case 9:
|
||||
return "Nine";
|
||||
break;
|
||||
case 10:
|
||||
return "Ten";
|
||||
break;
|
||||
case 11:
|
||||
return "Eleven";
|
||||
break;
|
||||
case 12:
|
||||
return "Twelve";
|
||||
break;
|
||||
case 13:
|
||||
return "Thirteen";
|
||||
break;
|
||||
case 14:
|
||||
return "Fourteen";
|
||||
break;
|
||||
case 15:
|
||||
return "Fifteen";
|
||||
break;
|
||||
case 16:
|
||||
return "Sixteen";
|
||||
break;
|
||||
case 17:
|
||||
return "Seventeen";
|
||||
break;
|
||||
case 18:
|
||||
return "Eighteen";
|
||||
break;
|
||||
case 19:
|
||||
return "Nineteen";
|
||||
break;
|
||||
case 20:
|
||||
return "Twenty";
|
||||
break;
|
||||
case 21:
|
||||
return "Twenty One";
|
||||
break;
|
||||
case 22:
|
||||
return "Twenty Two";
|
||||
break;
|
||||
case 23:
|
||||
return "Twenty Three";
|
||||
break;
|
||||
case 24:
|
||||
return "Twenty Four";
|
||||
break;
|
||||
case 25:
|
||||
return "Twenty Five";
|
||||
break;
|
||||
case 26:
|
||||
return "Twenty Six";
|
||||
break;
|
||||
case 27:
|
||||
return "Twenty Seven";
|
||||
break;
|
||||
case 28:
|
||||
return "Twenty Eight";
|
||||
break;
|
||||
case 29:
|
||||
return "Twenty Nine";
|
||||
break;
|
||||
case 30:
|
||||
return "Thirty";
|
||||
break;
|
||||
case 31:
|
||||
return "Thirty One";
|
||||
break;
|
||||
case 32:
|
||||
return "Thirty Two";
|
||||
break;
|
||||
case 33:
|
||||
return "Thirty Three";
|
||||
break;
|
||||
case 34:
|
||||
return "Thirty Four";
|
||||
break;
|
||||
case 35:
|
||||
return "Thirty Five";
|
||||
break;
|
||||
case 36:
|
||||
return "Thirty Six";
|
||||
break;
|
||||
case 37:
|
||||
return "Thirty Seven";
|
||||
break;
|
||||
case 38:
|
||||
return "Thirty Eight";
|
||||
break;
|
||||
case 39:
|
||||
return "Thirty Nine";
|
||||
break;
|
||||
case 40:
|
||||
return "Forty";
|
||||
break;
|
||||
case 41:
|
||||
return "Forty One";
|
||||
break;
|
||||
case 42:
|
||||
return "Forty Two";
|
||||
break;
|
||||
case 43:
|
||||
return "Forty Three";
|
||||
break;
|
||||
case 44:
|
||||
return "Forty Four";
|
||||
break;
|
||||
case 45:
|
||||
return "Forty Five";
|
||||
break;
|
||||
case 46:
|
||||
return "Forty Six";
|
||||
break;
|
||||
case 47:
|
||||
return "Forty Seven";
|
||||
break;
|
||||
case 48:
|
||||
return "Forty Eight";
|
||||
break;
|
||||
case 49:
|
||||
return "Forty Nine";
|
||||
break;
|
||||
case 50:
|
||||
return "Fifty";
|
||||
break;
|
||||
}
|
||||
return "Lots";
|
||||
}
|
||||
|
||||
bool UtilityClass::intersects( SDL_Rect A, SDL_Rect B )
|
||||
{
|
||||
int leftA, leftB;
|
||||
int rightA, rightB;
|
||||
int topA, topB;
|
||||
int bottomA, bottomB;
|
||||
//Calculate the sides of rect A
|
||||
leftA = A.x;
|
||||
rightA = A.x + A.w;
|
||||
topA = A.y;
|
||||
bottomA = A.y + A.h;
|
||||
//Calculate the sides of rect B
|
||||
leftB = B.x;
|
||||
rightB = B.x + B.w;
|
||||
topB = B.y;
|
||||
bottomB = B.y + B.h;
|
||||
|
||||
if( bottomA <= topB )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( topA >= bottomB )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( rightA <= leftB )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( leftA >= rightB )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//If none of the sides from A are outside B return true; }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void UtilityClass::updateglow()
|
||||
{
|
||||
slowsine++;
|
||||
if (slowsine >= 64) slowsine = 0;
|
||||
|
||||
if (glowdir == 0) {
|
||||
glow+=2;
|
||||
if (glow >= 62) glowdir = 1;
|
||||
}else {
|
||||
glow-=2;
|
||||
if (glow < 2) glowdir = 0;
|
||||
}
|
||||
}
|
||||
46
desktop_version/src/UtilityClass.h
Normal file
46
desktop_version/src/UtilityClass.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef UTILITYCLASS_H
|
||||
#define UTILITYCLASS_H
|
||||
|
||||
#include <SDL.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
int ss_toi(std::string _s);
|
||||
|
||||
std::vector<std::string> split(const std::string &s, char delim, std::vector<std::string> &elems);
|
||||
|
||||
std::vector<std::string> split(const std::string &s, char delim);
|
||||
|
||||
|
||||
//helperClass
|
||||
class UtilityClass
|
||||
{
|
||||
public:
|
||||
UtilityClass();
|
||||
|
||||
static std::string String(int _v);
|
||||
|
||||
static std::string GCString(std::vector<SDL_GameControllerButton> buttons);
|
||||
|
||||
std::string twodigits(int t);
|
||||
|
||||
std::string timestring(int t);
|
||||
|
||||
std::string number(int _t);
|
||||
|
||||
|
||||
static bool intersects( SDL_Rect A, SDL_Rect B );
|
||||
|
||||
void updateglow();
|
||||
|
||||
int glow;
|
||||
int slowsine;
|
||||
int glowdir;
|
||||
int globaltemp;
|
||||
int temp;
|
||||
int temp2;
|
||||
std::string tempstring;
|
||||
std::vector<int> splitseconds;
|
||||
};
|
||||
|
||||
#endif /* UTILITYCLASS_H */
|
||||
1033
desktop_version/src/WarpClass.cpp
Normal file
1033
desktop_version/src/WarpClass.cpp
Normal file
File diff suppressed because it is too large
Load Diff
19
desktop_version/src/WarpClass.h
Normal file
19
desktop_version/src/WarpClass.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef WARPCLASS_H
|
||||
#define WARPCLASS_H
|
||||
|
||||
#include "Game.h"
|
||||
#include "Entity.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class warpclass
|
||||
{
|
||||
public:
|
||||
std::vector<std::string> loadlevel(int rx, int ry , Game& game, entityclass& obj);
|
||||
std::string roomname;
|
||||
int coin, rcol;
|
||||
bool warpx, warpy;
|
||||
};
|
||||
|
||||
#endif /* WARPCLASS_H */
|
||||
5353
desktop_version/src/editor.cpp
Normal file
5353
desktop_version/src/editor.cpp
Normal file
File diff suppressed because it is too large
Load Diff
262
desktop_version/src/editor.h
Normal file
262
desktop_version/src/editor.h
Normal file
@@ -0,0 +1,262 @@
|
||||
#ifndef EDITOR_H
|
||||
#define EDITOR_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "Script.h"
|
||||
|
||||
class KeyPoll; class Graphics; class Game; class mapclass; class entityclass; class UtilityClass;
|
||||
|
||||
|
||||
class edentities{
|
||||
public:
|
||||
int x, y, t;
|
||||
//parameters
|
||||
int p1, p2, p3, p4, p5, p6;
|
||||
std::string scriptname;
|
||||
};
|
||||
|
||||
|
||||
class edlevelclass{
|
||||
public:
|
||||
edlevelclass();
|
||||
int tileset, tilecol;
|
||||
std::string roomname;
|
||||
int warpdir;
|
||||
int platx1, platy1, platx2, platy2, platv;
|
||||
int enemyx1, enemyy1, enemyx2, enemyy2, enemytype;
|
||||
int directmode;
|
||||
};
|
||||
|
||||
struct LevelMetaData
|
||||
{
|
||||
std::string title;
|
||||
std::string creator;
|
||||
std::string Desc1;
|
||||
std::string Desc2;
|
||||
std::string Desc3;
|
||||
std::string website;
|
||||
std::string filename;
|
||||
|
||||
std::string modifier;
|
||||
std::string timeCreated;
|
||||
std::string timeModified;
|
||||
|
||||
int version;
|
||||
};
|
||||
|
||||
|
||||
extern edentities edentity[3000];
|
||||
extern scriptclass script;
|
||||
|
||||
class EditorData
|
||||
{
|
||||
public:
|
||||
|
||||
static EditorData& GetInstance()
|
||||
{
|
||||
static EditorData instance; // Guaranteed to be destroyed.
|
||||
// Instantiated on first use.
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
int numedentities;
|
||||
std::string title;
|
||||
std::string creator;
|
||||
|
||||
std::string modifier;
|
||||
std::string timeCreated;
|
||||
std::string timeModified;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
EditorData():
|
||||
numedentities(0)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class editorclass{
|
||||
//Special class to handle ALL editor variables locally
|
||||
public:
|
||||
editorclass();
|
||||
|
||||
std::string Desc1;
|
||||
std::string Desc2;
|
||||
std::string Desc3;
|
||||
std::string website;
|
||||
|
||||
std::vector<std::string> directoryList;
|
||||
std::vector<LevelMetaData> ListOfMetaData;
|
||||
|
||||
void getDirectoryData();
|
||||
bool getLevelMetaData(std::string& filename, LevelMetaData& _data );
|
||||
|
||||
void saveconvertor();
|
||||
void reset();
|
||||
void loadlevel(int rxi, int ryi);
|
||||
|
||||
void placetile(int x, int y, int t);
|
||||
|
||||
void placetilelocal(int x, int y, int t);
|
||||
|
||||
int getenemyframe(int t);
|
||||
int base(int x, int y);
|
||||
|
||||
int backbase(int x, int y);
|
||||
|
||||
int at(int x, int y);
|
||||
|
||||
int freewrap(int x, int y);
|
||||
|
||||
int backonlyfree(int x, int y);
|
||||
|
||||
int backfree(int x, int y);
|
||||
|
||||
int spikefree(int x, int y);
|
||||
int free(int x, int y);
|
||||
int absfree(int x, int y);
|
||||
|
||||
int match(int x, int y);
|
||||
int warpzonematch(int x, int y);
|
||||
int outsidematch(int x, int y);
|
||||
|
||||
int backmatch(int x, int y);
|
||||
|
||||
void load(std::string& _path);
|
||||
void save(std::string& _path);
|
||||
void generatecustomminimap(Graphics& dwgfx, mapclass& map);
|
||||
int edgetile(int x, int y);
|
||||
int warpzoneedgetile(int x, int y);
|
||||
int outsideedgetile(int x, int y);
|
||||
|
||||
int backedgetile(int x, int y);
|
||||
|
||||
int labspikedir(int x, int y, int t);
|
||||
int spikedir(int x, int y);
|
||||
int findtrinket(int t);
|
||||
int findcrewmate(int t);
|
||||
int findwarptoken(int t);
|
||||
void countstuff();
|
||||
void findstartpoint(Game& game);
|
||||
void weirdloadthing(std::string t);
|
||||
int getlevelcol(int t);
|
||||
int getenemycol(int t);
|
||||
int entcol;
|
||||
|
||||
//Colouring stuff
|
||||
int getwarpbackground(int rx, int ry);
|
||||
|
||||
std::vector<std::string> getLevelDirFileNames( );
|
||||
std::vector <int> swapmap;
|
||||
std::vector <int> contents;
|
||||
std::vector <int> vmult;
|
||||
int numtrinkets;
|
||||
int numcrewmates;
|
||||
edlevelclass level[400]; //Maxwidth*maxheight
|
||||
|
||||
int temp;
|
||||
int notedelay;
|
||||
std::string note;
|
||||
std::string keybuffer;
|
||||
std::string filename;
|
||||
|
||||
int drawmode;
|
||||
int tilex, tiley;
|
||||
int keydelay, lclickdelay;
|
||||
bool savekey, loadkey;
|
||||
int levx, levy;
|
||||
int entframe, entframedelay;
|
||||
|
||||
bool roomtextmod;
|
||||
int roomtextent;
|
||||
|
||||
bool scripttextmod;
|
||||
int scripttextent;
|
||||
int scripttexttype;
|
||||
|
||||
bool xmod, zmod, spacemod, warpmod, roomnamemod, textentry, savemod, loadmod;
|
||||
bool titlemod, creatormod, desc1mod, desc2mod, desc3mod, websitemod;
|
||||
|
||||
int roomnamehide;
|
||||
bool saveandquit;
|
||||
bool shiftmenu, shiftkey;
|
||||
int spacemenu;
|
||||
bool settingsmod, settingskey;
|
||||
int warpent;
|
||||
bool updatetiles, changeroom;
|
||||
int deletekeyheld;
|
||||
|
||||
int boundarymod, boundarytype;
|
||||
int boundx1, boundx2, boundy1, boundy2;
|
||||
|
||||
int levmusic;
|
||||
int mapwidth, mapheight; //Actual width and height of stage
|
||||
int maxwidth, maxheight; //Special; the physical max the engine allows
|
||||
|
||||
int version;
|
||||
|
||||
//Script editor stuff
|
||||
void removeline(int t);
|
||||
void insertline(int t);
|
||||
|
||||
bool scripteditmod;
|
||||
int scripthelppage, scripthelppagedelay;
|
||||
std::string sb[500];
|
||||
std::string sbscript;
|
||||
int sblength;
|
||||
int sbx, sby;
|
||||
int pagey;
|
||||
|
||||
std::string author;
|
||||
std::string description;
|
||||
std::string title;
|
||||
|
||||
//Functions for interfacing with the script:
|
||||
void addhook(std::string t);
|
||||
void removehook(std::string t);
|
||||
void addhooktoscript(std::string t);
|
||||
void removehookfromscript(std::string t);
|
||||
void loadhookineditor(std::string t);
|
||||
void clearscriptbuffer();
|
||||
void gethooks();
|
||||
bool checkhook(std::string t);
|
||||
std::string hooklist[500];
|
||||
int numhooks;
|
||||
|
||||
int hookmenupage, hookmenu;
|
||||
|
||||
//Direct Mode variables
|
||||
int dmtile;
|
||||
int dmtileeditor;
|
||||
};
|
||||
|
||||
void addedentity(int xp, int yp, int tp, int p1=0, int p2=0, int p3=0, int p4=0, int p5=320, int p6=240);
|
||||
|
||||
void naddedentity(int xp, int yp, int tp, int p1=0, int p2=0, int p3=0, int p4=0, int p5=320, int p6=240);
|
||||
|
||||
void copyedentity(int a, int b);
|
||||
|
||||
void removeedentity(int t);
|
||||
|
||||
int edentat(int xp, int yp);
|
||||
|
||||
|
||||
bool edentclear(int xp, int yp);
|
||||
|
||||
void fillbox(Graphics& dwgfx, int x, int y, int x2, int y2, int c);
|
||||
|
||||
void fillboxabs(Graphics& dwgfx, int x, int y, int x2, int y2, int c);
|
||||
|
||||
void editorrender(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, entityclass& obj, UtilityClass& help);
|
||||
|
||||
void editorlogic(KeyPoll& key, Graphics& dwgfx, Game& game, entityclass& obj, musicclass& music, mapclass& map, UtilityClass& help);
|
||||
|
||||
void editorinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
|
||||
entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
#endif /* EDITOR_H */
|
||||
539
desktop_version/src/main.cpp
Normal file
539
desktop_version/src/main.cpp
Normal file
@@ -0,0 +1,539 @@
|
||||
#include <SDL.h>
|
||||
#include "SoundSystem.h"
|
||||
|
||||
#include "UtilityClass.h"
|
||||
#include "Game.h"
|
||||
#include "Graphics.h"
|
||||
#include "KeyPoll.h"
|
||||
#include "titlerender.h"
|
||||
|
||||
#include "Tower.h"
|
||||
#include "WarpClass.h"
|
||||
#include "Labclass.h"
|
||||
#include "Finalclass.h"
|
||||
#include "Map.h"
|
||||
|
||||
#include "Screen.h"
|
||||
|
||||
#include "Script.h"
|
||||
|
||||
#include "Logic.h"
|
||||
|
||||
#include "Input.h"
|
||||
#include "editor.h"
|
||||
#include "preloader.h"
|
||||
|
||||
#include "FileSystemUtils.h"
|
||||
#include "Network.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
scriptclass script;
|
||||
edentities edentity[3000];
|
||||
|
||||
editorclass ed;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILESYSTEM_init(argv[0]);
|
||||
SDL_Init(
|
||||
SDL_INIT_VIDEO |
|
||||
SDL_INIT_AUDIO |
|
||||
SDL_INIT_JOYSTICK |
|
||||
SDL_INIT_GAMECONTROLLER
|
||||
);
|
||||
|
||||
if (argc > 2 && strcmp(argv[1], "-renderer") == 0)
|
||||
{
|
||||
SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, argv[2], SDL_HINT_OVERRIDE);
|
||||
}
|
||||
|
||||
NETWORK_init();
|
||||
|
||||
Screen gameScreen;
|
||||
|
||||
printf("\t\t\n");
|
||||
printf("\t\t\n");
|
||||
printf("\t\t VVVVVV\n");
|
||||
printf("\t\t\n");
|
||||
printf("\t\t\n");
|
||||
printf("\t\t 8888888888888888 \n");
|
||||
printf("\t\t88888888888888888888\n");
|
||||
printf("\t\t888888 8888 88\n");
|
||||
printf("\t\t888888 8888 88\n");
|
||||
printf("\t\t88888888888888888888\n");
|
||||
printf("\t\t88888888888888888888\n");
|
||||
printf("\t\t888888 88\n");
|
||||
printf("\t\t88888888 8888\n");
|
||||
printf("\t\t 8888888888888888 \n");
|
||||
printf("\t\t 88888888 \n");
|
||||
printf("\t\t 8888888888888888 \n");
|
||||
printf("\t\t88888888888888888888\n");
|
||||
printf("\t\t88888888888888888888\n");
|
||||
printf("\t\t88888888888888888888\n");
|
||||
printf("\t\t8888 88888888 8888\n");
|
||||
printf("\t\t8888 88888888 8888\n");
|
||||
printf("\t\t 888888888888 \n");
|
||||
printf("\t\t 8888 8888 \n");
|
||||
printf("\t\t 888888 888888 \n");
|
||||
printf("\t\t 888888 888888 \n");
|
||||
printf("\t\t 888888 888888 \n");
|
||||
printf("\t\t\n");
|
||||
printf("\t\t\n");
|
||||
|
||||
//Set up screen
|
||||
|
||||
|
||||
|
||||
|
||||
UtilityClass help;
|
||||
// Load Ini
|
||||
|
||||
|
||||
Graphics graphics;
|
||||
|
||||
|
||||
|
||||
musicclass music;
|
||||
Game game;
|
||||
game.infocus = true;
|
||||
|
||||
graphics.MakeTileArray();
|
||||
graphics.MakeSpriteArray();
|
||||
graphics.maketelearray();
|
||||
|
||||
|
||||
graphics.images.push_back(graphics.grphx.im_image0);
|
||||
graphics.images.push_back(graphics.grphx.im_image1);
|
||||
graphics.images.push_back(graphics.grphx.im_image2);
|
||||
graphics.images.push_back(graphics.grphx.im_image3);
|
||||
graphics.images.push_back(graphics.grphx.im_image4);
|
||||
graphics.images.push_back(graphics.grphx.im_image5);
|
||||
graphics.images.push_back(graphics.grphx.im_image6);
|
||||
|
||||
graphics.images.push_back(graphics.grphx.im_image7);
|
||||
graphics.images.push_back(graphics.grphx.im_image8);
|
||||
graphics.images.push_back(graphics.grphx.im_image9);
|
||||
graphics.images.push_back(graphics.grphx.im_image10);
|
||||
graphics.images.push_back(graphics.grphx.im_image11);
|
||||
graphics.images.push_back(graphics.grphx.im_image12);
|
||||
|
||||
const SDL_PixelFormat* fmt = gameScreen.GetFormat();
|
||||
graphics.backBuffer = SDL_CreateRGBSurface(SDL_SWSURFACE ,320 ,240 ,32,fmt->Rmask,fmt->Gmask,fmt->Bmask,fmt->Amask ) ;
|
||||
SDL_SetSurfaceBlendMode(graphics.backBuffer, SDL_BLENDMODE_NONE);
|
||||
graphics.Makebfont();
|
||||
|
||||
|
||||
graphics.forgroundBuffer = SDL_CreateRGBSurface(SDL_SWSURFACE ,320 ,240 ,fmt->BitsPerPixel,fmt->Rmask,fmt->Gmask,fmt->Bmask,fmt->Amask );
|
||||
SDL_SetSurfaceBlendMode(graphics.forgroundBuffer, SDL_BLENDMODE_NONE);
|
||||
|
||||
graphics.screenbuffer = &gameScreen;
|
||||
|
||||
graphics.menubuffer = SDL_CreateRGBSurface(SDL_SWSURFACE ,320 ,240 ,fmt->BitsPerPixel,fmt->Rmask,fmt->Gmask,fmt->Bmask,fmt->Amask );
|
||||
SDL_SetSurfaceBlendMode(graphics.menubuffer, SDL_BLENDMODE_NONE);
|
||||
|
||||
graphics.towerbuffer = SDL_CreateRGBSurface(SDL_SWSURFACE ,320 ,240 ,fmt->BitsPerPixel,fmt->Rmask,fmt->Gmask,fmt->Bmask,fmt->Amask );
|
||||
SDL_SetSurfaceBlendMode(graphics.towerbuffer, SDL_BLENDMODE_NONE);
|
||||
|
||||
graphics.tempBuffer = SDL_CreateRGBSurface(SDL_SWSURFACE ,320 ,240 ,fmt->BitsPerPixel,fmt->Rmask,fmt->Gmask,fmt->Bmask,fmt->Amask );
|
||||
SDL_SetSurfaceBlendMode(graphics.tempBuffer, SDL_BLENDMODE_NONE);
|
||||
|
||||
//Make a temporary rectangle to hold the offsets
|
||||
// SDL_Rect offset;
|
||||
//Give the offsets to the rectangle
|
||||
// offset.x = 60;
|
||||
// offset.y = 80;
|
||||
|
||||
//game.gamestate = TITLEMODE;
|
||||
//game.gamestate=EDITORMODE;
|
||||
game.gamestate = PRELOADER; //Remember to uncomment this later!
|
||||
|
||||
game.menustart = false;
|
||||
game.mainmenu = 0;
|
||||
|
||||
KeyPoll key;
|
||||
mapclass map;
|
||||
|
||||
map.ypos = (700-29) * 8;
|
||||
map.bypos = map.ypos / 2;
|
||||
|
||||
//Moved screensetting init here from main menu V2.1
|
||||
game.loadstats(map, graphics);
|
||||
if(game.usingmmmmmm==0) music.usingmmmmmm=false;
|
||||
if(game.usingmmmmmm==1) music.usingmmmmmm=true;
|
||||
if (game.slowdown == 0) game.slowdown = 30;
|
||||
|
||||
switch(game.slowdown){
|
||||
case 30: game.gameframerate=34; break;
|
||||
case 24: game.gameframerate=41; break;
|
||||
case 18: game.gameframerate=55; break;
|
||||
case 12: game.gameframerate=83; break;
|
||||
default: game.gameframerate=34; break;
|
||||
}
|
||||
|
||||
//Check to see if you've already unlocked some achievements here from before the update
|
||||
if (game.swnbestrank > 0){
|
||||
if(game.swnbestrank >= 1) NETWORK_unlockAchievement("vvvvvvsupgrav5");
|
||||
if(game.swnbestrank >= 2) NETWORK_unlockAchievement("vvvvvvsupgrav10");
|
||||
if(game.swnbestrank >= 3) NETWORK_unlockAchievement("vvvvvvsupgrav15");
|
||||
if(game.swnbestrank >= 4) NETWORK_unlockAchievement("vvvvvvsupgrav20");
|
||||
if(game.swnbestrank >= 5) NETWORK_unlockAchievement("vvvvvvsupgrav30");
|
||||
if(game.swnbestrank >= 6) NETWORK_unlockAchievement("vvvvvvsupgrav60");
|
||||
}
|
||||
|
||||
if(game.unlock[5]) NETWORK_unlockAchievement("vvvvvvgamecomplete");
|
||||
if(game.unlock[19]) NETWORK_unlockAchievement("vvvvvvgamecompleteflip");
|
||||
if(game.unlock[20]) NETWORK_unlockAchievement("vvvvvvmaster");
|
||||
|
||||
if (game.bestgamedeaths > -1) {
|
||||
if (game.bestgamedeaths <= 500) {
|
||||
NETWORK_unlockAchievement("vvvvvvcomplete500");
|
||||
}
|
||||
if (game.bestgamedeaths <= 250) {
|
||||
NETWORK_unlockAchievement("vvvvvvcomplete250");
|
||||
}
|
||||
if (game.bestgamedeaths <= 100) {
|
||||
NETWORK_unlockAchievement("vvvvvvcomplete100");
|
||||
}
|
||||
if (game.bestgamedeaths <= 50) {
|
||||
NETWORK_unlockAchievement("vvvvvvcomplete50");
|
||||
}
|
||||
}
|
||||
|
||||
if(game.bestrank[0]>=3) NETWORK_unlockAchievement("vvvvvvtimetrial_station1_fixed");
|
||||
if(game.bestrank[1]>=3) NETWORK_unlockAchievement("vvvvvvtimetrial_lab_fixed");
|
||||
if(game.bestrank[2]>=3) NETWORK_unlockAchievement("vvvvvvtimetrial_tower_fixed");
|
||||
if(game.bestrank[3]>=3) NETWORK_unlockAchievement("vvvvvvtimetrial_station2_fixed");
|
||||
if(game.bestrank[4]>=3) NETWORK_unlockAchievement("vvvvvvtimetrial_warp_fixed");
|
||||
if(game.bestrank[5]>=3) NETWORK_unlockAchievement("vvvvvvtimetrial_final_fixed");
|
||||
|
||||
entityclass obj;
|
||||
obj.init();
|
||||
|
||||
//Quick hack to start in final level ---- //Might be useful to leave this commented in for testing
|
||||
/*
|
||||
//game.gamestate=GAMEMODE;
|
||||
//game.start(obj,music);
|
||||
//script.startgamemode(8, key, graphics, game, map, obj, help, music);
|
||||
// map.finalmode = true; //Enable final level mode
|
||||
//map.finalx = 41; map.finaly = 52; //Midpoint
|
||||
//map.finalstretch = true;
|
||||
//map.final_colormode = true;
|
||||
//map.final_mapcol = 0;
|
||||
//map.final_colorframe = 0;
|
||||
|
||||
//game.starttest(obj, music);
|
||||
|
||||
game.savex = 5 * 8; game.savey = 15 * 8; game.saverx = 41; game.savery = 52;
|
||||
game.savegc = 0; game.savedir = 1;
|
||||
game.state = 0; game.deathseq = -1; game.lifeseq = 10;
|
||||
//obj.createentity(game, game.savex, game.savey, 0);
|
||||
map.gotoroom(game.saverx, game.savery, graphics, game, obj, music);
|
||||
//music.play(1);
|
||||
*/
|
||||
//End hack here ----
|
||||
|
||||
volatile Uint32 time, timePrev = 0;
|
||||
game.infocus = true;
|
||||
key.isActive = true;
|
||||
|
||||
while(!key.quitProgram)
|
||||
{
|
||||
//gameScreen.ClearScreen(0x00);
|
||||
|
||||
time = SDL_GetTicks();
|
||||
|
||||
// Update network per frame.
|
||||
NETWORK_update();
|
||||
|
||||
//framerate limit to 30
|
||||
Uint32 timetaken = time - timePrev;
|
||||
if(game.gamestate==EDITORMODE)
|
||||
{
|
||||
if (timetaken < 24)
|
||||
{
|
||||
volatile Uint32 delay = 24 - timetaken;
|
||||
SDL_Delay( delay );
|
||||
time = SDL_GetTicks();
|
||||
}
|
||||
timePrev = time;
|
||||
|
||||
}else{
|
||||
if (timetaken < game.gameframerate)
|
||||
{
|
||||
volatile Uint32 delay = game.gameframerate - timetaken;
|
||||
SDL_Delay( delay );
|
||||
time = SDL_GetTicks();
|
||||
}
|
||||
timePrev = time;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
key.Poll();
|
||||
if(key.toggleFullscreen)
|
||||
{
|
||||
if(!gameScreen.isWindowed)
|
||||
{
|
||||
//SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
}
|
||||
|
||||
|
||||
if(game.gamestate == EDITORMODE)
|
||||
{
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
}
|
||||
|
||||
gameScreen.toggleFullScreen();
|
||||
game.fullscreen = !game.fullscreen;
|
||||
key.toggleFullscreen = false;
|
||||
|
||||
key.keymap.clear(); //we lost the input due to a new window.
|
||||
game.press_left = false;
|
||||
game.press_right = false;
|
||||
game.press_action = true;
|
||||
game.press_map = false;
|
||||
printf("Error: failed: %s\n", SDL_GetError());
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*if(key.quitProgram)
|
||||
{
|
||||
music.playef(2);
|
||||
}*/
|
||||
|
||||
game.infocus = key.isActive;
|
||||
if(!game.infocus)
|
||||
{
|
||||
if(game.getGlobalSoundVol()> 0)
|
||||
{
|
||||
game.setGlobalSoundVol(0);
|
||||
}
|
||||
FillRect(graphics.backBuffer, 0x00000000);
|
||||
graphics.bprint(5, 110, "Game paused", 196 - help.glow, 255 - help.glow, 196 - help.glow, true);
|
||||
graphics.bprint(5, 120, "[click to resume]", 196 - help.glow, 255 - help.glow, 196 - help.glow, true);
|
||||
graphics.bprint(5, 230, "Press M to mute in game", 164 - help.glow, 196 - help.glow, 164 - help.glow, true);
|
||||
graphics.render();
|
||||
//We are minimised, so lets put a bit of a delay to save CPU
|
||||
SDL_Delay(100);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(game.gamestate)
|
||||
{
|
||||
case PRELOADER:
|
||||
//Render
|
||||
preloaderrender(graphics, game, help);
|
||||
break;
|
||||
case EDITORMODE:
|
||||
graphics.flipmode = false;
|
||||
//Input
|
||||
editorinput(key, graphics, game, map, obj, help, music);
|
||||
//Render
|
||||
editorrender(key, graphics, game, map, obj, help);
|
||||
////Logic
|
||||
editorlogic(key, graphics, game, obj, music, map, help);
|
||||
break;
|
||||
case TITLEMODE:
|
||||
//Input
|
||||
titleinput(key, graphics, map, game, obj, help, music);
|
||||
//Render
|
||||
titlerender(graphics, map, game, obj, help, music);
|
||||
////Logic
|
||||
titlelogic(graphics, game, obj, help, music, map);
|
||||
break;
|
||||
case GAMEMODE:
|
||||
if (map.towermode)
|
||||
{
|
||||
gameinput(key, graphics, game, map, obj, help, music);
|
||||
|
||||
//if(game.recording==1)
|
||||
//{
|
||||
// ///recordinput(key, graphics, game, map, obj, help, music);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
//}
|
||||
towerrender(graphics, game, map, obj, help);
|
||||
towerlogic(graphics, game, obj, music, map, help);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (game.recording == 1)
|
||||
{
|
||||
//recordinput(key, dwgfx, game, map, obj, help, music);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (script.running)
|
||||
{
|
||||
script.run(key, graphics, game, map, obj, help, music);
|
||||
}
|
||||
|
||||
gameinput(key, graphics, game, map, obj, help, music);
|
||||
//}
|
||||
gamerender(graphics,map, game, obj, help);
|
||||
gamelogic(graphics, game,obj, music, map, help);
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case MAPMODE:
|
||||
maprender(graphics, game, map, obj, help);
|
||||
if (game.recording == 1)
|
||||
{
|
||||
//recordinput(key, dwgfx, game, map, obj, help, music); //will implement this later if it's actually needed
|
||||
}
|
||||
else
|
||||
{
|
||||
mapinput(key, graphics, game, map, obj, help, music);
|
||||
}
|
||||
maplogic(graphics, game, obj ,music , map, help );
|
||||
break;
|
||||
case TELEPORTERMODE:
|
||||
teleporterrender(graphics, game, map, obj, help);
|
||||
if (game.recording == 1)
|
||||
{
|
||||
//recordinput(key, graphics, game, map, obj, help, music);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(game.useteleporter)
|
||||
{
|
||||
teleporterinput(key, graphics, game, map, obj, help, music);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (script.running)
|
||||
{
|
||||
script.run(key, graphics, game, map, obj, help, music);
|
||||
}
|
||||
gameinput(key, graphics, game, map, obj, help, music);
|
||||
}
|
||||
}
|
||||
maplogic(graphics, game, obj, music, map, help);
|
||||
break;
|
||||
case GAMECOMPLETE:
|
||||
gamecompleterender(graphics, game, obj, help, map);
|
||||
//Input
|
||||
gamecompleteinput(key, graphics, game, map, obj, help, music);
|
||||
//Logic
|
||||
gamecompletelogic(graphics, game, obj, music, map, help);
|
||||
break;
|
||||
case GAMECOMPLETE2:
|
||||
gamecompleterender2(graphics, game, obj, help);
|
||||
//Input
|
||||
gamecompleteinput2(key, graphics, game, map, obj, help, music);
|
||||
//Logic
|
||||
gamecompletelogic2(graphics, game, obj, music, map, help);
|
||||
break;
|
||||
case CLICKTOSTART:
|
||||
|
||||
//dwgfx.bprint(5, 115, "[Click to start]", 196 - help.glow, 196 - help.glow, 255 - help.glow, true);
|
||||
//dwgfx.drawgui(help);
|
||||
//dwgfx.render();
|
||||
//dwgfx.backbuffer.unlock();
|
||||
|
||||
help.updateglow();
|
||||
// if (key.click) {
|
||||
// dwgfx.textboxremove();
|
||||
// }
|
||||
// if (dwgfx.ntextbox == 0) {
|
||||
// //music.play(6);
|
||||
// map.ypos = (700-29) * 8;
|
||||
// map.bypos = map.ypos / 2;
|
||||
// map.cameramode = 0;
|
||||
|
||||
// game.gamestate = TITLEMODE;
|
||||
// }
|
||||
break;
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (game.savemystats)
|
||||
{
|
||||
game.savemystats = false;
|
||||
game.savestats(map, graphics);
|
||||
}
|
||||
|
||||
//Mute button
|
||||
if (key.isDown(KEYBOARD_m) && game.mutebutton<=0 && !ed.textentry)
|
||||
{
|
||||
game.mutebutton = 8;
|
||||
if (game.muted)
|
||||
{
|
||||
game.muted = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
game.muted = true;
|
||||
}
|
||||
}
|
||||
if(game.mutebutton>0)
|
||||
{
|
||||
game.mutebutton--;
|
||||
}
|
||||
|
||||
if (game.muted)
|
||||
{
|
||||
//if (game.globalsound == 1)
|
||||
//{
|
||||
game.globalsound = 0;
|
||||
Mix_VolumeMusic(0) ;
|
||||
Mix_Volume(-1,0);
|
||||
//}
|
||||
}
|
||||
|
||||
if (!game.muted && game.globalsound == 0)
|
||||
{
|
||||
game.globalsound = 1;
|
||||
Mix_VolumeMusic(MIX_MAX_VOLUME) ;
|
||||
Mix_Volume(-1,MIX_MAX_VOLUME);
|
||||
}
|
||||
|
||||
if(key.resetWindow)
|
||||
{
|
||||
key.resetWindow = false;
|
||||
gameScreen.ResizeScreen(-1, -1);
|
||||
}
|
||||
|
||||
music.processmusic();
|
||||
graphics.processfade();
|
||||
game.gameclock();
|
||||
gameScreen.FlipScreen();
|
||||
|
||||
//SDL_FillRect( SDL_GetVideoSurface(), NULL, 0 );
|
||||
}
|
||||
|
||||
|
||||
//SDL_Delay(300);
|
||||
|
||||
//TODO
|
||||
//Free the loaded image
|
||||
//SDL_FreeSurface( gameScreen );
|
||||
|
||||
//Quit SDL
|
||||
NETWORK_shutdown();
|
||||
SDL_Quit();
|
||||
FILESYSTEM_deinit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
126
desktop_version/src/preloader.cpp
Normal file
126
desktop_version/src/preloader.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
#include "preloader.h"
|
||||
|
||||
#include "Enums.h"
|
||||
|
||||
int pre_fakepercent=0, pre_transition=30;
|
||||
bool pre_startgame=false;
|
||||
int pre_darkcol=0, pre_lightcol=0, pre_curcol=0, pre_coltimer=0, pre_offset=0;
|
||||
|
||||
int pre_frontrectx=30, pre_frontrecty=20, pre_frontrectw=260, pre_frontrecth=200;
|
||||
int pre_temprectx=0, pre_temprecty=0, pre_temprectw=320, pre_temprecth=240;
|
||||
|
||||
void preloaderrender(Graphics& dwgfx, Game& game, UtilityClass& help)
|
||||
{
|
||||
//TODO
|
||||
//dwgfx.backbuffer.lock();
|
||||
|
||||
//Draw grid
|
||||
|
||||
//pre_transition = -10; pre_fakepercent = 100;
|
||||
|
||||
if (pre_transition < 30) pre_transition--;
|
||||
if(pre_transition>=30){
|
||||
pre_fakepercent++;
|
||||
if (pre_fakepercent >= 100) {
|
||||
pre_fakepercent = 100;
|
||||
pre_startgame = true;
|
||||
}
|
||||
|
||||
pre_offset = (pre_offset + 4 + int(fRandom() * 5.0f))%32;
|
||||
pre_coltimer--;
|
||||
if (pre_coltimer <= 0) {
|
||||
pre_curcol = (pre_curcol + int(fRandom() * 5.0f)) % 6;
|
||||
pre_coltimer = 8;
|
||||
}
|
||||
switch(pre_curcol) {
|
||||
case 0:
|
||||
pre_lightcol = dwgfx.RGBflip(0xBF,0x59,0x6F);
|
||||
pre_darkcol = dwgfx.RGBflip(0x88,0x3E,0x53);
|
||||
break;
|
||||
case 1:
|
||||
pre_lightcol = dwgfx.RGBflip(0x6C,0xBC,0x5C);
|
||||
pre_darkcol = dwgfx.RGBflip(0x50,0x86,0x40);
|
||||
break;
|
||||
case 2:
|
||||
pre_lightcol = dwgfx.RGBflip(0x5D,0x57,0xAA);
|
||||
pre_darkcol = dwgfx.RGBflip(0x2F,0x2F,0x6C);
|
||||
break;
|
||||
case 3:
|
||||
pre_lightcol = dwgfx.RGBflip(0xB7,0xBA,0x5E);
|
||||
pre_darkcol = dwgfx.RGBflip(0x84,0x83,0x42);
|
||||
break;
|
||||
case 4:
|
||||
pre_lightcol = dwgfx.RGBflip(0x57,0x90,0xAA);
|
||||
pre_darkcol = dwgfx.RGBflip(0x2F,0x5B,0x6C);
|
||||
break;
|
||||
case 5:
|
||||
pre_lightcol = dwgfx.RGBflip(0x90,0x61,0xB1);
|
||||
pre_darkcol = dwgfx.RGBflip(0x58,0x3D,0x71);
|
||||
break;
|
||||
default:
|
||||
pre_lightcol = dwgfx.RGBflip(0x00,0x00,0x00);
|
||||
pre_darkcol = dwgfx.RGBflip(0x08,0x00,0x00);
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 18; i++) {
|
||||
pre_temprecty = (i * 16)- pre_offset;
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
FillRect(dwgfx.backBuffer, pre_temprectx, pre_temprecty, pre_temprectw,pre_temprecth, pre_lightcol);
|
||||
}
|
||||
else
|
||||
{
|
||||
FillRect(dwgfx.backBuffer, pre_temprectx, pre_temprecty, pre_temprectw,pre_temprecth, pre_darkcol);
|
||||
}
|
||||
}
|
||||
|
||||
FillRect(dwgfx.backBuffer, pre_frontrectx, pre_frontrecty, pre_frontrectw,pre_frontrecth, dwgfx.getBGR(0x3E,0x31,0xA2));
|
||||
|
||||
if(pre_fakepercent==100){
|
||||
dwgfx.Print(282-(15*8), 204, "LOADING... " + help.String(int(pre_fakepercent))+"%", 124, 112, 218, false);
|
||||
}else{
|
||||
dwgfx.Print(282-(14*8), 204, "LOADING... " + help.String(int(pre_fakepercent))+"%", 124, 112, 218, false);
|
||||
}
|
||||
|
||||
//Render
|
||||
if (pre_startgame) {
|
||||
pre_transition = 29;
|
||||
}
|
||||
}else if (pre_transition <= -10) {
|
||||
game.gamestate=TITLEMODE;
|
||||
}else if (pre_transition < 5) {
|
||||
FillRect(dwgfx.backBuffer, 0, 0, 320,240, dwgfx.getBGR(0,0,0));
|
||||
}else if (pre_transition < 20) {
|
||||
pre_temprecty = 0;
|
||||
pre_temprecth = 240;
|
||||
FillRect(dwgfx.backBuffer, pre_temprectx, pre_temprecty, pre_temprectw,pre_temprecth, 0x000000);
|
||||
FillRect(dwgfx.backBuffer, pre_frontrectx, pre_frontrecty, pre_frontrectw,pre_frontrecth, dwgfx.getBGR(0x3E,0x31,0xA2));
|
||||
|
||||
dwgfx.Print(282-(15*8), 204, "LOADING... 100%", 124, 112, 218, false);
|
||||
}
|
||||
|
||||
if (game.test)
|
||||
{
|
||||
dwgfx.Print(5, 5, game.teststring, 196, 196, 255 - help.glow, false);
|
||||
}
|
||||
|
||||
dwgfx.drawfade();
|
||||
|
||||
if (game.flashlight > 0 && !game.noflashingmode)
|
||||
{
|
||||
game.flashlight--;
|
||||
dwgfx.flashlight();
|
||||
}
|
||||
|
||||
if (game.screenshake > 0 && !game.noflashingmode)
|
||||
{
|
||||
game.screenshake--;
|
||||
dwgfx.screenshake();
|
||||
}
|
||||
else
|
||||
{
|
||||
dwgfx.render();
|
||||
}
|
||||
//dwgfx.backbuffer.unlock();
|
||||
}
|
||||
10
desktop_version/src/preloader.h
Normal file
10
desktop_version/src/preloader.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef PRELOADER_H
|
||||
#define PRELOADER_H
|
||||
|
||||
#include "Graphics.h"
|
||||
#include "Game.h"
|
||||
#include "UtilityClass.h"
|
||||
|
||||
void preloaderrender(Graphics& dwgfx, Game& game, UtilityClass& help);
|
||||
|
||||
#endif /* PRELOADER_H */
|
||||
3096
desktop_version/src/titlerender.cpp
Normal file
3096
desktop_version/src/titlerender.cpp
Normal file
File diff suppressed because it is too large
Load Diff
35
desktop_version/src/titlerender.h
Normal file
35
desktop_version/src/titlerender.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef TITLERENDERER_H
|
||||
#define TITLERENDERER_H
|
||||
|
||||
#include "Graphics.h"
|
||||
#include "UtilityClass.h"
|
||||
#include "Maths.h"
|
||||
#include "Entity.h"
|
||||
#include "Map.h"
|
||||
#include "Script.h"
|
||||
|
||||
class Stage
|
||||
{
|
||||
public:
|
||||
int frameRate;
|
||||
};
|
||||
|
||||
extern Stage stage;
|
||||
extern Stage swfStage;
|
||||
extern int temp;
|
||||
|
||||
void titlerender(Graphics& dwgfx, mapclass& map, Game& game, entityclass& obj, UtilityClass& help, musicclass& music);
|
||||
|
||||
void towerrender(Graphics& dwgfx, Game& game, mapclass& map, entityclass& obj, UtilityClass& help);
|
||||
|
||||
void gamerender(Graphics& dwgfx, mapclass& map, Game& game, entityclass& obj, UtilityClass& help);
|
||||
|
||||
void maprender(Graphics& dwgfx, Game& game, mapclass& map, entityclass& obj, UtilityClass& help);
|
||||
|
||||
void teleporterrender(Graphics& dwgfx, Game& game, mapclass& map, entityclass& obj, UtilityClass& help);
|
||||
|
||||
void gamecompleterender(Graphics& dwgfx, Game& game, entityclass& obj, UtilityClass& help, mapclass& map);
|
||||
|
||||
void gamecompleterender2(Graphics& dwgfx, Game& game, entityclass& obj, UtilityClass& help);
|
||||
|
||||
#endif /* TITLERENDERER_H */
|
||||
Reference in New Issue
Block a user