0 Members and 1 Guest are viewing this topic.
#include <os.h>#include <SDL/SDL.h>#define WIDTH 320#define HALF_WIDTH 160 // WIDTH / 2#define HEIGHT 240#define HALF_HEIGHT 120 // HEIGHT / 2#define SCALE_FACTOR 6#define FACTOR 128 //(2<<(SCALE_FACTOR+1))#define SPEED 4int main(void) { SDL_Surface *screen; SDL_Rect pixelRect, clearRect; int Xib; short X0 = 0, Y0 = 0; clearRect.x = 0; clearRect.y = HALF_HEIGHT; clearRect.w = WIDTH; clearRect.h = 1; pixelRect.h = (pixelRect.w = 2); SDL_Init(SDL_INIT_VIDEO); screen = SDL_SetVideoMode(WIDTH, HEIGHT, is_cx?16:8, SDL_SWSURFACE); while(!isKeyPressed(KEY_NSPIRE_ESC)) { for(pixelRect.x = 0; pixelRect.x < WIDTH; pixelRect.x += 2) { Xib = (pixelRect.x - HALF_WIDTH) * HEIGHT; for(pixelRect.y = HALF_HEIGHT; pixelRect.y < HEIGHT; pixelRect.y += 2) { if( ( (( (WIDTH - (Xib / pixelRect.y) + X0) >> SCALE_FACTOR) & 1) + (( (2 * (HEIGHT - pixelRect.y) + Y0) >> SCALE_FACTOR) & 1 ) ) & 1) { SDL_FillRect(screen, &pixelRect, (Uint32)0); } } } SDL_FillRect(screen, &clearRect, (Uint32)0); SDL_Flip(screen); SDL_FillRect(screen, NULL, (Uint32)0xffffffff); if(isKeyPressed(KEY_NSPIRE_LEFT)) { X0 = (FACTOR + X0 - SPEED) % FACTOR; } if(isKeyPressed(KEY_NSPIRE_RIGHT)) { X0 = (FACTOR + X0 + SPEED) % FACTOR; } if(isKeyPressed(KEY_NSPIRE_UP)) { Y0 = (FACTOR + Y0 - SPEED) % FACTOR; } if(isKeyPressed(KEY_NSPIRE_DOWN)) { Y0 = (FACTOR + Y0 + SPEED) % FACTOR; } } SDL_FreeSurface(screen); SDL_Quit(); return 0;}
code in spoiler
Je suis tout à fait d'accord, mais english spoken here
Quote from: Lionel Debroux on September 30, 2012, 11:13:11 amJe suis tout à fait d'accord, mais english spoken here Ok Hayleia, sorry ^^