Commit c7cf75c4df040a222940f31430fb3475623acef1
1 parent
d777f95a
replaced
Showing
1 changed file
with
0 additions
and
131 deletions
Show diff stats
main.c deleted
@@ -1,131 +0,0 @@ | @@ -1,131 +0,0 @@ | ||
1 | -#include "Graphique/libgraph.h" | ||
2 | -#include <unistd.h> | ||
3 | -#include <stdbool.h> | ||
4 | -#include <SDL/SDL.h> | ||
5 | -#include "liste.h" | ||
6 | -#define TAILLE_X 700 | ||
7 | -#define TAILLE_Y 700 | ||
8 | -#define LARGEUR_MONS 30 | ||
9 | -#define HAUTEUR_MONS 30 | ||
10 | -#define LARGEUR_VAIS 35 | ||
11 | -#define M_SPEED 5 | ||
12 | -#define CADENCE_MISSILE 600 | ||
13 | -#define HAUTEUR_MONS 30 | ||
14 | -#define LARGEUR_MISS 5 | ||
15 | -#define HAUTEUR_MISS 10 | ||
16 | - | ||
17 | - | ||
18 | - | ||
19 | -l_entite* create_l_entite (int x,int y,int speed,int image); | ||
20 | -entite create_entite (entite ent,int x,int y, int speed, int image); | ||
21 | -void add_entite (l_entite** head,int x,int y,int speed,int image); | ||
22 | -void display_l_entite (l_entite* mons); | ||
23 | -void display_entite (entite ent); | ||
24 | -void moveMonster (l_entite* monstre); | ||
25 | -void addMissile (l_entite** head, entite vaisseau,int image); | ||
26 | -void moveMissile (l_entite* msl); | ||
27 | -void remove_missile (l_entite **head, entite *karim); | ||
28 | -void detecterCollisions (l_entite* l_missile, l_entite* l_monstre); | ||
29 | - | ||
30 | - | ||
31 | -int main() | ||
32 | -{ | ||
33 | - | ||
34 | - l_entite* W_monster = NULL; | ||
35 | - l_entite* B_monster = NULL; | ||
36 | - l_entite* l_missile = NULL; | ||
37 | - entite vaisseau; | ||
38 | - entite missile; | ||
39 | - entite missile_ref; | ||
40 | - creerSurface(TAILLE_X,TAILLE_Y,"Space Invaders"); | ||
41 | - | ||
42 | - | ||
43 | - | ||
44 | - int ZB=lutinTexte("Space invaders", COULEUR_BLEU); | ||
45 | - int M1=chargerLutin("Graphique/invader_monstre1_2.bmp", COULEUR_BLEU); | ||
46 | - int M2=chargerLutin("Graphique/invader_monstre2_1.bmp", COULEUR_BLEU); | ||
47 | - int V =chargerLutin("Graphique/invader_canon.bmp", COULEUR_BLEU); | ||
48 | - int MI =chargerLutin("Graphique/invader_missile.bmp", COULEUR_BLEU); | ||
49 | - | ||
50 | - | ||
51 | - | ||
52 | - W_monster =create_l_entite(0,0,1,M1); | ||
53 | - B_monster =create_l_entite(0,100,1,M2); | ||
54 | - vaisseau =create_entite(vaisseau,0.5*TAILLE_X,0.95*TAILLE_Y,1,V); | ||
55 | - missile_ref =create_entite(missile_ref,vaisseau.x + (LARGEUR_VAIS/2),400,1,MI); | ||
56 | - l_missile =create_l_entite( vaisseau.x + (LARGEUR_VAIS/2),(vaisseau).y,1,MI); | ||
57 | - | ||
58 | - int i=0;int a =60; | ||
59 | - for (i=0;i<4;i++) | ||
60 | - { | ||
61 | - add_entite(&W_monster,((W_monster->ent).x)+a,(W_monster->ent).y,1,M1); | ||
62 | - add_entite(&B_monster,((B_monster->ent).x)+a,(B_monster->ent).y,1,M2); | ||
63 | - a+=60; | ||
64 | - } | ||
65 | - | ||
66 | - | ||
67 | - | ||
68 | - while(1) | ||
69 | - { | ||
70 | - evenement ev; | ||
71 | - char touche; | ||
72 | - l_missile = NULL; | ||
73 | - lireEvenement(&ev,&touche,NULL); | ||
74 | - if(ev==quitter) | ||
75 | - {break; | ||
76 | - } | ||
77 | - rectanglePlein (0,0,TAILLE_X,TAILLE_Y,COULEUR_NOIR); | ||
78 | - display_l_entite(W_monster); | ||
79 | - display_l_entite(B_monster); | ||
80 | - display_entite(vaisseau); | ||
81 | - moveMonster( W_monster); | ||
82 | - moveMonster( B_monster); | ||
83 | - | ||
84 | - | ||
85 | - if (ev == toucheBas && touche == 'm') | ||
86 | - { | ||
87 | - if( l_missile == NULL) | ||
88 | - { | ||
89 | - addMissile (&l_missile, vaisseau,MI); | ||
90 | - } | ||
91 | - else if( l_missile->ent.y < CADENCE_MISSILE) | ||
92 | - { | ||
93 | - addMissile (&l_missile, vaisseau,MI); | ||
94 | - | ||
95 | - } | ||
96 | - } | ||
97 | - | ||
98 | - display_l_entite(l_missile); | ||
99 | - moveMissile(l_missile); | ||
100 | - | ||
101 | - detecterCollisions( l_missile, B_monster); | ||
102 | - | ||
103 | - if (ev == toucheBas && touche=='d') | ||
104 | - { | ||
105 | - vaisseau.x=vaisseau.x + 10; | ||
106 | - if (vaisseau.x > TAILLE_X - LARGEUR_VAIS) | ||
107 | - { | ||
108 | - vaisseau.x = vaisseau.x - 10; | ||
109 | - } | ||
110 | - | ||
111 | - } | ||
112 | - | ||
113 | - if (ev == toucheBas && touche == 'q') | ||
114 | - { | ||
115 | - vaisseau.x=vaisseau.x - 10; | ||
116 | - if (vaisseau.x < 0) | ||
117 | - { | ||
118 | - vaisseau.x = vaisseau.x + 10; | ||
119 | - } | ||
120 | - } | ||
121 | - | ||
122 | - | ||
123 | - | ||
124 | - | ||
125 | - afficherLutin(ZB,400,400); | ||
126 | - majSurface(); | ||
127 | - SDL_Delay(10); | ||
128 | - | ||
129 | - } | ||
130 | - return 0; | ||
131 | -} |