Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <allegro.h>
- echanger_gauche_droite(char tab,int i,int j,BITMAP* sprite1,BITMAP* sprite2,BITMAP* buffer){
- double pos_x, pos_y;
- double pos_x_bis, pos_y_bis;
- pos_x = 95+i*36; pos_y = 95+j*36; pos_x_bis = 95+(i+1)*36; pos_y_bis = 95+j*36;
- clear_bitmap(buffer);
- while(pos_x <= pos_x+36){
- while(pos_x_bis >= pos_x-36){
- pos_x += 0.5;
- pos_x_bis -= 0.5;
- clear_bitmap(buffer);
- draw_sprite(buffer,sprite1,pos_x,pos_y);
- draw_sprite(buffer,sprite2,pos_x_bis,pos_y_bis);
- blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
- }
- }
- }END_OF_FUNCTION();
- echanger_haut_bas(char tab,int i,int j,BITMAP* sprite1,BITMAP* sprite2,BITMAP* buffer){
- double pos_x, pos_y;
- double pos_x_bis, pos_y_bis;
- pos_x = 95+i*36; pos_y = 95+j*36; pos_x_bis = 95+i*36; pos_y_bis = 95+(j+1)*36;
- clear_bitmap(buffer);
- while(pos_y <= pos_y+36){
- while(pos_y_bis >= pos_y-36){
- pos_y += 0.5;
- pos_y_bis -= 0.5;
- clear_bitmap(buffer);
- draw_sprite(buffer,sprite1,pos_x,pos_y);
- draw_sprite(buffer,sprite2,pos_x_bis,pos_y_bis);
- blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
- }
- }
- }END_OF_FUNCTION();
- //fonction qui permute deux fruits de droite a gauche
- int main()
- {
- allegro_init();
- install_keyboard();
- install_mouse();
- set_color_depth(desktop_color_depth());
- set_gfx_mode(GFX_AUTODETECT_WINDOWED,1024,768,0,0);
- int i=0,j=0;
- char tab;
- BITMAP* buffer = NULL;
- BITMAP* apple = NULL;
- BITMAP* onion = NULL;
- BITMAP* orange = NULL;
- BITMAP* fraise = NULL;
- BITMAP* sun = NULL;
- apple = load_bitmap("Apple.bmp",NULL);
- fraise = load_bitmap("Fraise.bmp",NULL);
- onion = load_bitmap("Onion.bmp",NULL);
- sun = load_bitmap("Sun.bmp",NULL);
- orange = load_bitmap("Orange.bmp",NULL);
- buffer = create_bitmap(SCREEN_W,SCREEN_H);
- while(!key[KEY_ESC]){
- clear_bitmap(buffer);
- draw_sprite(buffer,apple,95,95);
- draw_sprite(buffer,fraise,95,95+36);
- blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
- while(key[KEY_ENTER]){
- echanger_haut_bas(tab,i,j,apple,fraise,buffer);
- }
- }
- }END_OF_MAIN();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement