Ok hey, I have this program and i dont understand how Its not wiorking.
Thx for your time. :o

#include <allegro.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void main()
 {

 int x,y,bx,by,af,al,ar,ab;

  allegro_init();
  install_keyboard();
  install_timer();
  set_color_depth(16);
  set_gfx_mode(GFX_AUTODETECT,800,600,0,0);


  BITMAP  *buffer, *back, *a, *b, *c, *d, *e, *f, *g, *h;
  
  back=load_bitmap("back.bmp",0);

  a=load_bitmap("gob-front-1.bmp",0);
  b=load_bitmap("gob-front-2.bmp",0);
  c=load_bitmap("gob-back-1.bmp",0);
  d=load_bitmap("gob-back-2.bmp",0);
  e=load_bitmap("gob-left-1.bmp",0);
  f=load_bitmap("gob-left-2.bmp",0);
  g=load_bitmap("gob-right-1.bmp",0);
  h=load_bitmap("gob-right-2.bmp",0);

  x=300;
  y=250;
  bx=0;
  by=0;
  af=1;
  al=1;
  ar=1;
  ab=1;

  buffer=create_bitmap(800,600);
  

while(!key[KEY_ESC])
  {
  sit();
  }
  }
  

 END_OF_MAIN()


void sit();
    {

if(af == 1)
        {
             blit(buffer,screen, 0, 0, 0, 0, 800,600);
             draw_sprite(buffer,back,bx,by);
             draw_sprite(buffer,a,x,y);
             delay (100);
             af=0; }

if(af == 0)
        {
             blit(buffer,screen, 0, 0, 0, 0, 800,600);
             draw_sprite(buffer,back,bx,by);
             draw_sprite(buffer,b,x,y);
             delay (100);
             af=1;
}
}
}


int left();
  {
while(key[KEY_LEFT])
{
     if(al == 1)
        {
             blit(buffer,screen, 0, 0, 0, 0, 800,600);
             draw_sprite(buffer,back,bx,by);
             draw_sprite(buffer,e,x,y);
             bx = bx + 1;
             delay (100);
             al=0; }

     if(al == 0)
        {
             blit(buffer,screen, 0, 0, 0, 0, 800,600);
             draw_sprite(buffer,back,bx,by);
             draw_sprite(buffer,f,x,y);
             bx = bx + 1;
             delay (100);
             al=1;
}
}
}


int right();
   {
while(key[KEY_RIGHT])
{
     if(ar == 1)
        {
             blit(buffer,screen, 0, 0, 0, 0, 800,600);
             draw_sprite(buffer,back,bx,by);
             draw_sprite(buffer,g,x,y);
             bx = bx - 1;
             delay (100);
             ar=0; }

     if(ar == 0)
        {
             blit(buffer,screen, 0, 0, 0, 0, 800,600);
             draw_sprite(buffer,back,bx,by);
             draw_sprite(buffer,h,x,y);
             bx = bx - 1;
             delay (100);
             ar=1;
}
}
}

int back();
{
while(key[KEY_UP])
{
     if(ab == 1)
        {
             blit(buffer,screen, 0, 0, 0, 0, 800,600);
             draw_sprite(buffer,back,bx,by);
             draw_sprite(buffer,c,x,y);
             bx = by + 1;
             delay (100);
             ab=0; }

     if(ab == 0)
        {
             blit(buffer,screen, 0, 0, 0, 0, 800,600);
             draw_sprite(buffer,back,bx,by);
             draw_sprite(buffer,d,x,y);
             bx = by + 1;
             delay (100);
             ab=1;
}
}
}


int front();
{
while(key[KEY_DOWN])
{
     if(af == 1)
        {
             blit(buffer,screen, 0, 0, 0, 0, 800,600);
             draw_sprite(buffer,back,bx,by);
             draw_sprite(buffer,a,x,y);
             bx = by - 1;
             delay (100);
             ab=0; }

     if(af == 0)
        {
             blit(buffer,screen, 0, 0, 0, 0, 800,600);
             draw_sprite(buffer,back,bx,by);
             draw_sprite(buffer,b,x,y);
             bx = by - 1;
             delay (100);
             ab=1;
}
}
}

   void delay(clock_t wt)
{
	clock_t t1, t2;

	t1 = clock();
	t2 = clock();

	while (t2 - t1 <= wt)
		{
			t2 = clock();

		}
}
Member Avatar for Electrohead

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++:

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing  make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
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"   

Untitled2.cpp:2: error: `main' must return `int'
Untitled2.cpp: In function `int main(...)':
Untitled2.cpp:6: error: `allegro_init' undeclared (first use this function)
Untitled2.cpp:6: error: (Each undeclared identifier is reported only once for each function it appears in.)
Untitled2.cpp:7: error: `install_keyboard' undeclared (first use this function)
Untitled2.cpp:8: error: `install_timer' undeclared (first use this function)
Untitled2.cpp:9: error: `set_color_depth' undeclared (first use this function)
Untitled2.cpp:10: error: `GFX_AUTODETECT' undeclared (first use this function)
Untitled2.cpp:10: error: `set_gfx_mode' undeclared (first use this function)
Untitled2.cpp:13: error: `BITMAP' undeclared (first use this function)
Untitled2.cpp:13: error: `buffer' undeclared (first use this function)
Untitled2.cpp:13: error: `back' undeclared (first use this function)
Untitled2.cpp:13: error: `a' undeclared (first use this function)
Untitled2.cpp:13: error: `b' undeclared (first use this function)
Untitled2.cpp:13: error: `c' undeclared (first use this function)
Untitled2.cpp:13: error: `d' undeclared (first use this function)
Untitled2.cpp:13: error: `e' undeclared (first use this function)
Untitled2.cpp:13: error: `f' undeclared (first use this function)
Untitled2.cpp:13: error: `g' undeclared (first use this function)
Untitled2.cpp:13: error: `h' undeclared (first use this function)
Untitled2.cpp:15: error: `load_bitmap' undeclared (first use this function)

Untitled2.cpp:35: error: `create_bitmap' undeclared (first use this function)
Untitled2.cpp:38: error: `key' undeclared (first use this function)
Untitled2.cpp:38: error: `KEY_ESC' undeclared (first use this function)
Untitled2.cpp:40: error: `sit' undeclared (first use this function)
Untitled2.cpp: At global scope:
Untitled2.cpp:48: error: expected constructor, destructor, or type conversion before "void"

Untitled2.cpp:48: error: expected `,' or `;' before "void"
Untitled2.cpp:49: error: expected unqualified-id before '{' token
Untitled2.cpp:49: error: expected `,' or `;' before '{' token
Untitled2.cpp:68: error: expected declaration before '}' token

make.exe: *** [Untitled2.o] Error 1

Execution terminated

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

>> 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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.