
necesito ayuda con limites
Publicado por Roman (2 intervenciones) el 14/03/2016 06:23:19
es un programa el cual dibujo un cuadro con CImg pero no se como hacer q no pase de la pantalla quisiera que me ayudaran por favor
Valora esta pregunta


0
#include <iostream>
#include "CImg.h"
using namespace cimg_library;
using namespace std;
int main(void) {
int alto = 500, ancho = 500;
int x0 = 0, y0 = 0, x1 = 50, y1 = 50;
int azul_perro[3] = {0, 255, 255};
int azul[3] = {0,0,255};
int verde[3] = {0,255,0};
int rojo[3] = {255,0,0};
int cafe[3] = {128,0,64};
int naranja[3] = {255,128,0};
int amarillo[3] = {255,255,0};
int rosa[3] = {255,128,128};
int violeta[3] = {128,0,255};
int gris[3] = {128,128,192};
int negro[3] = {0,0,0};
int blanco[3] = {255,255,255};
CImg <int> imagen(ancho,alto,1,3,255);
CImgDisplay ventana(ancho, alto, "Game",0);
while(!ventana.is_closed()){
if(ventana.is_keyARROWRIGHT()){
x0++;
x1++;
imagen.fill(255);
imagen.draw_rectangle(x0,y0,x1,y1,violeta);
}
if(ventana.is_keyARROWDOWN()){
y0++;
y1++;
imagen.fill(255);
imagen.draw_rectangle(x0,y0,x1,y1,rojo);
}
if(ventana.is_keyARROWLEFT()){
x0--;
x1--;
imagen.fill(255);
imagen.draw_rectangle(x0,y0,x1,y1,naranja);
}
if(ventana.is_keyARROWUP()){
y0--;
y1--;
imagen.fill(255);
imagen.draw_rectangle(x0,y0,x1,y1,cafe);
}
ventana.display(imagen);
ventana.wait(10);
}
}