smartino969
Grünschnabel
Der Compiler zeigd mir an, dass in der Datei iterator ein ';' fehlt aber ich habe dise Datei nicht gemacht oder verändert.
Darum Freue ich mich auf eine Antwort, denn ich möchte an meinem Projekt über SDL weiter arbeiten.
main.cpp
framemork.h
framework.cpp
Darum Freue ich mich auf eine Antwort, denn ich möchte an meinem Projekt über SDL weiter arbeiten.

main.cpp
Code:
#include "sdl.h"
#include "framework.h"
#include <string>
#include <iostream>
using namespace std;
SDL_Surface *load_image(string filename_str);
void *set_image(int x, int y, SDL_Surface* src, SDL_Surface* dst);
int main(int argc, char* args[])
{
SDL_Surface *image = NULL;
SDL_Surface *image2 = NULL;
bool run = true;
framework Framework;
Framework.Init(1280, 720, 32, false);
//Screen wird Definirt
SDL_WM_SetCaption("Hallo", NULL);
image = load_image("hallo.bmp");
set_image(100, 100, image, Framework.Screen());
Framework.Flip();
Framework.Clear();
SDL_Delay(2000);
while (run == true)
{
if (Framework.keyDown(SDL_QUIT) == 1)
{
run = 0;
}
}
Framework.Quit();
return 0;
}
SDL_Surface *load_image(string filename_str)
{
SDL_Surface *old_image = NULL;
SDL_Surface *optionmizedImage = NULL;
old_image = SDL_LoadBMP(filename_str.c_str());
if (old_image != NULL)
{
optionmizedImage = SDL_DisplayFormat(old_image);
SDL_FreeSurface(old_image);
}
else
{
cout << "Bild konte nicht Kombilirt werden" << endl;
}
return optionmizedImage;
}
void *set_image(int x, int y, SDL_Surface* src, SDL_Surface* dst)
{
SDL_Rect position;
position.x = x;
position.y = y;
SDL_BlitSurface(src, NULL, dst, &position);
return 0;
}
framemork.h
Code:
#ifndef FRAMEWORK_H
#define FRAMEWORK_H
#include "framework.h"
#include "sdl.h"
#include <iostream>
using namespace std;
class framework
{
public:
framework();
virtual ~framework();
bool Init(int ScreenWidth, int ScreenHeight, int ColorDepth, bool FullScreen);
void Quit();
void Flip();
void Clear();
bool keyDown(int Key_ID);
SDL_Surface* Screen() { return pScreen; }
private:
char button;
SDL_Surface* pScreen;
}
#endif
framework.cpp
Code:
#include "framework.h"
#include "sdl.h"
#include <iostream>
#include <string>
using namespace std;
framework::framework(){
button = '0';
}
bool framework::Init(int ScreenWidth, int ScreenHeight, int ColorDepth, bool FullScreen)
{
//Prüfen ob Initalisieren ghet
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1)
{
cout << "Die SDL Konnte nicht initalisiert werden!" << endl;
cout << "Fehlermeldung: " << SDL_GetError() << endl;
Quit();
return (false);
}
// Fulscrinn erlmiteln
if (FullScreen = true)
{
pScreen = SDL_SetVideoMode(ScreenWidth, ScreenHeight, ColorDepth, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN);
}
else
{
pScreen = SDL_SetVideoMode(ScreenWidth, ScreenHeight, ColorDepth, SDL_HWSURFACE | SDL_DOUBLEBUF);
}
//Prüfen ob alles Funktioniert hatt
if (pScreen == NULL)
{
cout << "Videomodus konnte nicht gestzt werden!" << endl;
cout << "Fehlermeldung. " << SDL_GetError() << endl;
Quit();
return(false);
}
return(true);
}
void framework::Quit()
{
//SDL Beenden
SDL_Quit();
}
void framework::Flip()
{
SDL_Flip(pScreen);
}
void framework::Clear()
{
// Buffer (Surface) mit Hintergrundfrabe füllen
SDL_FillRect(pScreen, NULL, SDL_MapRGB(pScreen->format, 0, 0, 0));
}
bool framework::keyDown(int Key_ID)
{
// Prüfen ob die Taste Gedrückt ist
SDL_Event event;
SDL_PollEvent(&event);
if (event.type == Key_ID)
{
return true;
}
else
{
return false;
}
}