Grrr C++ Help Me!

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2005
Posts: 2
Reputation: Zackery is an unknown quantity at this point 
Solved Threads: 0
Zackery Zackery is offline Offline
Newbie Poster

Grrr C++ Help Me!

 
0
  #1
May 21st, 2005
Ok hey, I have this program and i dont understand how Its not wiorking.
Thx for your time. :o

  1. #include <allegro.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5.  
  6. void main()
  7. {
  8.  
  9. int x,y,bx,by,af,al,ar,ab;
  10.  
  11. allegro_init();
  12. install_keyboard();
  13. install_timer();
  14. set_color_depth(16);
  15. set_gfx_mode(GFX_AUTODETECT,800,600,0,0);
  16.  
  17.  
  18. BITMAP *buffer, *back, *a, *b, *c, *d, *e, *f, *g, *h;
  19.  
  20. back=load_bitmap("back.bmp",0);
  21.  
  22. a=load_bitmap("gob-front-1.bmp",0);
  23. b=load_bitmap("gob-front-2.bmp",0);
  24. c=load_bitmap("gob-back-1.bmp",0);
  25. d=load_bitmap("gob-back-2.bmp",0);
  26. e=load_bitmap("gob-left-1.bmp",0);
  27. f=load_bitmap("gob-left-2.bmp",0);
  28. g=load_bitmap("gob-right-1.bmp",0);
  29. h=load_bitmap("gob-right-2.bmp",0);
  30.  
  31. x=300;
  32. y=250;
  33. bx=0;
  34. by=0;
  35. af=1;
  36. al=1;
  37. ar=1;
  38. ab=1;
  39.  
  40. buffer=create_bitmap(800,600);
  41.  
  42.  
  43. while(!key[KEY_ESC])
  44. {
  45. sit();
  46. }
  47. }
  48.  
  49.  
  50. END_OF_MAIN()
  51.  
  52.  
  53. void sit();
  54. {
  55.  
  56. if(af == 1)
  57. {
  58. blit(buffer,screen, 0, 0, 0, 0, 800,600);
  59. draw_sprite(buffer,back,bx,by);
  60. draw_sprite(buffer,a,x,y);
  61. delay (100);
  62. af=0; }
  63.  
  64. if(af == 0)
  65. {
  66. blit(buffer,screen, 0, 0, 0, 0, 800,600);
  67. draw_sprite(buffer,back,bx,by);
  68. draw_sprite(buffer,b,x,y);
  69. delay (100);
  70. af=1;
  71. }
  72. }
  73. }
  74.  
  75.  
  76. int left();
  77. {
  78. while(key[KEY_LEFT])
  79. {
  80. if(al == 1)
  81. {
  82. blit(buffer,screen, 0, 0, 0, 0, 800,600);
  83. draw_sprite(buffer,back,bx,by);
  84. draw_sprite(buffer,e,x,y);
  85. bx = bx + 1;
  86. delay (100);
  87. al=0; }
  88.  
  89. if(al == 0)
  90. {
  91. blit(buffer,screen, 0, 0, 0, 0, 800,600);
  92. draw_sprite(buffer,back,bx,by);
  93. draw_sprite(buffer,f,x,y);
  94. bx = bx + 1;
  95. delay (100);
  96. al=1;
  97. }
  98. }
  99. }
  100.  
  101.  
  102. int right();
  103. {
  104. while(key[KEY_RIGHT])
  105. {
  106. if(ar == 1)
  107. {
  108. blit(buffer,screen, 0, 0, 0, 0, 800,600);
  109. draw_sprite(buffer,back,bx,by);
  110. draw_sprite(buffer,g,x,y);
  111. bx = bx - 1;
  112. delay (100);
  113. ar=0; }
  114.  
  115. if(ar == 0)
  116. {
  117. blit(buffer,screen, 0, 0, 0, 0, 800,600);
  118. draw_sprite(buffer,back,bx,by);
  119. draw_sprite(buffer,h,x,y);
  120. bx = bx - 1;
  121. delay (100);
  122. ar=1;
  123. }
  124. }
  125. }
  126.  
  127. int back();
  128. {
  129. while(key[KEY_UP])
  130. {
  131. if(ab == 1)
  132. {
  133. blit(buffer,screen, 0, 0, 0, 0, 800,600);
  134. draw_sprite(buffer,back,bx,by);
  135. draw_sprite(buffer,c,x,y);
  136. bx = by + 1;
  137. delay (100);
  138. ab=0; }
  139.  
  140. if(ab == 0)
  141. {
  142. blit(buffer,screen, 0, 0, 0, 0, 800,600);
  143. draw_sprite(buffer,back,bx,by);
  144. draw_sprite(buffer,d,x,y);
  145. bx = by + 1;
  146. delay (100);
  147. ab=1;
  148. }
  149. }
  150. }
  151.  
  152.  
  153. int front();
  154. {
  155. while(key[KEY_DOWN])
  156. {
  157. if(af == 1)
  158. {
  159. blit(buffer,screen, 0, 0, 0, 0, 800,600);
  160. draw_sprite(buffer,back,bx,by);
  161. draw_sprite(buffer,a,x,y);
  162. bx = by - 1;
  163. delay (100);
  164. ab=0; }
  165.  
  166. if(af == 0)
  167. {
  168. blit(buffer,screen, 0, 0, 0, 0, 800,600);
  169. draw_sprite(buffer,back,bx,by);
  170. draw_sprite(buffer,b,x,y);
  171. bx = by - 1;
  172. delay (100);
  173. ab=1;
  174. }
  175. }
  176. }
  177.  
  178. void delay(clock_t wt)
  179. {
  180. clock_t t1, t2;
  181.  
  182. t1 = clock();
  183. t2 = clock();
  184.  
  185. while (t2 - t1 <= wt)
  186. {
  187. t2 = clock();
  188.  
  189. }
  190. }
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 149
Reputation: Electrohead is an unknown quantity at this point 
Solved Threads: 1
Electrohead's Avatar
Electrohead Electrohead is offline Offline
Junior Poster

