EDIT: Woops! I'm an idiot xP this is fixed now... And I forgot to declare a P1 variable, or how it's called >.<
Well, I made this class and for some reason it ain't working o.o I blame the engine, 'cause I havn't got any of my includes working with it, but I've got no proof it's the engine xP
NOTE: I'm about to move my globals into classes, so sorry for the mess xP
Anyway, I've got this class
And it's giving me these errors, a load of themCode:class P1 { public: P1(); ~P1(); const float x; float y; float speed; };
Well here's the code that worked when I used globals instead of classesCode:error C2143: syntax error : missing ';' before '.' and warning C4832: token '.' is illegal after UDT 'P1' objects.h(5) : see declaration of 'P1' error C2275: 'P1' : illegal use of this type as an expression objects.h(5) : see declaration of 'P1'
Thanks in advance!Code:#include "objects.h" #include "hge.h" #include "hgeresource.h" #include "hgesprite.h" HGE *hge = 0; //resource managers hgeResourceManager* myRes; //sprites hgeSprite* ballSprite; hgeSprite* platformP1; hgeSprite* platformP2; //ball variables float ballX = 400, ballY = 300; float ballSpeed = 90; bool FrameFunc(){ float dt = hge->Timer_GetDelta(); if(hge->Input_GetKeyState(HGEK_ESCAPE)) return true; //movement controls //Player 1 if(hge->Input_GetKeyState(HGEK_W)) P1.y -= P1.speed*dt; if(hge->Input_GetKeyState(HGEK_S)) P1.y += P1.speed*dt; //player 2 if(hge->Input_GetKeyState(HGEK_UP)) P2.y -= P2.speed*dt; if(hge->Input_GetKeyState(HGEK_DOWN)) P2.y += P2.speed*dt; return false; } bool RenderFunc(){ hge->Gfx_BeginScene(); hge->Gfx_Clear(0); ballSprite->RenderStretch(ballX, ballY, ballX + 16, ballY + 16); //Render platformP1 platformP1->SetColor(0xFF0000FF); platformP1->RenderStretch(P1.x, P1.y, P1.x + 10, P1.y + 64); //Render platformP2 platformP2->SetColor(0xFFFF0000); platformP2->RenderStretch(P2.x, P2.y, P2.x + 10, P2.y + 64); hge->Gfx_EndScene(); return false; } int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int){ hge = hgeCreate(HGE_VERSION); hge->System_SetState(HGE_LOGFILE, "LOGFILE.log"); hge->System_SetState(HGE_FRAMEFUNC, FrameFunc); hge->System_SetState(HGE_RENDERFUNC, RenderFunc); hge->System_SetState(HGE_TITLE, "HGE application"); hge->System_SetState(HGE_WINDOWED, true); hge->System_SetState(HGE_SCREENWIDTH, 800); hge->System_SetState(HGE_SCREENHEIGHT, 600); hge->System_SetState(HGE_SCREENBPP, 32); if(hge->System_Initiate()){ myRes = new hgeResourceManager("resource.res"); ballSprite = myRes->GetSprite("ballSprite"); platformP1 = myRes->GetSprite("platformSprite"); platformP2 = myRes->GetSprite("platformSprite"); hge->System_Start(); delete myRes; } else{ MessageBox(NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL); } hge->System_Shutdown(); hge->Release(); return 0; }



LinkBack URL
About LinkBacks


