From: "Attala" Newsgroups: comp.os.msdos.djgpp Subject: Newbie problem Date: Tue, 26 Jan 1999 20:04:05 +0100 Organization: Tele2 Norway Public Access Lines: 79 Message-ID: <78l3o4$2sn$1@romeo.dax.net> NNTP-Posting-Host: mp-210-91.daxnet.no X-Newsreader: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com OK, I'm a real newbie at this C++ thing, but I really enjoy experimenting. I started out in one of the examples that follow Allegro, and wanted to write a program that displays a sprite and moves it. (Silly? Well, I told you I was a newbie). As you may have guessed it didn't work. I have included the source so that maybe a kind soul could tell me what I should do to make it work. The error message told me it exited because of signal from SIGSEV, (what is that?) I know I probably can find a good source code for moving sprites somewhere, but I would really like to know what is wrong with my own. Thanks The source code: #include #include #include "man.h" #include "allegro.h" DATAFILE *man_data; int card, w, h; int frame_number; BITMAP *sprite_buffer; int next; int xpos; int ypos; int *file_attr; void animate () { vsync(); vsync(); blit (sprite_buffer, screen, 0, 0, 120, 80, 85, 85); clear (sprite_buffer); next = FALSE; if (key[KEY_SPACE]) next = TRUE; if (frame_number == 5) { frame_number = 0; } else { frame_number++; } if (xpos == 400) { xpos = 0; } else { xpos++; } if (ypos == 400) { ypos = 0; } else { ypos++; } } int main (int argc, char *argv[]) { char datafile_name[256]; replace_filename(datafile_name, argv[0], "man.dat", sizeof(datafile_name)); allegro_init(); install_keyboard(); install_mouse(); clear_keybuf(); card = GFX_AUTODETECT; w = 800; h = 600; xpos = 0; ypos = 0; frame_number = 0; set_gfx_mode(card, w, h, 0, 0); man_data = load_datafile(datafile_name); sprite_buffer = create_bitmap (85, 85); clear (sprite_buffer); do { draw_sprite (sprite_buffer, man_data[frame_number].dat, xpos, ypos); animate(); } while (next == FALSE); clear_keybuf(); rectfill(screen, 0, 190, 800, 600, 0); textout (screen, font, "It works!!", 1, 190, 15); unload_datafile(man_data); allegro_exit(); readkey(); return 0; }