Re: Grrr C++ Help Me!

 
0
  #2
May 27th, 2005
Although I have no idea, i have taken the liberty of compling it to see the problem.

Please be more specific Zackery. It is hard to determine a problem if we haven't even seen the compile log. Here is the compile log from Dev-C++:

  1. Compiler: Default compiler
  2. Building Makefile: "C:\Dev-Cpp\Makefile.win"
  3. Executing make...
  4. make.exe -f "C:\Dev-Cpp\Makefile.win" all
  5. g++.exe -c Untitled2.cpp -o Untitled2.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
  6.  
  7. Untitled2.cpp:2: error: `main' must return `int'
  8. Untitled2.cpp: In function `int main(...)':
  9. Untitled2.cpp:6: error: `allegro_init' undeclared (first use this function)
  10. Untitled2.cpp:6: error: (Each undeclared identifier is reported only once for each function it appears in.)
  11. Untitled2.cpp:7: error: `install_keyboard' undeclared (first use this function)
  12. Untitled2.cpp:8: error: `install_timer' undeclared (first use this function)
  13. Untitled2.cpp:9: error: `set_color_depth' undeclared (first use this function)
  14. Untitled2.cpp:10: error: `GFX_AUTODETECT' undeclared (first use this function)
  15. Untitled2.cpp:10: error: `set_gfx_mode' undeclared (first use this function)
  16. Untitled2.cpp:13: error: `BITMAP' undeclared (first use this function)
  17. Untitled2.cpp:13: error: `buffer' undeclared (first use this function)
  18. Untitled2.cpp:13: error: `back' undeclared (first use this function)
  19. Untitled2.cpp:13: error: `a' undeclared (first use this function)
  20. Untitled2.cpp:13: error: `b' undeclared (first use this function)
  21. Untitled2.cpp:13: error: `c' undeclared (first use this function)
  22. Untitled2.cpp:13: error: `d' undeclared (first use this function)
  23. Untitled2.cpp:13: error: `e' undeclared (first use this function)
  24. Untitled2.cpp:13: error: `f' undeclared (first use this function)
  25. Untitled2.cpp:13: error: `g' undeclared (first use this function)
  26. Untitled2.cpp:13: error: `h' undeclared (first use this function)
  27. Untitled2.cpp:15: error: `load_bitmap' undeclared (first use this function)
  28.  
  29. Untitled2.cpp:35: error: `create_bitmap' undeclared (first use this function)
  30. Untitled2.cpp:38: error: `key' undeclared (first use this function)
  31. Untitled2.cpp:38: error: `KEY_ESC' undeclared (first use this function)
  32. Untitled2.cpp:40: error: `sit' undeclared (first use this function)
  33. Untitled2.cpp: At global scope:
  34. Untitled2.cpp:48: error: expected constructor, destructor, or type conversion before "void"
  35.  
  36. Untitled2.cpp:48: error: expected `,' or `;' before "void"
  37. Untitled2.cpp:49: error: expected unqualified-id before '{' token
  38. Untitled2.cpp:49: error: expected `,' or `;' before '{' token
  39. Untitled2.cpp:68: error: expected declaration before '}' token
  40.  
  41. make.exe: *** [Untitled2.o] Error 1
  42.  
  43. Execution terminated
  44.  
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 12
Reputation: cscotty is an unknown quantity at this point 
Solved Threads: 0
cscotty cscotty is offline Offline
Newbie Poster

Re: Grrr C++ Help Me!

 
0
  #3
Jun 6th, 2005
Seems as if you didnt declare a few variables and more....Im an absolute beginner so that's all I was able to catch.

Scott
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: Dogtree is an unknown quantity at this point 
Solved Threads: 3
Dogtree's Avatar
Dogtree Dogtree is offline Offline
Posting Whiz in Training

Re: Grrr C++ Help Me!

 
0
  #4
Jun 6th, 2005
>> Here is the compile log from Dev-C++:
That's assuming that Zackery doesn't have Allegro installed, which he probably does. Almost all of those errors and warnings have to do with you not compiling and linking correctly with a third party library.

>> i dont understand how Its not wiorking
How is it not working? Do you get compiler errors? Linker errors? Run-time errors? Is the output just not what you expected? Your question is too vague.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC