mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-09-20 21:37:26 +02:00
Compare commits
No commits in common. "ff3e390352e5b6945725433003ea7a3223e6e618" and "67958564315f0bcbcf8806435fa0f7003a0b3cf3" have entirely different histories.
ff3e390352
...
6795856431
12 changed files with 243 additions and 0 deletions
|
@ -4372,6 +4372,27 @@ bool entityclass::testwallsy( int t, float tx, float ty )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void entityclass::fixfriction( int t, float xfix, float xrate, float yrate )
|
||||||
|
{
|
||||||
|
if (!INBOUNDS_VEC(t, entities))
|
||||||
|
{
|
||||||
|
puts("fixfriction() out-of-bounds!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entities[t].vx > xfix) entities[t].vx -= xrate;
|
||||||
|
if (entities[t].vx < xfix) entities[t].vx += xrate;
|
||||||
|
if (entities[t].vy > 0) entities[t].vy -= yrate;
|
||||||
|
if (entities[t].vy < 0) entities[t].vy += yrate;
|
||||||
|
if (entities[t].vy > 10) entities[t].vy = 10;
|
||||||
|
if (entities[t].vy < -10) entities[t].vy = -10;
|
||||||
|
if (entities[t].vx > 6) entities[t].vx = 6.0f;
|
||||||
|
if (entities[t].vx < -6) entities[t].vx = -6.0f;
|
||||||
|
|
||||||
|
if (SDL_fabsf(entities[t].vx-xfix) <= xrate) entities[t].vx = xfix;
|
||||||
|
if (SDL_fabsf(entities[t].vy) < yrate) entities[t].vy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void entityclass::applyfriction( int t, float xrate, float yrate )
|
void entityclass::applyfriction( int t, float xrate, float yrate )
|
||||||
{
|
{
|
||||||
if (!INBOUNDS_VEC(t, entities))
|
if (!INBOUNDS_VEC(t, entities))
|
||||||
|
|
|
@ -157,6 +157,8 @@ public:
|
||||||
|
|
||||||
bool testwallsy(int t, float tx, float ty);
|
bool testwallsy(int t, float tx, float ty);
|
||||||
|
|
||||||
|
void fixfriction(int t, float xfix, float xrate, float yrate);
|
||||||
|
|
||||||
void applyfriction(int t, float xrate, float yrate);
|
void applyfriction(int t, float xrate, float yrate);
|
||||||
|
|
||||||
void updateentitylogic(int t);
|
void updateentitylogic(int t);
|
||||||
|
|
|
@ -455,6 +455,10 @@ int Graphics::len(std::string t)
|
||||||
return bfontpos;
|
return bfontpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Graphics::PrintOff( int _x, int _y, std::string _s, int r, int g, int b, bool cen /*= false*/ ) {
|
||||||
|
PrintOffAlpha(_x,_y,_s,r,g,b,255,cen);
|
||||||
|
}
|
||||||
|
|
||||||
void Graphics::PrintOffAlpha( int _x, int _y, std::string _s, int r, int g, int b, int a, bool cen /*= false*/ )
|
void Graphics::PrintOffAlpha( int _x, int _y, std::string _s, int r, int g, int b, int a, bool cen /*= false*/ )
|
||||||
{
|
{
|
||||||
std::vector<SDL_Surface*>& font = flipmode ? flipbfont : bfont;
|
std::vector<SDL_Surface*>& font = flipmode ? flipbfont : bfont;
|
||||||
|
@ -515,6 +519,40 @@ void Graphics::bprintalpha( int x, int y, std::string t, int r, int g, int b, in
|
||||||
PrintAlpha(x, y, t, r, g, b, a, cen);
|
PrintAlpha(x, y, t, r, g, b, a, cen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Graphics::RPrint( int _x, int _y, std::string _s, int r, int g, int b, bool cen /*= false*/ )
|
||||||
|
{
|
||||||
|
std::vector<SDL_Surface*>& font = flipmode ? flipbfont : bfont;
|
||||||
|
|
||||||
|
r = clamp(r,0,255);
|
||||||
|
g = clamp(g,0,255);
|
||||||
|
b = clamp(b,0,255);
|
||||||
|
ct.colour = getRGB(r, g, b);
|
||||||
|
|
||||||
|
if (cen)
|
||||||
|
_x = ((308) - (_s.length() / 2));
|
||||||
|
int bfontpos = 0;
|
||||||
|
int curr;
|
||||||
|
int idx;
|
||||||
|
std::string::iterator iter = _s.begin();
|
||||||
|
while (iter != _s.end()) {
|
||||||
|
curr = utf8::unchecked::next(iter);
|
||||||
|
point tpoint;
|
||||||
|
tpoint.x = _x + bfontpos;
|
||||||
|
tpoint.y = _y;
|
||||||
|
|
||||||
|
SDL_Rect fontRect = bfont_rect;
|
||||||
|
fontRect.x = tpoint.x ;
|
||||||
|
fontRect.y = tpoint.y ;
|
||||||
|
|
||||||
|
idx = font_idx(curr);
|
||||||
|
if (INBOUNDS_VEC(idx, font))
|
||||||
|
{
|
||||||
|
BlitSurfaceColoured( font[idx], NULL, backBuffer, &fontRect , ct);
|
||||||
|
}
|
||||||
|
bfontpos+=bfontlen(curr) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Graphics::printcrewname( int x, int y, int t )
|
void Graphics::printcrewname( int x, int y, int t )
|
||||||
{
|
{
|
||||||
//Print the name of crew member t in the right colour
|
//Print the name of crew member t in the right colour
|
||||||
|
@ -679,6 +717,17 @@ void Graphics::drawtile3( int x, int y, int t, int off, int height_subtract /*=
|
||||||
BlitSurfaceStandard(tiles3[t], &src_rect, backBuffer, &rect);
|
BlitSurfaceStandard(tiles3[t], &src_rect, backBuffer, &rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Graphics::drawentcolours( int x, int y, int t)
|
||||||
|
{
|
||||||
|
if (!INBOUNDS_VEC(t, entcolours))
|
||||||
|
{
|
||||||
|
WHINE_ONCE("drawentcolours() out-of-bounds!")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SDL_Rect rect = { Sint16(x), Sint16(y), tiles_rect.w, tiles_rect.h };
|
||||||
|
BlitSurfaceStandard(entcolours[t], NULL, backBuffer, &rect);
|
||||||
|
}
|
||||||
|
|
||||||
void Graphics::drawtowertile( int x, int y, int t )
|
void Graphics::drawtowertile( int x, int y, int t )
|
||||||
{
|
{
|
||||||
if (!INBOUNDS_VEC(t, tiles2))
|
if (!INBOUNDS_VEC(t, tiles2))
|
||||||
|
@ -2814,6 +2863,18 @@ void Graphics::setwarprect( int a, int b, int c, int d )
|
||||||
warprect.h = d;
|
warprect.h = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Graphics::textboxcenter()
|
||||||
|
{
|
||||||
|
if (!INBOUNDS_VEC(m, textbox))
|
||||||
|
{
|
||||||
|
puts("textboxcenter() out-of-bounds!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
textbox[m].centerx();
|
||||||
|
textbox[m].centery();
|
||||||
|
}
|
||||||
|
|
||||||
void Graphics::textboxcenterx()
|
void Graphics::textboxcenterx()
|
||||||
{
|
{
|
||||||
if (!INBOUNDS_VEC(m, textbox))
|
if (!INBOUNDS_VEC(m, textbox))
|
||||||
|
@ -2836,6 +2897,18 @@ int Graphics::textboxwidth()
|
||||||
return textbox[m].w;
|
return textbox[m].w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Graphics::textboxmove(int xo, int yo)
|
||||||
|
{
|
||||||
|
if (!INBOUNDS_VEC(m, textbox))
|
||||||
|
{
|
||||||
|
puts("textboxmove() out-of-bounds!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
textbox[m].xp += xo;
|
||||||
|
textbox[m].yp += yo;
|
||||||
|
}
|
||||||
|
|
||||||
void Graphics::textboxmoveto(int xo)
|
void Graphics::textboxmoveto(int xo)
|
||||||
{
|
{
|
||||||
if (!INBOUNDS_VEC(m, textbox))
|
if (!INBOUNDS_VEC(m, textbox))
|
||||||
|
|
|
@ -49,10 +49,14 @@ public:
|
||||||
|
|
||||||
void createtextbox(std::string t, int xp, int yp, int r= 255, int g= 255, int b = 255);
|
void createtextbox(std::string t, int xp, int yp, int r= 255, int g= 255, int b = 255);
|
||||||
|
|
||||||
|
void textboxcenter();
|
||||||
|
|
||||||
void textboxcenterx();
|
void textboxcenterx();
|
||||||
|
|
||||||
int textboxwidth();
|
int textboxwidth();
|
||||||
|
|
||||||
|
void textboxmove(int xo, int yo);
|
||||||
|
|
||||||
void textboxmoveto(int xo);
|
void textboxmoveto(int xo);
|
||||||
|
|
||||||
void textboxcentery();
|
void textboxcentery();
|
||||||
|
@ -107,6 +111,10 @@ public:
|
||||||
|
|
||||||
void PrintAlpha(int _x, int _y, std::string _s, int r, int g, int b, int a, bool cen = false);
|
void PrintAlpha(int _x, int _y, std::string _s, int r, int g, int b, int a, 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 PrintOffAlpha(int _x, int _y, std::string _s, int r, int g, int b, int a, bool cen = false);
|
void PrintOffAlpha(int _x, int _y, std::string _s, int r, int g, int b, int a, bool cen = false);
|
||||||
|
|
||||||
void bprint(int x, int y, std::string t, 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);
|
||||||
|
@ -159,6 +167,7 @@ public:
|
||||||
void drawbackground(int t);
|
void drawbackground(int t);
|
||||||
void updatebackground(int t);
|
void updatebackground(int t);
|
||||||
void drawtile3( int x, int y, int t, int off, int height_subtract = 0 );
|
void drawtile3( int x, int y, int t, int off, int height_subtract = 0 );
|
||||||
|
void drawentcolours( int x, int y, int t);
|
||||||
void drawtile2( int x, int y, int t );
|
void drawtile2( int x, int y, int t );
|
||||||
void drawtile( int x, int y, int t );
|
void drawtile( int x, int y, int t );
|
||||||
void drawtowertile( int x, int y, int t );
|
void drawtowertile( int x, int y, int t );
|
||||||
|
|
|
@ -136,6 +136,28 @@ SDL_Surface * ScaleSurface( SDL_Surface *_surface, int Width, int Height, SDL_Su
|
||||||
return _ret;
|
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 * FlipSurfaceVerticle(SDL_Surface* _src)
|
||||||
{
|
{
|
||||||
SDL_Surface * ret = SDL_CreateRGBSurface(_src->flags, _src->w, _src->h, _src->format->BitsPerPixel,
|
SDL_Surface * ret = SDL_CreateRGBSurface(_src->flags, _src->w, _src->h, _src->format->BitsPerPixel,
|
||||||
|
|
|
@ -39,6 +39,7 @@ void FillRect( SDL_Surface* surface, SDL_Rect rect, int rgba );
|
||||||
|
|
||||||
void ScrollSurface(SDL_Surface* _src, int pX, int py);
|
void ScrollSurface(SDL_Surface* _src, int pX, int py);
|
||||||
|
|
||||||
|
SDL_Surface * FlipSurfaceHorizontal(SDL_Surface* _src);
|
||||||
SDL_Surface * FlipSurfaceVerticle(SDL_Surface* _src);
|
SDL_Surface * FlipSurfaceVerticle(SDL_Surface* _src);
|
||||||
void UpdateFilter();
|
void UpdateFilter();
|
||||||
SDL_Surface* ApplyFilter( SDL_Surface* _src );
|
SDL_Surface* ApplyFilter( SDL_Surface* _src );
|
||||||
|
|
|
@ -323,6 +323,11 @@ bool KeyPoll::isDown(SDL_Keycode key)
|
||||||
return keymap[key];
|
return keymap[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KeyPoll::isUp(SDL_Keycode key)
|
||||||
|
{
|
||||||
|
return !keymap[key];
|
||||||
|
}
|
||||||
|
|
||||||
bool KeyPoll::isDown(std::vector<SDL_GameControllerButton> buttons)
|
bool KeyPoll::isDown(std::vector<SDL_GameControllerButton> buttons)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < buttons.size(); i += 1)
|
for (size_t i = 0; i < buttons.size(); i += 1)
|
||||||
|
|
|
@ -54,6 +54,8 @@ public:
|
||||||
|
|
||||||
bool isDown(SDL_Keycode key);
|
bool isDown(SDL_Keycode key);
|
||||||
|
|
||||||
|
bool isUp(SDL_Keycode key);
|
||||||
|
|
||||||
bool isDown(std::vector<SDL_GameControllerButton> buttons);
|
bool isDown(std::vector<SDL_GameControllerButton> buttons);
|
||||||
bool isDown(SDL_GameControllerButton button);
|
bool isDown(SDL_GameControllerButton button);
|
||||||
bool controllerButtonDown();
|
bool controllerButtonDown();
|
||||||
|
|
|
@ -59,3 +59,15 @@ SoundSystem::SoundSystem()
|
||||||
SDL_assert(0 && "Unable to initialize audio!");
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ class SoundSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SoundSystem();
|
SoundSystem();
|
||||||
|
void playMusic(MusicTrack* music);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SOUNDSYSTEM_H */
|
#endif /* SOUNDSYSTEM_H */
|
||||||
|
|
|
@ -932,6 +932,14 @@ int editorclass::getenemyframe(int t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void editorclass::placetile( int x, int y, int t )
|
||||||
|
{
|
||||||
|
if(x>=0 && y>=0 && x<mapwidth*40 && y<mapheight*30)
|
||||||
|
{
|
||||||
|
contents[x+(levx*40)+vmult[y+(levy*30)]]=t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void editorclass::placetilelocal( int x, int y, int t )
|
void editorclass::placetilelocal( int x, int y, int t )
|
||||||
{
|
{
|
||||||
if(x>=0 && y>=0 && x<40 && y<30)
|
if(x>=0 && y>=0 && x<40 && y<30)
|
||||||
|
@ -1241,6 +1249,27 @@ int editorclass::match( int x, int y )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int editorclass::warpzonematch( int x, int y )
|
||||||
|
{
|
||||||
|
if(free(x-1,y)==0 && free(x,y-1)==0 && free(x+1,y)==0 && free(x,y+1)==0) return 0;
|
||||||
|
|
||||||
|
if(free(x-1,y)==0 && free(x,y-1)==0) return 10;
|
||||||
|
if(free(x+1,y)==0 && free(x,y-1)==0) return 11;
|
||||||
|
if(free(x-1,y)==0 && free(x,y+1)==0) return 12;
|
||||||
|
if(free(x+1,y)==0 && free(x,y+1)==0) return 13;
|
||||||
|
|
||||||
|
if(free(x,y-1)==0) return 1;
|
||||||
|
if(free(x-1,y)==0) return 2;
|
||||||
|
if(free(x,y+1)==0) return 3;
|
||||||
|
if(free(x+1,y)==0) return 4;
|
||||||
|
if(free(x-1,y-1)==0) return 5;
|
||||||
|
if(free(x+1,y-1)==0) return 6;
|
||||||
|
if(free(x-1,y+1)==0) return 7;
|
||||||
|
if(free(x+1,y+1)==0) return 8;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int editorclass::outsidematch( int x, int y )
|
int editorclass::outsidematch( int x, int y )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1326,6 +1355,57 @@ int editorclass::edgetile( int x, int y )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int editorclass::warpzoneedgetile( int x, int y )
|
||||||
|
{
|
||||||
|
switch(backmatch(x,y))
|
||||||
|
{
|
||||||
|
case 14:
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
return 80;
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
return 82;
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
return 160;
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
return 162;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
return 81;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return 120;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
return 161;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
return 122;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
return 42;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
return 41;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
return 2;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int editorclass::outsideedgetile( int x, int y )
|
int editorclass::outsideedgetile( int x, int y )
|
||||||
{
|
{
|
||||||
switch(outsidematch(x,y))
|
switch(outsidematch(x,y))
|
||||||
|
@ -2116,6 +2196,15 @@ int edentat( int xp, int yp )
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool edentclear( int xp, int yp )
|
||||||
|
{
|
||||||
|
for(size_t i=0; i<edentity.size(); i++)
|
||||||
|
{
|
||||||
|
if(edentity[i].x==xp && edentity[i].y==yp) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void fillbox( int x, int y, int x2, int y2, int c )
|
void fillbox( int x, int y, int x2, int y2, int c )
|
||||||
{
|
{
|
||||||
FillRect(graphics.backBuffer, x, y, x2-x, 1, c);
|
FillRect(graphics.backBuffer, x, y, x2-x, 1, c);
|
||||||
|
|
|
@ -121,6 +121,8 @@ class editorclass{
|
||||||
void getlin(const enum textmode mode, const std::string& prompt, std::string* ptr);
|
void getlin(const enum textmode mode, const std::string& prompt, std::string* ptr);
|
||||||
const short* loadlevel(int rxi, int ryi);
|
const short* loadlevel(int rxi, int ryi);
|
||||||
|
|
||||||
|
void placetile(int x, int y, int t);
|
||||||
|
|
||||||
void placetilelocal(int x, int y, int t);
|
void placetilelocal(int x, int y, int t);
|
||||||
|
|
||||||
int getenemyframe(int t);
|
int getenemyframe(int t);
|
||||||
|
@ -141,6 +143,7 @@ class editorclass{
|
||||||
int absfree(int x, int y);
|
int absfree(int x, int y);
|
||||||
|
|
||||||
int match(int x, int y);
|
int match(int x, int y);
|
||||||
|
int warpzonematch(int x, int y);
|
||||||
int outsidematch(int x, int y);
|
int outsidematch(int x, int y);
|
||||||
|
|
||||||
int backmatch(int x, int y);
|
int backmatch(int x, int y);
|
||||||
|
@ -154,6 +157,7 @@ class editorclass{
|
||||||
bool save(std::string& _path);
|
bool save(std::string& _path);
|
||||||
void generatecustomminimap();
|
void generatecustomminimap();
|
||||||
int edgetile(int x, int y);
|
int edgetile(int x, int y);
|
||||||
|
int warpzoneedgetile(int x, int y);
|
||||||
int outsideedgetile(int x, int y);
|
int outsideedgetile(int x, int y);
|
||||||
|
|
||||||
int backedgetile(int x, int y);
|
int backedgetile(int x, int y);
|
||||||
|
@ -272,6 +276,8 @@ void removeedentity(int t);
|
||||||
int edentat(int xp, int yp);
|
int edentat(int xp, int yp);
|
||||||
|
|
||||||
|
|
||||||
|
bool edentclear(int xp, int yp);
|
||||||
|
|
||||||
void fillbox(int x, int y, int x2, int y2, int c);
|
void fillbox(int x, int y, int x2, int y2, int c);
|
||||||
|
|
||||||
void fillboxabs(int x, int y, int x2, int y2, int c);
|
void fillboxabs(int x, int y, int x2, int y2, int c);
|
||||||
|
|
Loading…
Reference in a new issue