Search Results

Search found 3 results on 1 pages for 'user36324'.

Page 1/1 | 1 

  • Brief pause after keypress

    - by user36324
    After i press and hold the key it goes forward once then pauses for a second or less then goes forward on forever. My problem is the brief pause I cant locate the issue. Thanks for your help. while(game){ while (SDL_PollEvent(&e)){ mainChar.manageEvents(e); } background.renderChar(); mainChar.renderChar(); SDL_RenderPresent(ren); } void Character::manageEvents(SDL_Event event) { switch(event.type){ case SDL_KEYDOWN: KEYS[event.key.keysym.sym] = true; printf("true"); handleInput(); break; case SDL_KEYUP: KEYS[event.key.keysym.sym] = false; printf("false"); break; default: break; } } void Character::handleInput() { if(KEYS[SDLK_a]) { dst.x--; } if(KEYS[SDLK_d]) { dst.x++; } if(KEYS[SDLK_w]) { dst.y++; } if(KEYS[SDLK_s]) { dst.y--; } }

    Read the article

  • Is this the most effect simple way to display a moving image? SDL2

    - by user36324
    I've looked around for tutorials on SDL2, but there isnt many so I am curious i was messing around and is this an effective way to move an image. One problem is that it drags along the image to where it moves. #include "SDL.h" #include "SDL_image.h" int main(int argc, char* argv[]) { bool exit = false; SDL_Init(SDL_INIT_EVERYTHING); SDL_Window *win = SDL_CreateWindow("Hello World!", 100, 100, 640, 480, SDL_WINDOW_SHOWN); SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); SDL_Surface *png = IMG_Load("character.png"); SDL_Rect src; src.x = 0; src.y = 0; src.w = 161; src.h = 159; SDL_Rect dest; dest.x = 50; dest.y = 50; dest.w = 161; dest.h = 159; SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, png); SDL_FreeSurface(png); while(exit==false){ dest.x++; SDL_RenderClear(ren); SDL_RenderCopy(ren, tex, &src, &dest); SDL_RenderPresent(ren); } SDL_Delay(5000); SDL_DestroyTexture(tex); SDL_DestroyRenderer(ren); SDL_DestroyWindow(win); SDL_Quit(); }

    Read the article

  • Getting an object from a 2d array inside of a class

    - by user36324
    I am have a class file that contains two classes, platform and platforms. platform holds the single platform information, and platforms has an 2d array of platforms. Im trying to render all of them in a for loop but it is not working. If you could kindly help me i would greatly appreciate. void Platforms::setUp() { for(int x = 0; x < tilesW; x++){ for(int y = 0; y < tilesH; y++){ Platform tempPlat(x,y,true,renderer,filename,tileSize/scaleW,tileSize/scaleH); platArray[x][y] = tempPlat; } } } void Platforms::show() { for(int x = 0; x < tilesW; x++){ for(int y = 0; y < tilesH; y++){ platArray[x][y].show(renderer,scaleW,scaleH); } } }

    Read the article

1