S
So Sollte es irgendjemanden interressieren...
Das ist der Fertige Quelltext wie es auch funktioniert:
#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
int main () {
int puffer_a; // spalte 1
int a_a = 0;
int b_a = 255;
int c_a = 255;
int puffer_b; // spalte 2
int a_b = 0;
int b_b = 0;
int c_b = 255;
// SPALTE C NICHT BENÖTIGT DA IMMER NUR 0
Uint8 *keys = SDL_GetKeyState(NULL);
SDL_Event event;
SDL_Surface *screen;
SDL_INIT_VIDEO;
screen = SDL_SetVideoMode ( 1920, 1080, 32, SDL_HWSURFACE | SDL_NOFRAME);
atexit(SDL_Quit);
SDL_Rect a, b , c;
a.x = 0;
a.y = 0;
a.w = 1920;
a.h = 360;
b.x = 0;
b.y = 360;
b.w = 1920;
b.h = 360;
c.x = 0;
c.y = 720;
c.w = 1920;
c.h = 360;
SDL_FillRect(screen, &a, SDL_MapRGB(screen->format,a_a, a_b, 0));
SDL_FillRect(screen, &b, SDL_MapRGB(screen->format, b_a, b_b, 0));
SDL_FillRect(screen, &c , SDL_MapRGB(screen->format, c_a, c_b, 0));
SDL_UpdateRect(screen, 0, 0, 0, 0);
while(1)
{
if(keys[SDLK_q])
{
exit(1);
}
while (SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_QUIT:
{
exit(0);
break;
}
case SDL_KEYDOWN:
{
if(keys[SDLK_w])
{
puffer_a = a_a;
a_a = b_a;
b_a = c_a;
c_a = puffer_a;
puffer_b = a_b;
a_b = b_b;
b_b = c_b;
c_b = puffer_b;
SDL_FillRect(screen, &a, SDL_MapRGB(screen->format,a_a, a_b, 0));
SDL_FillRect(screen, &b, SDL_MapRGB(screen->format, b_a, b_b, 0));
SDL_FillRect(screen, &c , SDL_MapRGB(screen->format, c_a, c_b, 0));
SDL_UpdateRect(screen, 0, 0, 0, 0);
}
}
}
}
}
}
Danke an alle die mitgeholfen haben!!!