• Content count

  • Joined

  • Last visited

Community Reputation

109 Neutral

About DillonBroadus

  • Rank
  1. My brain. Wowowowowowowowowow
  2. The Shins. All day. Erry day.
  3. Problems with SDL Input

    Well thank you very much for that tip on the SDL_EnableKeyRepeat. Here's that player::show() function. See anything strange? [source lang="cpp"]void Player::Show() { character = LoadImage(direction); Blit(x, y, character, screen); }[/source]
  4. Problems with SDL Input

    I have made it to where it only polls once and just passes the event along. However, the input still isn't continuous and in fact it has some weird effect where when one key is pressed, instead of moving the character a continuous amount of units in that certain direction, it goes 5 units in the direction while the key is down and goes 5 again when the key is up. And also, I figure it may be a memory leak caused by maybe pointers or something, however, after a quick glance, it doesn't appear that anything funky is being done with pointers. I would show more code, however, not knowing where the problem may be, I'm not sure what portion of the code to show. However, these are the image functions which use more pointers than any other part: [source lang="cpp"]SDL_Surface * LoadImage(std::string path) { SDL_Surface * loadedImage = NULL; SDL_Surface * optimizedImage = NULL; loadedImage = IMG_Load( path.c_str() ); if(loadedImage != NULL) { optimizedImage = SDL_DisplayFormat(loadedImage); SDL_FreeSurface(loadedImage); if(optimizedImage != NULL) { Uint32 colorkey = SDL_MapRGB(optimizedImage->format, 111, 111, 111); SDL_SetColorKey(optimizedImage, SDL_SRCCOLORKEY, colorkey); } } return optimizedImage; } void Blit(int x, int y, SDL_Surface* source, SDL_Surface* destination) { Rect coords; coords.x = x; coords.y = y; SDL_BlitSurface( source, NULL, destination, &coords ); } void ColorRect(SDL_Surface* surface, int x, int y, int z) { SDL_FillRect(surface, 0, SDL_MapRGB(surface->format, x, y, z)); } void Update(SDL_Surface* surface) { SDL_Flip(surface); } [/source]
  5. Problems with SDL Input

    Ah, well this is very strange. Polling the event inside the function or outside the function provides no differences and the program still continuously amasses a large quantity of memory it doesn't need. I'm not sure why this program works perfectly when everything's in the same source file and yet it starts acting funky when classes and multiple source files are involved.
  6. Problems with SDL Input

    So, I've been working on a bit of game code on and off and I had the simplest operations working nicely, those being image loading and blitting, as well as some keyboard input to move a dummy character around. What I sometimes like to do is, while developing something, I'll turn my main.cpp file into a sandbox, until the stuff I'm doing works correctly and then I'll take the code, split it up and organize it into nice little files. Well, after such an organization, I found that the keyboard input was no longer continuous, even though my switch case is supposed to handle SDL_KEYDOWN and SDL_KEYUP. I've tried moving a bunch of things around, but I'm not able to get it to work correctly. Anyone have any ideas as to why? game loop: [source lang="cpp"] while (!quit) { SDL_Event event; while(SDL_PollEvent(&event)) { Chronos.GetInput(event); if(event.type == SDL_QUIT) { quit = true; } } //Chronos.Move(); ColorRect(screen, 255, 255, 255); Chronos.Show(); Blit(15, 15, img, screen); Update(screen); }[/source] Chronos.GetInput(): [source lang="cpp"]void Player::GetInput(SDL_Event event) { SDL_PollEvent(&event); switch (event.type) { case SDL_KEYDOWN: switch(event.key.keysym.sym) { case SDLK_UP: { y -= 5; direction = FACEUP; break; } case SDLK_DOWN: { y += 5; direction = FACEDOWN; break; } case SDLK_RIGHT: { x += 5; direction = FACERIGHT; break; } case SDLK_LEFT: { x -= 5; direction = FACELEFT; break; } break; } case SDL_KEYUP: switch(event.key.keysym.sym) { case SDLK_UP: { y -= 5; direction = FACEUP; break; } case SDLK_RIGHT: { x += 5; direction = FACERIGHT; break; } case SDLK_DOWN: { y += 5; direction = FACEDOWN; break; } case SDLK_LEFT: { x -= 5; direction = FACELEFT; break; } } break; } } [/source] Using Task Manager, I also noticed that my program seems to slowly add more memory to its Working Set getting upwards of 800k KB for no apparent reason and, if unchecked, would keep going. Does anyone know what a possible cause of this could be? I'm sure the former is just a novice mistake, however the latter seems strange and possibly more serious. Thanks in advance for any and all help. It is much appreciated!
  7. The polish coming off, the dream is come and gone, Love's not coming through.