From d777f95a274ef223b805918e599ea3da880653a3 Mon Sep 17 00:00:00 2001 From: mahmoudrabia Date: Thu, 29 Aug 2024 14:23:38 +0200 Subject: [PATCH] . --- test2.c | 149 ----------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 0 insertions(+), 149 deletions(-) delete mode 100644 test2.c diff --git a/test2.c b/test2.c deleted file mode 100644 index 1280cdd..0000000 --- a/test2.c +++ /dev/null @@ -1,149 +0,0 @@ -#include -#include -#include"Graphique/libgraph.h" -#include -#include "test2.h" -#include -#include -#define TAILLE_X 700 -#define TAILLE_DESC 40 -#define LARGEUR_MONS 30 -#define HAUTEUR_MONS 30 -#define LARGEUR_VAIS 35 -#define SPEED 1 -#define MISS_SPEED 5 -#define LARGEUR_MISS 5 -#define HAUTEUR_MISS 10 - - - - -l_entite* create_l_entite(int x,int y,int speed,int image) -{ - l_entite* monster_1 =(l_entite*)malloc(sizeof(l_entite)); - (monster_1->ent).image=image; - (monster_1->ent).x =x; - (monster_1->ent).y =y; - (monster_1->ent).speed=speed; - monster_1->next = NULL; - return monster_1; -} - -entite create_entite(entite ent,int x,int y, int speed, int image) -{ - (ent).image=image; - (ent).x =x; - (ent).y =y; - (ent).speed=speed; - return ent; -} - - - -void add_entite (l_entite** head,int x,int y,int speed,int image) -{ - - l_entite* new_monster = create_l_entite( x, y,speed,image); - if (head==NULL) - { - *head=new_monster; - } - else - { - l_entite* current =*head; - while (current->next != NULL) - { current=current->next; - } - current->next=new_monster; - } -} - - -void display_l_entite(l_entite* mons) -{ - l_entite* ptr= mons; - while(ptr != NULL) - { - afficherLutin((ptr->ent).image,(ptr->ent).x,(ptr->ent).y); - ptr=ptr->next; - } -} - -void display_entite(entite ent) - { - afficherLutin((ent).image,(ent).x,(ent).y); - } - - - -void moveMonster(l_entite* monstre) -{ - int max = TAILLE_X - LARGEUR_MONS; - l_entite* currentMonster = monstre; - while (currentMonster != NULL) - { - (currentMonster->ent).x += (currentMonster->ent).speed; - - if ( (currentMonster->ent).x < 0 || (currentMonster->ent).x > max) - { - (currentMonster->ent).speed = -(currentMonster->ent).speed; - (currentMonster->ent).y += TAILLE_DESC ; - } - - currentMonster = currentMonster->next; - } -} -int main() -{ - - l_entite* W_monster = NULL; - l_entite* B_monster = NULL; - l_entite* l_missile = NULL; - entite vaisseau; - entite missile; - entite missile_ref; - creerSurface(TAILLE_X,TAILLE_Y,"Space Invaders"); - - - - int ZB=lutinTexte("Space invaders", COULEUR_BLEU); - int M1=chargerLutin("Graphique/invader_monstre1_2.bmp", COULEUR_BLEU); - int M2=chargerLutin("Graphique/invader_monstre2_1.bmp", COULEUR_BLEU); - int V =chargerLutin("Graphique/invader_canon.bmp", COULEUR_BLEU); - int MI =chargerLutin("Graphique/invader_missile.bmp", COULEUR_BLEU); - - - - W_monster =create_l_entite(0,0,1,M1); - B_monster =create_l_entite(0,100,1,M2); - vaisseau =create_entite(vaisseau,0.5*TAILLE_X,0.95*TAILLE_Y,1,V); - missile_ref =create_entite(missile_ref,vaisseau.x + (LARGEUR_VAIS/2),400,1,MI); - l_missile =create_l_entite( vaisseau.x + (LARGEUR_VAIS/2),(vaisseau).y,1,MI); - - int i=0;int a =60; - for (i=0;i<4;i++) - { - add_entite(&W_monster,((W_monster->ent).x)+a,(W_monster->ent).y,1,M1); - add_entite(&B_monster,((B_monster->ent).x)+a,(B_monster->ent).y,1,M2); - a+=60; - } - - - - while(1) - { - evenement ev; - char touche; - l_missile = NULL; - lireEvenement(&ev,&touche,NULL); - if(ev==quitter) - {break; - } - rectanglePlein (0,0,TAILLE_X,TAILLE_Y,COULEUR_NOIR); - display_l_entite(W_monster); - display_l_entite(B_monster); - display_entite(vaisseau); - moveMonster( W_monster); - moveMonster( B_monster); - } - } \ No newline at end of file -- libgit2 0.21.2