![]() |
|
game loop with Allegro 5 |
dedalusman
Member #14,504
August 2012
|
Hello everybody This is my first game loop with Allegro 5.0.6 But she don't run correctly because I have a horizontal line at y = 160 on my Eeepc 1024/600. When I move a circle at y=160, it is split in two part. No good image Do you have an idea for change this code for better image ? Thanks Sorry for my bad English but I am French. 1//Main fonction for testing game loop with Allegro 5
2
3//****************
4//*** main.cpp ***
5//****************
6
7//Version 1.0
8
9//Developed with Dev C++ 5.2.0.3 & Allegro 5.0.6
10
11//By Alain Galiani
12//Dedalusman
13//nageondu@gmail.com
14
15//Start 20 08 2012
16//Finished 00 00 2013
17//Last updat 20 08 2012
18
19//History:
20
21/*
22
23*/
24
25typedef signed long lm4o;
26typedef float flo4;
27
28//****************
29//*** INCLUDES ***
30//****************
31
32#include<allegro5/allegro.h>
33#include<allegro5/allegro_primitives.h>
34#include<allegro5/allegro_font.h>
35#include<allegro5/allegro_ttf.h>
36#include<allegro5/allegro_native_dialog.h>
37
38#include<stdlib.h>
39#include<math.h>
40
41#include<windows.h>
42
43#include<class_cycles_seconde.hpp>
44#include<class_cercle.hpp>
45
46#include<global_registers.hpp>
47#include<class_global_inputs.hpp>
48
49
50int main(int argc, char **argv)
51{
52
53 class_cercle tab_ob_cercle[1000];
54 class_cercle*ptr_ob_cercle=NULL;
55 class_cercle*ptr_tab_ob_cercle=NULL;
56 ptr_tab_ob_cercle=&tab_ob_cercle[0];
57
58 lm4o ray_max,ray_min;
59 lm4o lxi,lxs,lyi,lys;
60
61 lm4o nb1;
62
63 lm4o resol_x=1024,
64 resol_y=600;
65
66 lm4o count1=0,count2=0,count3=0;
67
68 lm4o fps=60;
69
70 flo4 cps1,cps2;
71 class_cycles_seconde ob_cycles1,ob_cycles2;
72
73 lm4o pos_x,pos_y,pos_x1,pos_y1;
74 lm4o vv_x,vv_y;
75
76 ALLEGRO_DISPLAY *ptr_display=NULL;
77
78 if(!al_init())
79 {
80 return -1;
81 }
82
83 al_set_new_display_flags(ALLEGRO_FULLSCREEN);
84
85 ptr_display = al_create_display(resol_x,resol_y);
86
87 if(!ptr_display)
88 {
89 al_uninstall_system();
90 return -1;
91 }
92
93 class_global_inputs global_inputs;
94
95 if(global_inputs.init(fps)!=0)
96 {
97 al_destroy_display(ptr_display);
98 al_uninstall_system();
99 return -1;
100 }
101
102 al_init_font_addon();
103
104 if(!al_init_ttf_addon())
105 {
106 al_destroy_display(ptr_display);
107 al_uninstall_system();
108 return -1;
109 }
110
111 if(!al_init_primitives_addon())
112 {
113 al_destroy_display(ptr_display);
114 al_uninstall_system();
115 return -1;
116 }
117
118 al_hide_mouse_cursor(ptr_display);//cache la souris dans le display
119
120 ALLEGRO_FONT *ptr_font24;
121 ptr_font24=al_load_font("Starjhol.ttf",24,0);
122
123 ALLEGRO_FONT *ptr_font18;
124 ptr_font18=al_load_font("Starjhol.ttf",18,0);
125
126 al_clear_to_color(al_map_rgb(0,0,0));
127
128 lxi=0;
129 lxs=resol_x;
130 lyi=0;
131 lys=resol_y;
132
133 ray_min=10;
134 ray_max=100;
135
136 for(nb1=0;nb1<1000;nb1++)
137 {
138 ptr_ob_cercle=ptr_tab_ob_cercle+nb1;
139 ptr_ob_cercle->espace(lxi,lxs,lyi,lys);
140 ptr_ob_cercle->hasard(ray_min,ray_max);
141 }
142
143 //****************************************************************************
144 //*** TEST GAME LOOP *********************************************************
145 //****************************************************************************
146
147 count1=0;
148 count2=0;
149
150 pos_x=resol_x/2;
151 pos_y=resol_y/2;
152 pos_x1=resol_x/3;
153 pos_y1=resol_y/3;
154
155 vv_x=0;
156 vv_y=0;
157
158 g_game_loop=true;
159
160 ob_cycles1.start(100);
161 ob_cycles2.start(100);
162
163 while(g_game_loop)
164 {
165
166 count1++;
167 cps1=ob_cycles1.run();
168
169 global_inputs.run();
170
171 //***********************
172 //*** CALCULATE FRAME ***
173 //***********************
174
175 if(g_redraw)
176 {
177 count2++;
178 cps2=ob_cycles2.run();
179
180 g_redraw=false;
181
182 vv_x=(10*g_key_right)-(10*g_key_left);
183 vv_y=(10*g_key_down)-(10*g_key_up);
184
185 pos_x+=vv_x;
186 pos_y+=vv_y;
187
188 pos_x1=g_mouse_pos_x;
189 pos_y1=g_mouse_pos_y;
190
191 for(nb1=0;nb1<7;nb1++)
192 {
193 ptr_ob_cercle=ptr_tab_ob_cercle+nb1;
194 ptr_ob_cercle->animation();
195 ptr_ob_cercle->dessine_plein();
196 }
197
198 //*** TEXT CONTROL ***
199
200 al_draw_text(ptr_font18,al_map_rgb(255,0,255),20,20,0,"game loop");
201 al_draw_textf(ptr_font18,al_map_rgb(255,100,255),400,resol_y-40,0,"compteur 2 = %i",count2);
202 al_draw_textf(ptr_font18,al_map_rgb(255,255,100),400,resol_y-70,0,"compteur 1 = %i",count1);
203
204 al_draw_textf(ptr_font18,al_map_rgb(255,255,255),20,resol_y-40,0,"position x = %i y = %i ",pos_x,pos_y);
205
206 al_draw_textf(ptr_font18,al_map_rgb(125,125,255),20,resol_y-70,0,"CPS 2 = %f",cps2);//compteur cycles 2
207 al_draw_textf(ptr_font18,al_map_rgb(255,125,255),20,resol_y-100,0,"CPS 1 = %f",cps1);//compteur cycles 1
208
209 //*** KEY CIRCLE ***
210
211 al_draw_filled_circle(pos_x,pos_y,20,al_map_rgb(0,255,255));
212
213 //*** MOUSE CIRCLE ***
214
215 al_draw_filled_circle(pos_x1,pos_y1,20,al_map_rgb(255,255,125));
216
217 if(g_but_mouse_right)
218 {
219 al_draw_filled_circle(pos_x1+40,pos_y1,10,al_map_rgb(255,0,255));
220 }
221 if(g_but_mouse_left)
222 {
223 al_draw_filled_circle(pos_x1-40,pos_y1,10,al_map_rgb(255,255,255));
224 }
225
226 //*** JOYSTICK CONTROL ***
227
228 al_draw_textf(ptr_font18,al_map_rgb(255,0,255),400,resol_y-160,0,"joy1 axe x1 = %f",g_x1_axis_joy1);
229 al_draw_textf(ptr_font18,al_map_rgb(255,255,0),400,resol_y-130,0,"joy1 axe y1 = %f",g_y1_axis_joy1);
230
231 al_draw_textf(ptr_font18,al_map_rgb(0,125,255),400,resol_y-220,0,"joy1 axe x2 = %f",g_x2_axis_joy1);
232 al_draw_textf(ptr_font18,al_map_rgb(0,255,0),400,resol_y-190,0,"joy1 axe y2 = %f",g_y2_axis_joy1);
233
234 al_draw_textf(ptr_font18,al_map_rgb(0,255,125),400,resol_y-280,0,"joy1 axe x3 = %f",g_x3_axis_joy1);
235 al_draw_textf(ptr_font18,al_map_rgb(0,0,255),400,resol_y-250,0,"joy1 axe y3 = %f",g_y3_axis_joy1);
236
237 al_draw_textf(ptr_font18,al_map_rgb(255,0,0),400,resol_y-340,0,"joy1 axe x4 = %f",g_x4_axis_joy1);
238 al_draw_textf(ptr_font18,al_map_rgb(0,255,0),400,resol_y-310,0,"joy1 axe y4 = %f",g_y4_axis_joy1);
239
240 al_draw_textf(ptr_font18,al_map_rgb(0,0,255),400,resol_y-400,0,"joy1 axe x5 = %f",g_x5_axis_joy1);
241 al_draw_textf(ptr_font18,al_map_rgb(125,125,0),400,resol_y-370,0,"joy1 axe y5 = %f",g_y5_axis_joy1);
242
243 if(g_but_00_joy1)
244 {
245 al_draw_filled_circle(10,10,3,al_map_rgb(255,0,0));
246 }
247
248 if(g_but_01_joy1)
249 {
250 al_draw_filled_circle(10,20,3,al_map_rgb(255,0,0));
251 }
252
253 if(g_but_02_joy1)
254 {
255 al_draw_filled_circle(10,30,3,al_map_rgb(255,0,0));
256 }
257
258 if(g_but_03_joy1)
259 {
260 al_draw_filled_circle(10,40,3,al_map_rgb(255,0,0));
261 }
262
263 if(g_but_04_joy1)
264 {
265 al_draw_filled_circle(10,50,3,al_map_rgb(255,0,0));
266 }
267
268 if(g_but_05_joy1)
269 {
270 al_draw_filled_circle(10,60,3,al_map_rgb(255,0,0));
271 }
272
273 if(g_but_06_joy1)
274 {
275 al_draw_filled_circle(10,70,3,al_map_rgb(255,0,0));
276 }
277
278 if(g_but_07_joy1)
279 {
280 al_draw_filled_circle(10,80,3,al_map_rgb(255,0,0));
281 }
282
283 if(g_but_08_joy1)
284 {
285 al_draw_filled_circle(10,90,3,al_map_rgb(255,0,0));
286 }
287
288 if(g_but_09_joy1)
289 {
290 al_draw_filled_circle(10,100,3,al_map_rgb(255,0,0));
291 }
292
293 if(g_but_10_joy1)
294 {
295 al_draw_filled_circle(10,110,3,al_map_rgb(255,0,0));
296 }
297
298 if(g_but_11_joy1)
299 {
300 al_draw_filled_circle(10,120,3,al_map_rgb(255,0,0));
301 }
302
303 if(g_but_12_joy1)
304 {
305 al_draw_filled_circle(10,130,3,al_map_rgb(255,0,0));
306 }
307
308 //*** DISPLAY ***
309
310 al_wait_for_vsync();
311 al_flip_display();
312 al_clear_to_color(al_map_rgb(0,0,0));
313 }
314 }
315
316 al_rest(3.0);
317
318 al_destroy_font(ptr_font18);
319 al_destroy_font(ptr_font24);
320 al_destroy_display(ptr_display);
321 al_uninstall_system();
322
323 return 0;
324}
1//Declaration de la class cercle avec ses fonctions membres
2
3//************************
4//*** class_cercle.hpp ***
5//************************
6
7//Version 1.0
8
9//Developed with Dev C++ 5.2.0.3 & Allegro 5.0.6
10
11//By Alain Galiani
12//Dedalusman
13//nageondu@gmail.com
14
15//Start 17 09 2011
16//Finished 00 00 2012
17//Last updat 17 09 2011
18
19//History:
20
21/*
22
23*/
24
25//********************==========================================================
26//*** class_cercle ***==========================================================
27//********************==========================================================
28
29class class_cercle
30{public:
31
32 //*** DATAS ***
33
34 lm4o ray;
35 ALLEGRO_COLOR cou;
36 lm4o pos_x,pos_y;
37 lm4o vv_x,vv_y;
38
39 lm4o b_sup_x,b_inf_x;
40 lm4o b_sup_y,b_inf_y;
41
42 lm4o lx_inf;
43 lm4o lx_sup;
44 lm4o ly_inf;
45 lm4o ly_sup;
46
47 //*** FONCTIONS ***
48
49 void animation();
50 void dessine();
51 void dessine_plein();
52 void creation(lm4o x,lm4o y,lm4o r,ALLEGRO_COLOR c,lm4o vx,lm4o vy);
53 void hasard(lm4o r1,lm4o r2);
54 void espace(lm4o lxi,lm4o lxs,lm4o lyi,lm4o lys);
55};
56
57void class_cercle::animation()
58{
59 pos_x+=vv_x;
60 pos_y+=vv_y;
61
62 b_sup_x=pos_x+ray;
63 b_inf_x=pos_x-ray;
64 b_sup_y=pos_y+ray;
65 b_inf_y=pos_y-ray;
66
67 if(b_sup_x>lx_sup)
68 {
69 vv_x=-vv_x;
70 pos_x=(lx_sup+lx_sup)-pos_x-(ray+ray);
71 }
72 else
73 {
74 if(b_inf_x<lx_inf)
75 {
76 vv_x=-vv_x;
77 pos_x=-pos_x+(ray+ray)+(lx_inf+lx_inf);
78 }
79 }
80
81 if(b_sup_y>ly_sup)
82 {
83 vv_y=-vv_y;
84 pos_y=(ly_sup+ly_sup)-pos_y-(ray+ray);
85 }
86 else
87 {
88 if(b_inf_y<ly_inf)
89 {
90 vv_y=-vv_y;
91 pos_y=-pos_y+(ray+ray)+(ly_inf+ly_inf);
92 }
93 }
94}
95
96void class_cercle::dessine()
97{
98 al_draw_circle(pos_x,pos_y,ray,cou,1);
99}
100
101void class_cercle::dessine_plein()
102{
103 al_draw_filled_circle(pos_x,pos_y,ray,cou);
104}
105
106void class_cercle::creation(lm4o x,lm4o y,lm4o r,ALLEGRO_COLOR c,lm4o vx,lm4o vy)
107{
108 pos_x=x;
109 pos_y=y;
110 ray=r;
111 cou=c;
112 vv_x=vx;
113 vv_y=vy;
114
115 b_sup_x=x+r;
116 b_inf_x=x-r;
117 b_sup_y=y+r;
118 b_inf_y=y-r;
119}
120
121void class_cercle::hasard(lm4o r1,lm4o r2)
122{
123 lm4o h;
124 lm4o d,dx,dy;
125
126 h=rand();
127 d=r2-r1;
128 ray=((h*d)/32767)+r1;
129
130 h=rand();
131 dx=lx_sup-lx_inf;
132 pos_x=((h*dx)/32767)+lx_inf;
133
134 if ((pos_x+ray)>=lx_sup)
135 {
136 pos_x=lx_sup-ray-2;
137 }
138 else
139 {
140 if((pos_x-ray)<=lx_inf)
141 {
142 pos_x=lx_inf+ray+2;
143 }
144 }
145
146 h=rand();
147 dy=ly_sup-ly_inf;
148 pos_y=((h*dy)/32767)+ly_inf;
149
150 if ((pos_y+ray)>=ly_sup)
151 {
152 pos_y=ly_sup-ray-2;
153 }
154 else
155 {
156 if((pos_y-ray)<=ly_inf)
157 {
158 pos_y=ly_inf+ray+2;
159 }
160 }
161
162 cou=al_map_rgb(rand(),rand(),rand());
163
164 h=rand();
165 vv_x=((h*14)/32767)+1;
166 if(rand()>16384)vv_x=-vv_x;
167
168 h=rand();
169 vv_y=((h*14)/32767)+1;
170 if(rand()>16384)vv_y=-vv_y;
171
172 b_sup_x=pos_x+ray;
173 b_inf_x=pos_x-ray;
174 b_sup_y=pos_y+ray;
175 b_inf_y=pos_y-ray;
176}
177
178void class_cercle::espace(lm4o lxi,lm4o lxs,lm4o lyi,lm4o lys)
179{
180 lx_inf=lxi;
181 lx_sup=lxs;
182 ly_inf=lyi;
183 ly_sup=lys;
184}
1//class_cycles_seconde.hpp for calculat cycles/seconde
2
3//********************************
4//*** class_cycles_seconde.hpp ***
5//********************************
6
7//Version 1.0
8
9//Developed with Dev C++ 5.2.0.3 & Allegro 5.0.6
10
11//By Alain Galiani
12//Dedalusman
13//nageondu@gmail.com
14
15//Start 20 08 2012
16//Finished 00 00 2013
17//Last updat 20 08 2012
18
19//History:
20
21/*
22
23*/
24
25class class_cycles_seconde
26{public:
27
28 //*** DATAS ***
29
30 lm4o temps_debut;
31 lm4o temps_fin;
32 flo4 temps_ecoule;
33 flo4 nb_cycles;
34 flo4 max_cycles;
35 flo4 cps;
36
37 //*** FONCTIONS ***
38
39 void start(flo4 max_cycles);
40 flo4 run();
41};
42
43void class_cycles_seconde::start(flo4 max_cy)
44{
45 max_cycles=max_cy;
46 temps_debut=GetTickCount();
47 nb_cycles=0;
48}
49
50flo4 class_cycles_seconde::run()
51{
52 if (nb_cycles>=max_cycles)
53 {
54 temps_fin=GetTickCount();
55 temps_ecoule=(float)(temps_fin-temps_debut)/1000.0;
56 cps=nb_cycles/temps_ecoule;
57 nb_cycles=0;
58 temps_debut=temps_fin;
59 }
60 else
61 {
62 nb_cycles++;
63 }
64 return cps;
65}
1//class_global_inputs.hpp for global input
2
3//*******************************
4//*** class_global_inputs.hpp ***
5//*******************************
6
7//Version 1.0
8
9//Developed with Dev C++ 5.2.0.3 & Allegro 5.0.6
10
11//By Alain Galiani
12//Dedalusman
13//nageondu@gmail.com
14
15//Start 20 08 2012
16//Finished 00 00 2013
17//Last updat 20 08 2012
18
19//History:
20
21/*
22
23*/
24
25class class_global_inputs
26{public:
27
28 //*** DATAS ***
29
30 lm4o fps;
31 ALLEGRO_EVENT ob_event;
32 ALLEGRO_EVENT_QUEUE *ptr_event_queue;
33 ALLEGRO_TIMER *ptr_timer;
34
35 //*** FONCTIONS ***
36
37 lm4o init(lm4o p_fps);
38 void run();
39};
40
41lm4o class_global_inputs::init(lm4o p_fps)
42{
43 fps=p_fps;
44
45 if(!al_install_keyboard())
46 {
47 return -1;
48 }
49
50 if(!al_install_mouse())
51 {
52 return -1;
53 }
54
55 if(!al_install_joystick())
56 {
57 return -1;
58 }
59
60 ptr_event_queue=al_create_event_queue();
61 ptr_timer=al_create_timer(1.0/fps);
62
63 al_register_event_source(ptr_event_queue,al_get_keyboard_event_source());
64 al_register_event_source(ptr_event_queue,al_get_mouse_event_source());
65 al_register_event_source(ptr_event_queue,al_get_timer_event_source(ptr_timer));
66 al_register_event_source(ptr_event_queue,al_get_joystick_event_source());
67
68 al_start_timer(ptr_timer);
69
70 return 0;
71}
72
73void class_global_inputs::run()
74{
75 al_wait_for_event(ptr_event_queue,&ob_event);
76 switch(ob_event.type)
77 {
78 case ALLEGRO_EVENT_KEY_DOWN:
79 switch(ob_event.keyboard.keycode)
80 {
81 case ALLEGRO_KEY_UP:
82 g_key_up=true;
83 break;
84
85 case ALLEGRO_KEY_DOWN:
86 g_key_down=true;
87 break;
88
89 case ALLEGRO_KEY_LEFT:
90 g_key_left=true;
91 break;
92
93 case ALLEGRO_KEY_RIGHT:
94 g_key_right=true;
95 break;
96 }
97 break;
98
99 case ALLEGRO_EVENT_KEY_UP:
100 switch(ob_event.keyboard.keycode)
101 {
102 case ALLEGRO_KEY_UP:
103 g_key_up=false;
104 break;
105
106 case ALLEGRO_KEY_DOWN:
107 g_key_down=false;
108 break;
109
110 case ALLEGRO_KEY_LEFT:
111 g_key_left=false;
112 break;
113
114 case ALLEGRO_KEY_RIGHT:
115 g_key_right=false;
116 break;
117
118 case ALLEGRO_KEY_ESCAPE:
119 g_game_loop=false;
120 break;
121 }
122 break;
123
124 case ALLEGRO_EVENT_DISPLAY_CLOSE:
125 g_game_loop=false;
126 break;
127
128 case ALLEGRO_EVENT_MOUSE_AXES:
129 g_mouse_pos_x=ob_event.mouse.x;
130 g_mouse_pos_y=ob_event.mouse.y;
131 break;
132
133 case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
134 if(ob_event.mouse.button & 2)
135 {
136 g_but_mouse_right=true;
137 }
138 if(ob_event.mouse.button & 1)
139 {
140 g_but_mouse_left=true;
141 }
142 break;
143
144 case ALLEGRO_EVENT_MOUSE_BUTTON_UP:
145 if(ob_event.mouse.button & 2)
146 {
147 g_but_mouse_right=false;
148 }
149 if(ob_event.mouse.button & 1)
150 {
151 g_but_mouse_left=false;
152 }
153 break;
154
155 case ALLEGRO_EVENT_JOYSTICK_AXIS:
156 switch(ob_event.joystick.stick)
157 {
158 case 0:
159 switch(ob_event.joystick.axis)
160 {
161 case 0:
162 g_x1_axis_joy1=ob_event.joystick.pos;
163 break;
164
165 case 1:
166 g_y1_axis_joy1=ob_event.joystick.pos;
167 break;
168 }
169 break;
170
171 case 1:
172 switch(ob_event.joystick.axis)
173 {
174 case 0:
175 g_x2_axis_joy1=ob_event.joystick.pos;
176 break;
177
178 case 1:
179 g_y2_axis_joy1=ob_event.joystick.pos;
180 break;
181 }
182 break;
183
184 case 2:
185 switch(ob_event.joystick.axis)
186 {
187 case 0:
188 g_x3_axis_joy1=ob_event.joystick.pos;
189 break;
190
191 case 1:
192 g_y3_axis_joy1=ob_event.joystick.pos;
193 break;
194 }
195 break;
196
197 case 3:
198 switch(ob_event.joystick.axis)
199 {
200 case 0:
201 g_x4_axis_joy1=ob_event.joystick.pos;
202 break;
203
204 case 1:
205 g_y4_axis_joy1=ob_event.joystick.pos;
206 break;
207 }
208 break;
209
210 case 4:
211 switch(ob_event.joystick.axis)
212 {
213 case 0:
214 g_x5_axis_joy1=ob_event.joystick.pos;
215 break;
216
217 case 1:
218 g_y5_axis_joy1=ob_event.joystick.pos;
219 break;
220 }
221 break;
222 }
223 break;
224
225 case ALLEGRO_EVENT_JOYSTICK_BUTTON_DOWN:
226 switch(ob_event.joystick.button)
227 {
228 case 0:
229 g_but_00_joy1=true;
230 break;
231
232 case 1:
233 g_but_01_joy1=true;
234 break;
235
236 case 2:
237 g_but_02_joy1=true;
238 break;
239
240 case 3:
241 g_but_03_joy1=true;
242 break;
243
244 case 4:
245 g_but_04_joy1=true;
246 break;
247
248 case 5:
249 g_but_05_joy1=true;
250 break;
251
252 case 6:
253 g_but_06_joy1=true;
254 break;
255
256 case 7:
257 g_but_07_joy1=true;
258 break;
259
260 case 8:
261 g_but_08_joy1=true;
262 break;
263
264 case 9:
265 g_but_09_joy1=true;
266 break;
267
268 case 10:
269 g_but_10_joy1=true;
270 break;
271
272 case 11:
273 g_but_11_joy1=true;
274 break;
275
276 case 12:
277 g_but_12_joy1=true;
278 break;
279 }
280 break;
281
282 case ALLEGRO_EVENT_JOYSTICK_BUTTON_UP:
283 switch(ob_event.joystick.button)
284 {
285 case 0:
286 g_but_00_joy1=false;
287 break;
288
289 case 1:
290 g_but_01_joy1=false;
291 break;
292
293 case 2:
294 g_but_02_joy1=false;
295 break;
296
297 case 3:
298 g_but_03_joy1=false;
299 break;
300
301 case 4:
302 g_but_04_joy1=false;
303 break;
304
305 case 5:
306 g_but_05_joy1=false;
307 break;
308
309 case 6:
310 g_but_06_joy1=false;
311 break;
312
313 case 7:
314 g_but_07_joy1=false;
315 break;
316
317 case 8:
318 g_but_08_joy1=false;
319 break;
320
321 case 9:
322 g_but_09_joy1=false;
323 break;
324
325 case 10:
326 g_but_10_joy1=false;
327 break;
328
329 case 11:
330 g_but_11_joy1=false;
331 break;
332
333 case 12:
334 g_but_12_joy1=false;
335 break;
336 }
337 break;
338
339 case ALLEGRO_EVENT_TIMER:
340 if(al_is_event_queue_empty(ptr_event_queue))
341 {
342 g_redraw=true;
343 }
344 break;
345 }
346}
1//global_registers.hpp for global variables
2
3//****************************
4//*** global_registers.hpp ***
5//****************************
6
7//Version 1.0
8
9//Developed with Dev C++ 5.2.0.3 & Allegro 5.0.6
10
11//By Alain Galiani
12//Dedalusman
13//nageondu@gmail.com
14
15//Start 20 08 2012
16//Finished 00 00 2013
17//Last updat 20 08 2012
18
19//History:
20
21/*
22
23*/
24
25//*** GLOBALES VARIABLES ***
26
27bool g_game_loop=true;//boucle de jeu
28bool g_redraw=false;//calcul de l'image apres les events
29
30//variable pour la position de la sourie
31lm4o g_mouse_pos_x,g_mouse_pos_y;
32
33//variables booleen pour les bouttons de la souris
34bool g_but_mouse_right=false,
35 g_but_mouse_left=false;
36
37//variables pour les axes du joystick
38flo4 g_x1_axis_joy1=0,
39 g_y1_axis_joy1=0,
40 g_x2_axis_joy1=0,
41 g_y2_axis_joy1=0,
42 g_x3_axis_joy1=0,
43 g_y3_axis_joy1=0,
44 g_x4_axis_joy1=0,
45 g_y4_axis_joy1=0,
46 g_x5_axis_joy1=0,
47 g_y5_axis_joy1=0;
48
49//variables booleen pour les bouttons du joystik1
50bool g_but_00_joy1=false,
51 g_but_01_joy1=false,
52 g_but_02_joy1=false,
53 g_but_03_joy1=false,
54 g_but_04_joy1=false,
55 g_but_05_joy1=false,
56 g_but_06_joy1=false,
57 g_but_07_joy1=false,
58 g_but_08_joy1=false,
59 g_but_09_joy1=false,
60 g_but_10_joy1=false,
61 g_but_11_joy1=false,
62 g_but_12_joy1=false;
63
64//variable pour le clavier
65bool g_key_up=false,
66 g_key_down=false,
67 g_key_left=false,
68 g_key_right=false;
|
Neil Walker
Member #210
April 2000
![]() |
How about a picture to show the problem, which is a little bit better than looking through 20k of code... Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
GibbSticks
Member #14,193
April 2012
![]() |
(is it against the forum rules to post in the ops native tongue in response to his/her(haha a girl on a.cc?) question?) use code tags < code > < /code > for your code also what libs are these? #include<class_cycles_seconde.hpp> #include<class_cercle.hpp> #include<global_registers.hpp> #include<class_global_inputs.hpp>
C++, C# developer Hitler was a fan of Chaplin. Chaplin was therefore responsible for the murder of millions of lives. |
Neil Walker
Member #210
April 2000
![]() |
^ that code wasn't there when I replied, just the attachments. GibbSticks said: haha a girl on a.cc? Last time I looked 'Alain' was a boy's name. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
dedalusman
Member #14,504
August 2012
|
the problem in the game_loop_problem.jpg Do you have an idea ? ...and I am a french boy, sorry |
l j
Member #10,584
January 2009
![]() |
I think if you offer both an English and his native language translation of your explanation it is allowed. Mais je ne suis pas certain.
|
|