1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#include <SDL.h>
#include "EngineClass.h"
void KeyInput(SDL_Rect &oSet)
{
Uint8 *keyStates = SDL_GetKeyState(NULL);
if(keyStates[SDLK_w])
{
oSet.y -= 1;
}
if(keyStates[SDLK_a])
{
oSet.x -= 1;
}
if(keyStates[SDLK_s])
{
oSet.y += 1;
}
if(keyStates[SDLK_d])
{
oSet.x += 1;
}
}
void ImageHandling(SDL_Rect &P, SDL_Surface &IMG)
{
SDL_Rect offset;
SDL_Surface *image;
image = SDL_LoadBMP("Test.bmp");
Uint32 colorkey = SDL_MapRGB(image->format, 255, 0, 255);
SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
offset.x = 10;
offset.y = 10;
}
void CreateWindow(SDL_Surface &S)
{
SDL_WM_SetCaption("This is a title, if you dont like it than fuck you", NULL);
SDL_Surface *Screen;
Screen = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE);
}
int main(int argc, char *argv[])
{
bool running = true;
SDL_Event occur;
SDL_Surface mainScreen;
SDL_Rect Position;
SDL_Surface image;
CreateWindow(mainScreen);
ImageHandling(Position, image);
KeyInput(Position);
if(SDL_Init(SDL_INIT_EVERYTHING) == -1)
{
running = false;
}
if(&mainScreen == NULL)
{
running = false;
}
while(running == true)
{
SDL_PollEvent(&occur);
if(occur.type == SDL_QUIT)
{
running = false;
}
KeyInput(Position);
SDL_FillRect(&mainScreen, NULL, 0);
SDL_BlitSurface(&image, NULL, &mainScreen, &Position);
SDL_Flip(&mainScreen);
}
SDL_Quit();
return 0;
}
|