Jump to content

  • Log In with Google      Sign In   
  • Create Account


spooderw

Member Since 03 Dec 2011
Offline Last Active Jul 28 2012 01:20 AM
-----

Posts I've Made

In Topic: Eris - Online Open World Tower Defense FPS

22 July 2012 - 04:16 PM

This game is Sweet! I love the cronogun! It is so awesome!! Nice job!


Thanks!

In Topic: Current best open source 3D rendering engine?

02 April 2012 - 09:12 PM

I've heard very good things about Ogre. It's mentioned in a few books I've read and I believe Naughty Dog uses it...never touched it myself.

In Topic: c++ SDL Button class

02 April 2012 - 09:00 PM

if(SDL_PollEvent(&event)){

   if(event.type == SDL_QUIT){running = false; SDL_Quit(); break;}
   if(event.type == SDL_KEYDOWN){
		if(event.key.keysym.sym == SDLK_ESCAPE){running = false; SDL_Quit(); break;}
   }
   if(ExitButton.CheckEvents()){
		running = false;
		SDL_Quit();
		break;
   }


If I am correct, this should be contained in a while loop, because if more than one event occurs in a single iteration of your game loop, you will only catch one of the events, which will not only result in missed input, but I believe it leaks memory and causes major slowdown.


Also, you should not have another event handler inside your button, you should pass in a bool that checks if the mouse is pressed.

It should be something like this:

main.cpp:
bool leftClick = false;
while(SDL_PollEvent(&event)){

   if(event.type == SDL_QUIT){running = false; SDL_Quit(); break;}
   if(event.type == SDL_KEYDOWN){
		if(event.key.keysym.sym == SDLK_ESCAPE){running = false; SDL_Quit(); break;}
	if(event.type == SDL_MOUSEBUTTONDOWN){
		 if(event.button.button == SDL_BUTTON_LEFT){
		  leftClick = true;}
	  if(event.type == SDL_MOUSEBUTTONUP){
		 if(event.button.button == SDL_BUTTON_LEFT){
		  leftClick = false;}
}
   if(ExitButton.CheckEvents(leftClick)){
		running = false;
		SDL_Quit();
		break;
   }


newbutton.cpp:
bool NewButton::CheckEvents(bool leftMousePressed){
	 if(leftMousePressed)
	 {
		if((MouseX > ButtonRect.x) && (MouseY > ButtonRect.y) && (MouseX < (ButtonRect.x + ButtonRect.w)) && (MouseY < (ButtonRect.y + ButtonRect.h))){
		 return true;
		}
	 }
   }
  }
}

In Topic: A simple png library for use in a c++ win32 tile-based game engine

02 April 2012 - 08:50 PM

SDL_image

In Topic: Help! Trying to create classic SNES sound.

01 April 2012 - 01:34 PM

Check out bfxr.

PARTNERS