Mail Archives: djgpp/1999/03/14/20:08:30
I'm afraid there are quite a few problems with your code. I'm
not trying to be obnoxious -- it's good to help people -- but
when you do you have to make sure the advice you give is
correct. Testing sample programs is a good idea.
On 14 Mar 99 at 18:10, John Carbrey wrote:
> fadeout(1000);
Is this meant to be Allegro's `fade_out' function? If so, note
that the parameter ranges from 0 to 64, 64 being an immediate
change. Passing 1000 is just the same as passing 64.
In fact if it is meant to be Allegro's function, the second
bitmap will never appear. You also forgot to declare and set
the palette, and perhaps should have used two different
palettes in case the images used different palettes. Of course
if you're not in a 8 bpp mode the palettes aren't relevant and
you can ignore this paragraph.
Also, you created two 640x480 bitmaps, then loaded two more.
The two you created yourself still exist, but are no longer
referenced by your code. Functions like `load_bitmap' create
their own bitmaps internally -- you don't need to (and
shouldn't) do this yourself. How could the function know
where the bitmap you created is?
Finally, it's a good idea to always check that functions like
`create_bitmap' and `load_bitmap' succeed. If they fail,
they'll return NULL pointers. You can easily test for this
and exit in some appropriate way. If you don't, these NULL
pointers will be passed through the rest of your code as if
nothing had gone wrong, and eventually (if you're lucky) an
error will occur somewhere else in the program. Tracing this
back to the original problem can be very awkward. If you're
not lucky, you won't find out about the problem until you send
the program to someone else and it crashes on their computer.
Debugging unreproduceable bugs like these is not fun, and the
best thing to do is to avoid creating them.
--
George
- Raw text -