My problem is that I wish to use a single mouse click (or key press) to "turn on" a set of conditions then I will "turn off" the conditions when a different requirement is met. Alas! Every time I release the mouse button the bool reverts to its initialized state. I do not want it to do that and I do not want to set it to "toggle" on and off with each mouse click either. Here are some examples of what has failed: // first, simple failure bool start = false; if (dbMouseClick()) start = true; // another unsuccessful …

Member Avatar
Member Avatar
+0 forum 1

Hi! The keypresses in my new project does not seem to be registered. I've never had this issue before and I don't think it is SDL:s fault this time. Here is the code in main: #include <cstdlib> #include <iostream> #include <SDL.h> #include "playertank.h" int main ( int argc, char** argv ) { SDL_Init(SDL_INIT_VIDEO); SDL_Surface* screen = SDL_SetVideoMode(720, 480, 24, SDL_HWSURFACE|SDL_DOUBLEBUF); SDL_Surface* background = SDL_LoadBMP("Grass.bmp"); SDL_Surface* tank_body = SDL_LoadBMP("TankBody.bmp"); PlayerTank player1(200,200,32,32,10); SDL_SetColorKey( tank_body, SDL_SRCCOLORKEY, SDL_MapRGB(screen->format, 0, 255, 255) ); bool quit = false; while(!quit) { //Controls player1.move(SDL_GetKeyState(NULL)); //logics //draw SDL_BlitSurface(background, NULL,screen,NULL); SDL_BlitSurface(tank_body,NULL,screen,player1.getPos()); SDL_Rect* copy = player1.getPos(); std::cout<<copy->y<<std::endl; SDL_Delay(100); SDL_Flip(screen); } atexit(SDL_Quit); …

Member Avatar
Member Avatar
+0 forum 4

The End.