Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » SIMPLY game with ALLEGRO

This thread is locked; no one can reply to it. rss feed Print
SIMPLY game with ALLEGRO
a b
Member #8,092
December 2006

I want make game. I have got board (chart): http://img474.imageshack.us/img474/7083/planst5.png
and pawn (checker):
http://img381.imageshack.us/img381/121/pawnjg7.png

Pawn is on field number 6, player throws bone and pawn has passages about this number of fields on left or right - player choose.

I have got this programm in c++:

1 
2#include<iostream>
3#include<ctime>
4#include<cstring>
5using namespace std;
6 
7int main ()
8{
9
10 int tab[11]={1,2,3,4,5,6,7,8,9,10,11};
11 int *index=&tab[5];
12 int *start=&tab[0];
13 int *end=&tab[10];
14
15 int eye;
16 srand (time(0));
17 int i=0;
18 cout<<"You are now on field number 6."<<endl;
19
20 while (i!=100)
21 {
22 eye = 1+rand()%6;
23 cout<<"The number of eyes in throw the bone "<<eye<<endl;
24 cout<<endl;
25 cout<<endl;
26 cout<<"Press l if you want go on left or r if you want go on right"<<endl;
27 string b;
28 cin>>b;
29 cout<<endl;
30 if (b=="l")
31 {
32 if ((index-eye)>=start)
33 {
34 index=index-eye;
35 cout<<"You are now on field number "<<*index<<endl;
36 }
37 else
38 {
39 index=end-(eye-*index);
40 cout<<"You are now on field number "<<*index<<endl;
41 }
42
43 }
44
45 else if (b=="r")
46 {
47
48 if ((index+eye)<=end)
49 {
50 index=index+eye;
51 cout<<"You are now on field number "<<*index<<endl;
52 }
53 else
54 {
55 index=start+(eye-(*end-*index))-1;
56 cout<<"You are now on field number "<<*index<<endl;
57 }
58 }
59 i++;
60 }
61
62
63 system ("pause");
64 return 0;
65
66}

And I have part of code with library ALLEGRO – but I don’t know what I should do have I can join this two codes ????

1#include <allegro.h>
2 
3int main()
4{
5BITMAP *plan = NULL;
6BITMAP *pawn = NULL;
7 
8allegro_init();
9install_keyboard();
10set_color_depth(16);
11set_gfx_mode(GFX_AUTODETECT,1280,1024,0,0);
12set_palette(default_palette);
13clear_to_color(screen,15);
14 
15plan = load_bitmap("plan.bmp",default_palette);
16pawn = load_bitmap("pawn.bmp",default_palette);
17 
18 
19 
20 blit(plan,screen,0,0,0,0,plan->w,plan->h);
21 blit(pawn,screen,0,0,0,0,pawn->w,pawn->h);
22 
23 
24destroy_bitmap(plan);
25destroy_bitmap(pawn);
26 
27readkey();
28allegro_exit();
29return 0;
30}
31END_OF_MAIN()

BAF
Member #2,981
December 2002
avatar

Uhm... are you serious? Allegro isn't any special concept, just use your old program and use allegro for the drawing routines.

a b
Member #8,092
December 2006

I am noob in library ALLEGRO - could you help me ? :(

Steve Terry
Member #1,989
March 2002
avatar

You may have to do something else for cin since you cannot just grab char input without a console. Look into the text routines in allegro to put text on the screen, and the allegro key functions. Should get you started.

[edit]
We won't write it for you if that's what you are asking. Look into the allegro examples folder for code examples.
[/edit]

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

X-G
Member #856
December 2000
avatar

/facepalm

Move along, folks.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

peelemachine
Member #8,085
December 2006

Try learn english

You're damned if you do, and you're damned if you don't.

ngiacomelli
Member #5,114
October 2004

peelemachine said:

Try learn english

I could say the same to you, troll. For the record, it appears most of these problems have been resolved in another thread.

peelemachine
Member #8,085
December 2006

But I left out the "to" on purpose... hahaha

You're damned if you do, and you're damned if you don't.

LennyLen
Member #5,313
December 2004
avatar

Quote:

But I left out the "to" on purpose... hahaha

You missed some punctuation too (in both posts). :P

GullRaDriel
Member #3,861
September 2003
avatar

Candies for all !

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Richard Phipps
Member #1,632
November 2001
avatar

Go to: