Post by Galahad on Dec 30, 2018 4:02:53 GMT
Did you have a look at SDL,if so what do you think?
#include <SDL.h>
#include <stdio.h>
#include <Windows.h>
#ifdef main
#undef main
#endif
// ----------------------- Defines -------------------------- //
#define PressedLeft 4
#define PressedRight 8
// ----------------------- Globals ------------------------- //
SDL_Event event;
SDL_Surface *SDLScreen;
SDL_Surface *DisplayGFX;
SDL_Surface *SDLSprite;
SDL_Surface *Temp;
SDL_Rect RectSprite,RectSpriteAnimation;
SDL_Rect DisplayGFXSource,SDLScreenDest;
char Input;
int colorkey;
int index;
int GFXTransitionTimer;
// ------------- Function Declerations --------------------- //
void Do_SDL_ESCKey();
void Do_KeyInput();
void Do_HandleHero();
// -------------------------------------------------------- //
int main(int argc, char* args[])
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_WM_SetCaption("The Cowlitz Gamer",NULL);
SDLScreen = SDL_SetVideoMode(256, 240, 0, 0);
DisplayGFX = SDL_LoadBMP("Winners.bmp");
// Source Display Grafics Rectange
DisplayGFXSource.x = 0;
DisplayGFXSource.y = 0;
DisplayGFXSource.w = DisplayGFX->w;
DisplayGFXSource.h = DisplayGFX->h;
// Destination Screen Rectange
SDLScreenDest.x = 0;
SDLScreenDest.y = 0;
SDLScreenDest.w = SDLScreen->w;
SDLScreenDest.h = SDLScreen->h;
// -- Animation Frame From Sprite Sheet-- //
RectSpriteAnimation[0].x = 0;
RectSpriteAnimation[0].y = 0;
RectSpriteAnimation[0].w = 16;
RectSpriteAnimation[0].h = 16;
// --------------------------------------- //
GFXTransitionTimer = 10*1000;
do {
SDL_BlitSurface(DisplayGFX, &DisplayGFXSource, SDLScreen, &SDLScreenDest);
SDL_UpdateRect(SDLScreen, 0, 0, 0, 0);
GFXTransitionTimer--;
}
while (GFXTransitionTimer);
SDL_FreeSurface(DisplayGFX);
DisplayGFX = SDL_LoadBMP("GameIntro.bmp");
Temp = SDL_LoadBMP("PlayerSprites.bmp");
SDLSprite = SDL_DisplayFormat(Temp);
SDL_FreeSurface(Temp);
RectSprite.x = 256/2-8;
RectSprite.y = 192;
colorkey = SDL_MapRGB(SDLScreen->format, 255, 0, 255);
SDL_SetColorKey(SDLSprite, SDL_RLEACCEL | SDL_SRCCOLORKEY, colorkey);
for (;;) {
SDL_BlitSurface(DisplayGFX, &DisplayGFXSource, SDLScreen, &SDLScreenDest);
SDL_BlitSurface(SDLSprite, &RectSpriteAnimation[index], SDLScreen, &RectSprite);
SDL_UpdateRect(SDLScreen,0,0,0,0);
Do_KeyInput();
SDL_Delay(10);
Do_HandleHero();
}
// -------------------------------------------------------- //
SDL_Quit();
return 0;
}
void Do_KeyInput()
{
Uint8 *keys;
keys = SDL_GetKeyState(NULL);
Input = 0;
if (keys[SDLK_RIGHT] == SDL_PRESSED) Input = PressedRight;
if (keys[SDLK_LEFT] == SDL_PRESSED) Input = PressedLeft;
}
void Do_HandleHero()
{
if (Input == PressedLeft) RectSprite.x -= 1;
if (Input == PressedRight) RectSprite.x += 1;
}