Commit d777f95a274ef223b805918e599ea3da880653a3
1 parent
327ad447
.
Showing
1 changed file
with
0 additions
and
149 deletions
Show diff stats
test2.c deleted
@@ -1,149 +0,0 @@ | @@ -1,149 +0,0 @@ | ||
1 | -#include<SDL/SDL.h> | ||
2 | -#include<SDL/SDL_ttf.h> | ||
3 | -#include"Graphique/libgraph.h" | ||
4 | -#include<stdbool.h> | ||
5 | -#include "test2.h" | ||
6 | -#include <stdio.h> | ||
7 | -#include <stdlib.h> | ||
8 | -#define TAILLE_X 700 | ||
9 | -#define TAILLE_DESC 40 | ||
10 | -#define LARGEUR_MONS 30 | ||
11 | -#define HAUTEUR_MONS 30 | ||
12 | -#define LARGEUR_VAIS 35 | ||
13 | -#define SPEED 1 | ||
14 | -#define MISS_SPEED 5 | ||
15 | -#define LARGEUR_MISS 5 | ||
16 | -#define HAUTEUR_MISS 10 | ||
17 | - | ||
18 | - | ||
19 | - | ||
20 | - | ||
21 | -l_entite* create_l_entite(int x,int y,int speed,int image) | ||
22 | -{ | ||
23 | - l_entite* monster_1 =(l_entite*)malloc(sizeof(l_entite)); | ||
24 | - (monster_1->ent).image=image; | ||
25 | - (monster_1->ent).x =x; | ||
26 | - (monster_1->ent).y =y; | ||
27 | - (monster_1->ent).speed=speed; | ||
28 | - monster_1->next = NULL; | ||
29 | - return monster_1; | ||
30 | -} | ||
31 | - | ||
32 | -entite create_entite(entite ent,int x,int y, int speed, int image) | ||
33 | -{ | ||
34 | - (ent).image=image; | ||
35 | - (ent).x =x; | ||
36 | - (ent).y =y; | ||
37 | - (ent).speed=speed; | ||
38 | - return ent; | ||
39 | -} | ||
40 | - | ||
41 | - | ||
42 | - | ||
43 | -void add_entite (l_entite** head,int x,int y,int speed,int image) | ||
44 | -{ | ||
45 | - | ||
46 | - l_entite* new_monster = create_l_entite( x, y,speed,image); | ||
47 | - if (head==NULL) | ||
48 | - { | ||
49 | - *head=new_monster; | ||
50 | - } | ||
51 | - else | ||
52 | - { | ||
53 | - l_entite* current =*head; | ||
54 | - while (current->next != NULL) | ||
55 | - { current=current->next; | ||
56 | - } | ||
57 | - current->next=new_monster; | ||
58 | - } | ||
59 | -} | ||
60 | - | ||
61 | - | ||
62 | -void display_l_entite(l_entite* mons) | ||
63 | -{ | ||
64 | - l_entite* ptr= mons; | ||
65 | - while(ptr != NULL) | ||
66 | - { | ||
67 | - afficherLutin((ptr->ent).image,(ptr->ent).x,(ptr->ent).y); | ||
68 | - ptr=ptr->next; | ||
69 | - } | ||
70 | -} | ||
71 | - | ||
72 | -void display_entite(entite ent) | ||
73 | - { | ||
74 | - afficherLutin((ent).image,(ent).x,(ent).y); | ||
75 | - } | ||
76 | - | ||
77 | - | ||
78 | - | ||
79 | -void moveMonster(l_entite* monstre) | ||
80 | -{ | ||
81 | - int max = TAILLE_X - LARGEUR_MONS; | ||
82 | - l_entite* currentMonster = monstre; | ||
83 | - while (currentMonster != NULL) | ||
84 | - { | ||
85 | - (currentMonster->ent).x += (currentMonster->ent).speed; | ||
86 | - | ||
87 | - if ( (currentMonster->ent).x < 0 || (currentMonster->ent).x > max) | ||
88 | - { | ||
89 | - (currentMonster->ent).speed = -(currentMonster->ent).speed; | ||
90 | - (currentMonster->ent).y += TAILLE_DESC ; | ||
91 | - } | ||
92 | - | ||
93 | - currentMonster = currentMonster->next; | ||
94 | - } | ||
95 | -} | ||
96 | -int main() | ||
97 | -{ | ||
98 | - | ||
99 | - l_entite* W_monster = NULL; | ||
100 | - l_entite* B_monster = NULL; | ||
101 | - l_entite* l_missile = NULL; | ||
102 | - entite vaisseau; | ||
103 | - entite missile; | ||
104 | - entite missile_ref; | ||
105 | - creerSurface(TAILLE_X,TAILLE_Y,"Space Invaders"); | ||
106 | - | ||
107 | - | ||
108 | - | ||
109 | - int ZB=lutinTexte("Space invaders", COULEUR_BLEU); | ||
110 | - int M1=chargerLutin("Graphique/invader_monstre1_2.bmp", COULEUR_BLEU); | ||
111 | - int M2=chargerLutin("Graphique/invader_monstre2_1.bmp", COULEUR_BLEU); | ||
112 | - int V =chargerLutin("Graphique/invader_canon.bmp", COULEUR_BLEU); | ||
113 | - int MI =chargerLutin("Graphique/invader_missile.bmp", COULEUR_BLEU); | ||
114 | - | ||
115 | - | ||
116 | - | ||
117 | - W_monster =create_l_entite(0,0,1,M1); | ||
118 | - B_monster =create_l_entite(0,100,1,M2); | ||
119 | - vaisseau =create_entite(vaisseau,0.5*TAILLE_X,0.95*TAILLE_Y,1,V); | ||
120 | - missile_ref =create_entite(missile_ref,vaisseau.x + (LARGEUR_VAIS/2),400,1,MI); | ||
121 | - l_missile =create_l_entite( vaisseau.x + (LARGEUR_VAIS/2),(vaisseau).y,1,MI); | ||
122 | - | ||
123 | - int i=0;int a =60; | ||
124 | - for (i=0;i<4;i++) | ||
125 | - { | ||
126 | - add_entite(&W_monster,((W_monster->ent).x)+a,(W_monster->ent).y,1,M1); | ||
127 | - add_entite(&B_monster,((B_monster->ent).x)+a,(B_monster->ent).y,1,M2); | ||
128 | - a+=60; | ||
129 | - } | ||
130 | - | ||
131 | - | ||
132 | - | ||
133 | - while(1) | ||
134 | - { | ||
135 | - evenement ev; | ||
136 | - char touche; | ||
137 | - l_missile = NULL; | ||
138 | - lireEvenement(&ev,&touche,NULL); | ||
139 | - if(ev==quitter) | ||
140 | - {break; | ||
141 | - } | ||
142 | - rectanglePlein (0,0,TAILLE_X,TAILLE_Y,COULEUR_NOIR); | ||
143 | - display_l_entite(W_monster); | ||
144 | - display_l_entite(B_monster); | ||
145 | - display_entite(vaisseau); | ||
146 | - moveMonster( W_monster); | ||
147 | - moveMonster( B_monster); | ||
148 | - } | ||
149 | - } | ||
150 | \ No newline at end of file | 0 | \ No newline at end of file |