mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-03 00:46:55 +02:00
drobne poprawki w wyświetlaniu cieni oraz naprawienie rotacji dla ośmiobitowych surface'ów
dorobienie ifndefów w niektórych plikach .h (dlaczego ty ich nie robisz???)
This commit is contained in:
@ -403,6 +403,12 @@ void CAmbarCendamo::deh3m()
|
|||||||
vinya.bytes[v] = bufor[i++];
|
vinya.bytes[v] = bufor[i++];
|
||||||
}
|
}
|
||||||
map.defy.push_back(vinya); // add this def to the vector
|
map.defy.push_back(vinya); // add this def to the vector
|
||||||
|
|
||||||
|
//testing - only fragment//////////////////////////////////////////////////////////////
|
||||||
|
//map.defy[idd].handler = new CSemiDefHandler();
|
||||||
|
//map.defy[idd].handler->openDef(map.defy[idd].name.c_str(), "H3sprite.lod");
|
||||||
|
//end fo testing - only fragment///////////////////////////////////////////////////////
|
||||||
|
|
||||||
//teceDef();
|
//teceDef();
|
||||||
}
|
}
|
||||||
THC std::cout<<"Wczytywanie defow: "<<th.getDif()<<std::endl;
|
THC std::cout<<"Wczytywanie defow: "<<th.getDif()<<std::endl;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef AMBARCENDD
|
#ifndef CAMBARCENDAMO_H
|
||||||
#define AMBARCENDD
|
#define CAMBARCENDAMO_H
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -31,4 +31,4 @@ public:
|
|||||||
EDefType getDefType(DefInfo& a); //returns type of object in def
|
EDefType getDefType(DefInfo& a); //returns type of object in def
|
||||||
CCreatureSet readCreatureSet(int pos, int number = 7); //reads creature set in most recently encountered format; reades number units (default is 7)
|
CCreatureSet readCreatureSet(int pos, int number = 7); //reads creature set in most recently encountered format; reades number units (default is 7)
|
||||||
};
|
};
|
||||||
#endif //AMBARCENDD
|
#endif //CAMBARCENDAMO_H
|
6
CMT.cpp
6
CMT.cpp
@ -228,11 +228,11 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
mush->initMusics();
|
mush->initMusics();
|
||||||
//audio initialized
|
//audio initialized
|
||||||
|
|
||||||
if(Mix_PlayMusic(mush->mainMenuWoG, -1)==-1) //uncomment this fragment to have music
|
/*if(Mix_PlayMusic(mush->mainMenuWoG, -1)==-1) //uncomment this fragment to have music
|
||||||
{
|
{
|
||||||
printf("Mix_PlayMusic: %s\n", Mix_GetError());
|
printf("Mix_PlayMusic: %s\n", Mix_GetError());
|
||||||
// well, there's no music, but most games don't break without music...
|
// well, there's no music, but most games don't break without music...
|
||||||
}
|
}*/
|
||||||
|
|
||||||
screen = SDL_SetVideoMode(800,600,24,SDL_HWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/);
|
screen = SDL_SetVideoMode(800,600,24,SDL_HWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/);
|
||||||
ekran = screen;
|
ekran = screen;
|
||||||
@ -283,7 +283,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
CObjectHandler * objh = new CObjectHandler;
|
CObjectHandler * objh = new CObjectHandler;
|
||||||
objh->loadObjects();
|
objh->loadObjects();
|
||||||
cgi->objh = objh;
|
cgi->objh = objh;
|
||||||
CAmbarCendamo * ac = new CAmbarCendamo("9gryf"); //4gryf
|
CAmbarCendamo * ac = new CAmbarCendamo("4gryf"); //4gryf
|
||||||
CMapHeader * mmhh = new CMapHeader(ac->bufor); //czytanie nag��wka
|
CMapHeader * mmhh = new CMapHeader(ac->bufor); //czytanie nag��wka
|
||||||
cgi->ac = ac;
|
cgi->ac = ac;
|
||||||
THC std::cout<<"Wczytywanie pliku: "<<tmh.getDif()<<std::endl;
|
THC std::cout<<"Wczytywanie pliku: "<<tmh.getDif()<<std::endl;
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef CMESSAGE_H
|
||||||
|
#define CMESSAGE_H
|
||||||
|
|
||||||
#include "SDL_TTF.h"
|
#include "SDL_TTF.h"
|
||||||
#include "CSemiDefHandler.h"
|
#include "CSemiDefHandler.h"
|
||||||
enum EWindowType {infoOnly, infoOK, yesOrNO};
|
enum EWindowType {infoOnly, infoOK, yesOrNO};
|
||||||
@ -60,3 +63,5 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#endif //CMESSAGE_H
|
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef CPREGAME_H
|
||||||
|
#define CPREGAME_H
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "CSemiDefHandler.h"
|
#include "CSemiDefHandler.h"
|
||||||
#include "CSemiLodHandler.h"
|
#include "CSemiLodHandler.h"
|
||||||
@ -64,3 +67,5 @@ public:
|
|||||||
void showAskBox (std::string data, void(*f1)(),void(*f2)());
|
void showAskBox (std::string data, void(*f1)(),void(*f2)());
|
||||||
void hideBox ();
|
void hideBox ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif //CPREGAME_H
|
@ -69,19 +69,35 @@ SDL_Surface * CSDL_Ext::rotate01(SDL_Surface * toRot, int myC)
|
|||||||
SDL_Surface * first = SDL_CreateRGBSurface(toRot->flags, toRot->w, toRot->h, toRot->format->BitsPerPixel, toRot->format->Rmask, toRot->format->Gmask, toRot->format->Bmask, toRot->format->Amask);
|
SDL_Surface * first = SDL_CreateRGBSurface(toRot->flags, toRot->w, toRot->h, toRot->format->BitsPerPixel, toRot->format->Rmask, toRot->format->Gmask, toRot->format->Bmask, toRot->format->Amask);
|
||||||
SDL_Surface * ret = SDL_ConvertSurface(first, toRot->format, toRot->flags);
|
SDL_Surface * ret = SDL_ConvertSurface(first, toRot->format, toRot->flags);
|
||||||
//SDL_SetColorKey(ret, SDL_SRCCOLORKEY, toRot->format->colorkey);
|
//SDL_SetColorKey(ret, SDL_SRCCOLORKEY, toRot->format->colorkey);
|
||||||
for(int i=0; i<ret->w; ++i)
|
if(toRot->format->BytesPerPixel!=1)
|
||||||
{
|
{
|
||||||
for(int j=0; j<ret->h; ++j)
|
for(int i=0; i<ret->w; ++i)
|
||||||
{
|
{
|
||||||
|
for(int j=0; j<ret->h; ++j)
|
||||||
{
|
{
|
||||||
Uint8 *p = (Uint8 *)toRot->pixels + j * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel;
|
|
||||||
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
|
||||||
{
|
{
|
||||||
CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2], myC);
|
Uint8 *p = (Uint8 *)toRot->pixels + j * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel;
|
||||||
|
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||||
|
{
|
||||||
|
CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2], myC);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0], myC);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(int i=0; i<ret->w; ++i)
|
||||||
|
{
|
||||||
|
for(int j=0; j<ret->h; ++j)
|
||||||
|
{
|
||||||
{
|
{
|
||||||
CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0], myC);
|
Uint8 *p = (Uint8 *)toRot->pixels + j * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel;
|
||||||
|
(*((Uint8*)ret->pixels + j*ret->pitch + i*ret->format->BytesPerPixel)) = *p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,20 +110,36 @@ SDL_Surface * CSDL_Ext::hFlip(SDL_Surface * toRot)
|
|||||||
SDL_Surface * first = SDL_CreateRGBSurface(toRot->flags, toRot->w, toRot->h, toRot->format->BitsPerPixel, toRot->format->Rmask, toRot->format->Gmask, toRot->format->Bmask, toRot->format->Amask);
|
SDL_Surface * first = SDL_CreateRGBSurface(toRot->flags, toRot->w, toRot->h, toRot->format->BitsPerPixel, toRot->format->Rmask, toRot->format->Gmask, toRot->format->Bmask, toRot->format->Amask);
|
||||||
SDL_Surface * ret = SDL_ConvertSurface(first, toRot->format, toRot->flags);
|
SDL_Surface * ret = SDL_ConvertSurface(first, toRot->format, toRot->flags);
|
||||||
//SDL_SetColorKey(ret, SDL_SRCCOLORKEY, toRot->format->colorkey);
|
//SDL_SetColorKey(ret, SDL_SRCCOLORKEY, toRot->format->colorkey);
|
||||||
for(int i=0; i<ret->w; ++i)
|
if(ret->format->BytesPerPixel!=1)
|
||||||
{
|
{
|
||||||
for(int j=0; j<ret->h; ++j)
|
for(int i=0; i<ret->w; ++i)
|
||||||
{
|
{
|
||||||
|
for(int j=0; j<ret->h; ++j)
|
||||||
{
|
{
|
||||||
Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j -1) * toRot->pitch + i * toRot->format->BytesPerPixel-2;
|
|
||||||
int k=2;
|
|
||||||
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
|
||||||
{
|
{
|
||||||
CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2], k);
|
Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j -1) * toRot->pitch + i * toRot->format->BytesPerPixel-2;
|
||||||
|
int k=2;
|
||||||
|
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||||
|
{
|
||||||
|
CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2], k);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0], k);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(int i=0; i<ret->w; ++i)
|
||||||
|
{
|
||||||
|
for(int j=0; j<ret->h; ++j)
|
||||||
|
{
|
||||||
{
|
{
|
||||||
CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0], k);
|
Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j -1) * toRot->pitch + i * toRot->format->BytesPerPixel;
|
||||||
|
(*((Uint8*)ret->pixels + j*ret->pitch + i*ret->format->BytesPerPixel)) = *p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,23 +185,37 @@ SDL_Surface * CSDL_Ext::rotate03(SDL_Surface * toRot)
|
|||||||
SDL_Surface * first = SDL_CreateRGBSurface(toRot->flags, toRot->w, toRot->h, toRot->format->BitsPerPixel, toRot->format->Rmask, toRot->format->Gmask, toRot->format->Bmask, toRot->format->Amask);
|
SDL_Surface * first = SDL_CreateRGBSurface(toRot->flags, toRot->w, toRot->h, toRot->format->BitsPerPixel, toRot->format->Rmask, toRot->format->Gmask, toRot->format->Bmask, toRot->format->Amask);
|
||||||
SDL_Surface * ret = SDL_ConvertSurface(first, toRot->format, toRot->flags);
|
SDL_Surface * ret = SDL_ConvertSurface(first, toRot->format, toRot->flags);
|
||||||
//SDL_SetColorKey(ret, SDL_SRCCOLORKEY, toRot->format->colorkey);
|
//SDL_SetColorKey(ret, SDL_SRCCOLORKEY, toRot->format->colorkey);
|
||||||
for(int i=0; i<ret->w; ++i)
|
if(ret->format->BytesPerPixel!=1)
|
||||||
{
|
{
|
||||||
for(int j=0; j<ret->h; ++j)
|
for(int i=0; i<ret->w; ++i)
|
||||||
{
|
{
|
||||||
|
for(int j=0; j<ret->h; ++j)
|
||||||
{
|
{
|
||||||
Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j - 1) * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel+2;
|
|
||||||
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
|
||||||
{
|
{
|
||||||
SDL_PutPixel(ret, i, j, p[0], p[1], p[2], 2);
|
Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j - 1) * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel+2;
|
||||||
}
|
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||||
else
|
{
|
||||||
{
|
SDL_PutPixel(ret, i, j, p[0], p[1], p[2], 2);
|
||||||
SDL_PutPixel(ret, i, j, p[2], p[1], p[0], 2);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_PutPixel(ret, i, j, p[2], p[1], p[0], 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(int i=0; i<ret->w; ++i)
|
||||||
|
{
|
||||||
|
for(int j=0; j<ret->h; ++j)
|
||||||
|
{
|
||||||
|
Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j - 1) * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel;
|
||||||
|
(*((Uint8*)ret->pixels + j*ret->pitch + i*ret->format->BytesPerPixel)) = *p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
SDL_FreeSurface(first);
|
SDL_FreeSurface(first);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -247,28 +293,6 @@ Uint32 CSDL_Ext::SDL_GetPixel(SDL_Surface *surface, int x, int y, bool colorByte
|
|||||||
SDL_Surface * CSDL_Ext::alphaTransform(SDL_Surface *src)
|
SDL_Surface * CSDL_Ext::alphaTransform(SDL_Surface *src)
|
||||||
{
|
{
|
||||||
Uint32 trans = SDL_MapRGBA(src->format, 0, 255, 255, 255);
|
Uint32 trans = SDL_MapRGBA(src->format, 0, 255, 255, 255);
|
||||||
//SDL_SetColorKey(src, SDL_SRCCOLORKEY, trans);
|
|
||||||
/*SDL_SetColorKey(src, 0, trans);
|
|
||||||
src = SDL_ConvertSurface(src, ekran->format, ekran->flags);
|
|
||||||
for(int i=0; i<src->w; ++i)
|
|
||||||
{
|
|
||||||
for(int j=0; j<src->h; ++j)
|
|
||||||
{
|
|
||||||
Uint8 cr, cg, cb, ca;
|
|
||||||
SDL_GetRGBA(SDL_GetPixel(src, i, j), src->format, &cr, &cg, &cb, &ca);
|
|
||||||
if(cr == 255 && cb == 255)
|
|
||||||
{
|
|
||||||
Uint32 aaaa=src->format->Amask;
|
|
||||||
Uint32 aaab=src->format->Bmask;
|
|
||||||
Uint32 aaag=src->format->Gmask;
|
|
||||||
Uint32 aaar=src->format->Rmask;
|
|
||||||
Uint32 put = cg << 24 | cr << 16 | ca << 8 | cb;
|
|
||||||
SDL_Rect rrr = genRect(1, 1, i, j);
|
|
||||||
SDL_FillRect(src, &rrr, put);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
//SDL_UpdateRect(src, 0, 0, src->w, src->h);
|
|
||||||
SDL_SetColorKey(src, 0, trans);
|
SDL_SetColorKey(src, 0, trans);
|
||||||
src->flags|=SDL_SRCALPHA;
|
src->flags|=SDL_SRCALPHA;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ public:
|
|||||||
static SDL_Cursor * SurfaceToCursor(SDL_Surface *image, int hx, int hy);
|
static SDL_Cursor * SurfaceToCursor(SDL_Surface *image, int hx, int hy);
|
||||||
static Uint32 SDL_GetPixel(SDL_Surface *surface, int x, int y, bool colorByte = false);
|
static Uint32 SDL_GetPixel(SDL_Surface *surface, int x, int y, bool colorByte = false);
|
||||||
static SDL_Color SDL_GetPixelColor(SDL_Surface *surface, int x, int y);
|
static SDL_Color SDL_GetPixelColor(SDL_Surface *surface, int x, int y);
|
||||||
static SDL_Surface * alphaTransform(SDL_Surface * src); //adds transparency and shadows
|
static SDL_Surface * alphaTransform(SDL_Surface * src); //adds transparency and shadows (partial handling only; see examples of using for details)
|
||||||
static Uint32 colorToUint32(const SDL_Color * color); //little endian only
|
static Uint32 colorToUint32(const SDL_Color * color); //little endian only
|
||||||
};
|
};
|
||||||
|
|
||||||
|
2
map.h
2
map.h
@ -4,6 +4,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "CSemiDefHandler.h"
|
||||||
|
|
||||||
struct Sresource
|
struct Sresource
|
||||||
{
|
{
|
||||||
@ -54,6 +55,7 @@ struct DefInfo //information from def declaration
|
|||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
int bytes [42];
|
int bytes [42];
|
||||||
|
CSemiDefHandler * handler;
|
||||||
};
|
};
|
||||||
struct Location
|
struct Location
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ void CMapHandler::init()
|
|||||||
|
|
||||||
for(int i=0; i<partialHide->ourImages.size(); ++i)
|
for(int i=0; i<partialHide->ourImages.size(); ++i)
|
||||||
{
|
{
|
||||||
//CSDL_Ext::alphaTransform(partialHide->ourImages[i].bitmap);
|
CSDL_Ext::alphaTransform(partialHide->ourImages[i].bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
visibility.resize(reader->map.width+8);
|
visibility.resize(reader->map.width+8);
|
||||||
@ -274,7 +274,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level)
|
|||||||
SDL_BlitSurface(terrainBitmap[bx+x][by+y],NULL,su,sr);
|
SDL_BlitSurface(terrainBitmap[bx+x][by+y],NULL,su,sr);
|
||||||
if( bx+x>3 && by+y>3 && bx+x<visibility.size()-3 && by+y<visibility[0].size()-3 && !visibility[bx+x][by+y])
|
if( bx+x>3 && by+y>3 && bx+x<visibility.size()-3 && by+y<visibility[0].size()-3 && !visibility[bx+x][by+y])
|
||||||
{
|
{
|
||||||
SDL_Surface * hide = CSDL_Ext::alphaTransform(getVisBitmap(bx+x, by+y, visibility));
|
SDL_Surface * hide = getVisBitmap(bx+x, by+y, visibility);
|
||||||
Uint32 pompom[32][32];
|
Uint32 pompom[32][32];
|
||||||
for(int i=0; i<hide->w; ++i)
|
for(int i=0; i<hide->w; ++i)
|
||||||
{
|
{
|
||||||
@ -283,16 +283,17 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level)
|
|||||||
pompom[i][j] = 0xffffffff - (CSDL_Ext::SDL_GetPixel(hide, i, j, true) & 0xff000000);
|
pompom[i][j] = 0xffffffff - (CSDL_Ext::SDL_GetPixel(hide, i, j, true) & 0xff000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hide = SDL_ConvertSurface(hide, su->format, SDL_SWSURFACE);
|
SDL_Surface * hide2 = SDL_ConvertSurface(hide, su->format, SDL_SWSURFACE);
|
||||||
for(int i=0; i<hide->w; ++i)
|
for(int i=0; i<hide2->w; ++i)
|
||||||
{
|
{
|
||||||
for(int j=0; j<hide->h; ++j)
|
for(int j=0; j<hide2->h; ++j)
|
||||||
{
|
{
|
||||||
Uint32 * place = (Uint32*)( (Uint8*)hide->pixels + j * hide->pitch + i * hide->format->BytesPerPixel);
|
Uint32 * place = (Uint32*)( (Uint8*)hide2->pixels + j * hide2->pitch + i * hide2->format->BytesPerPixel);
|
||||||
(*place)&=pompom[i][j];
|
(*place)&=pompom[i][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_BlitSurface(hide, NULL, su, sr);
|
SDL_BlitSurface(hide2, NULL, su, sr);
|
||||||
|
SDL_FreeSurface(hide2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -300,7 +301,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level)
|
|||||||
SDL_BlitSurface(undTerrainBitmap[bx+x][by+y],NULL,su,sr);
|
SDL_BlitSurface(undTerrainBitmap[bx+x][by+y],NULL,su,sr);
|
||||||
if( bx+x>3 && by+y>3 && bx+x<undVisibility.size()-3 && by+y<undVisibility[0].size()-3 && !undVisibility[bx+x][by+y])
|
if( bx+x>3 && by+y>3 && bx+x<undVisibility.size()-3 && by+y<undVisibility[0].size()-3 && !undVisibility[bx+x][by+y])
|
||||||
{
|
{
|
||||||
SDL_Surface * hide = CSDL_Ext::alphaTransform(getVisBitmap(bx+x, by+y, undVisibility));
|
SDL_Surface * hide = getVisBitmap(bx+x, by+y, undVisibility);
|
||||||
Uint32 pompom[32][32];
|
Uint32 pompom[32][32];
|
||||||
for(int i=0; i<hide->w; ++i)
|
for(int i=0; i<hide->w; ++i)
|
||||||
{
|
{
|
||||||
@ -309,16 +310,17 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level)
|
|||||||
pompom[i][j] = 0xffffffff - (CSDL_Ext::SDL_GetPixel(hide, i, j, true) & 0xff000000);
|
pompom[i][j] = 0xffffffff - (CSDL_Ext::SDL_GetPixel(hide, i, j, true) & 0xff000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hide = SDL_ConvertSurface(hide, su->format, SDL_SWSURFACE);
|
SDL_Surface * hide2 = SDL_ConvertSurface(hide, su->format, SDL_SWSURFACE);
|
||||||
for(int i=0; i<hide->w; ++i)
|
for(int i=0; i<hide2->w; ++i)
|
||||||
{
|
{
|
||||||
for(int j=0; j<hide->h; ++j)
|
for(int j=0; j<hide2->h; ++j)
|
||||||
{
|
{
|
||||||
Uint32 * place = (Uint32*)( (Uint8*)hide->pixels + j * hide->pitch + i * hide->format->BytesPerPixel);
|
Uint32 * place = (Uint32*)( (Uint8*)hide2->pixels + j * hide2->pitch + i * hide2->format->BytesPerPixel);
|
||||||
(*place)&=pompom[i][j];
|
(*place)&=pompom[i][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_BlitSurface(hide, NULL, su, sr);
|
SDL_BlitSurface(hide2, NULL, su, sr);
|
||||||
|
SDL_FreeSurface(hide2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete sr;
|
delete sr;
|
||||||
@ -338,7 +340,7 @@ SDL_Surface * CMapHandler::undTerrBitmap(int x, int y)
|
|||||||
return undTerrainBitmap[x+4][y+4];
|
return undTerrainBitmap[x+4][y+4];
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface * CMapHandler::getVisBitmap(int x, int y, std::vector< std::vector<bool> > & visibility)
|
SDL_Surface * CMapHandler::getVisBitmap(int x, int y, std::vector< std::vector<char> > & visibility)
|
||||||
{
|
{
|
||||||
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && !visibility[x+1][y+1] && !visibility[x+1][y-1] && !visibility[x-1][y+1])
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && !visibility[x+1][y+1] && !visibility[x+1][y-1] && !visibility[x-1][y+1])
|
||||||
{
|
{
|
||||||
@ -530,3 +532,13 @@ SDL_Surface * CMapHandler::getVisBitmap(int x, int y, std::vector< std::vector<b
|
|||||||
}
|
}
|
||||||
return fullHide->ourImages[0].bitmap; //this case should never happen, but it is better to hide too much than reveal it....
|
return fullHide->ourImages[0].bitmap; //this case should never happen, but it is better to hide too much than reveal it....
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char & CMapHandler::visAccess(int x, int y)
|
||||||
|
{
|
||||||
|
return visibility[x+4][y+4];
|
||||||
|
}
|
||||||
|
|
||||||
|
char & CMapHandler::undVisAccess(int x, int y)
|
||||||
|
{
|
||||||
|
return undVisibility[x+4][y+4];
|
||||||
|
}
|
||||||
|
@ -17,10 +17,12 @@ public:
|
|||||||
CSemiDefHandler * fullHide;
|
CSemiDefHandler * fullHide;
|
||||||
CSemiDefHandler * partialHide;
|
CSemiDefHandler * partialHide;
|
||||||
|
|
||||||
std::vector< std::vector<bool> > visibility; //true means that pointed place is visible
|
std::vector< std::vector<char> > visibility; //true means that pointed place is visible
|
||||||
std::vector< std::vector<bool> > undVisibility; //true means that pointed place is visible
|
std::vector< std::vector<char> > undVisibility; //true means that pointed place is visible
|
||||||
|
char & visAccess(int x, int y);
|
||||||
|
char & undVisAccess(int x, int y);
|
||||||
SDL_Surface mirrorImage(SDL_Surface *src); //what is this??
|
SDL_Surface mirrorImage(SDL_Surface *src); //what is this??
|
||||||
SDL_Surface * getVisBitmap(int x, int y, std::vector< std::vector<bool> > & visibility);
|
SDL_Surface * getVisBitmap(int x, int y, std::vector< std::vector<char> > & visibility);
|
||||||
void init();
|
void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
6
nodrze.h
6
nodrze.h
@ -1,5 +1,5 @@
|
|||||||
#ifndef NODRZE
|
#ifndef _NODRZE_H
|
||||||
#define NODRZE
|
#define _NODRZE_H
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#ifndef LOGUJ
|
#ifndef LOGUJ
|
||||||
@ -873,4 +873,4 @@ template <typename T> void nodrze<T>::pre(std::ostream & strum, wezel<T> * wsk)
|
|||||||
if (wsk->prawy != NIL)
|
if (wsk->prawy != NIL)
|
||||||
pre(strum,wsk->prawy);
|
pre(strum,wsk->prawy);
|
||||||
};
|
};
|
||||||
#endif
|
#endif //_NODRZE_H
|
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef TIMEHANDLER_H
|
||||||
|
#define TIMEHANDLER_H
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
class timeHandler
|
class timeHandler
|
||||||
{
|
{
|
||||||
@ -9,3 +12,5 @@ public:
|
|||||||
void remember(){mem=clock();};
|
void remember(){mem=clock();};
|
||||||
long memDif(){return mem-clock();};
|
long memDif(){return mem-clock();};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif //TIMEHANDLER_H
|
Reference in New Issue
Block a user