YupEE1 | Дата: Четверг, 25 Августа 2011, 22:41 | Сообщение # 1 |
был не раз
Сейчас нет на сайте
| Форумчане пожалуйста подскажите и укажите на мои ошибки. Начал осваивать разработку игр, делаю платформер на HGE 181 - что я не так сделал при создании уровня? сырец: level1.h Code #include "includes.h"
HGE *hge;
HTEXTURE metal_wall, lab_ceil, out_wall, lab_wall, lab_floor, empty_tex, bgt, ext;
hgeSprite //ceiling----------------------- *ceiling, //metal wall----------------------- *mw, //out wall------------------------ *out, //lab wall---------------------------------------- *lw, //background tiles-------------------------------------- *bgtf, //floor-------------------- *flr, //exit tiles-------------------------------------- *xit, //empty---------------------- *empty;
const static int TILE_SIZE_X = 32;//tile size const static int TILE_SIZE_Y = 32;
int const s = SCREEN_WIDTH/TILE_SIZE_X; int const c = SCREEN_HEIGHT/TILE_SIZE_Y;
int level[s][c] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 0,0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1, 0,0,0,1,2,0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2, 0,0,0,1,2,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5,2, 0,0,0,1,2,5,6,6,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6,6,6,6,6,8, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,2,2,2,2,2,2,2,5,2, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,2,2,2,2,2,2,2,5,2, };
bool RenderFunc() { int i,j; hge->Gfx_BeginScene(); hge->Gfx_Clear(0);
for(i=0; i<s; i++) { for(j=0; j<c; j++) { if (level[s][c]==0) { empty->Render(0,1); } if (level[s][c]==1) { out->Render(0,1); } //if (level[s][c]==2) //{ // mw->RenderEx(i*32,j*32,0,1); //} //if (level[s][c]==4) //{ // ceiling->RenderEx(i*32,j*32,0,1); //} //if (level[s][c]==5) //{ // lw->RenderEx(i*32,j*32,0,1); //} //if (level[s][c]==6) //{ // bgtf->RenderEx(i*32,j*32,0,1); //} //if (level[s][c]==7) //{ // flr->RenderEx(i*32,j*32,0,1); //} //if (level[s][c]==8) //{ // xit->RenderEx(i*32,j*32,0,1); //} } }
hge->Gfx_EndScene(); return false; }
bool FrameFunc() { if(hge->Input_GetKeyState(HGEK_ESCAPE))return true; return false; }
int LevelMain() { if(hge->System_Initiate()) { empty_tex = hge->Texture_Load("resources/tiles/32/empty.png"); metal_wall=hge->Texture_Load("resources/tiles/32/metal.png"); lab_ceil=hge->Texture_Load("resources/tiles/32/ceil.png"); out_wall=hge->Texture_Load("resources/tiles/32/out.png"); lab_wall=hge->Texture_Load("resources/tiles/32/wall.png"); lab_floor=hge->Texture_Load("resources/tiles/32/floor.png"); bgt=hge->Texture_Load("resources/tiles/32/bg.png"); ext=hge->Texture_Load("resources/tiles/32/exit.png"); if(!ext) { MessageBox(NULL, "Can't load BG2.PNG ", "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL); hge->System_Shutdown(); hge->Release(); return 0; } //backgrounds tiles-------------------------------- bgtf=new hgeSprite(bgt, 0, 0, 32, 32); xit=new hgeSprite(ext, 0, 0, 32, 32); mw=new hgeSprite(metal_wall, 0, 0, 32, 32); out=new hgeSprite(out_wall, 0, 0, 32, 32); ceiling=new hgeSprite(lab_ceil, 0, 0, 32, 32); lw=new hgeSprite(lab_wall, 0, 0, 32, 32); flr=new hgeSprite(lab_floor, 0, 0, 32, 32); empty=new hgeSprite(empty_tex, 0, 0, 32, 32);
hge->System_Start();
delete bgtf; delete xit; delete mw; delete out; delete ceiling; delete lw; delete flr; delete empty;
hge->Texture_Free(bgt); hge->Texture_Free(ext); hge->Texture_Free(metal_wall); hge->Texture_Free(out_wall); hge->Texture_Free(lab_ceil); hge->Texture_Free(lab_wall); hge->Texture_Free(lab_floor); hge->Texture_Free(empty_tex); } return 0; } main.cpp Code #include "level1.h"
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { hge = hgeCreate(HGE_VERSION); hge->System_SetState(HGE_FRAMEFUNC, FrameFunc); hge->System_SetState(HGE_RENDERFUNC, RenderFunc); hge->System_SetState(HGE_TITLE, "AIP's Run!"); hge->System_SetState(HGE_WINDOWED, true); hge->System_SetState(HGE_USESOUND, false); hge->System_SetState(HGE_SCREENWIDTH, SCREEN_WIDTH); hge->System_SetState(HGE_SCREENHEIGHT, SCREEN_HEIGHT); hge->System_SetState(HGE_SCREENBPP, 32);
LevelMain();
hge->System_Shutdown(); hge->Release(); return 0; } в includes.h необходимые инклуды.
|
|
| |