http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

TheGrumpyProgrammer



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Borland Turbo C BGI Graphics Library



Well, nobody's answered this so I'll give it a shot. I'm probably just 
telling you stuff you already know but here it goes.
I'm assuming you can draw an image on the screen if you are getting your 
logo up there. The ugly way to draw a sprite would be to load an image, 
display it for a while (usually a fraction of a second)) and then load 
another image in it's place that is the next frame of the sprite. That's the 
general idea but there are a few things that can be done to improve it.
First load all the frames of the sprite before hand. You could load 10 
images into memory (or even better, vram) or the prefered method is create 
an image that has all the frames on it. This looks a bit like graph paper 
with one frame in each square. I just put up a sample sprite on my web page 
at http://home.earthlink.net/~kimnjef/sprite.gif
I didn't use the graph lines (or cells) but I've seen lot that do.
Then as you loop through you just draw the part of the image that you want 
to. Here's some psudo code for this. (it should be close to working c but 
I'm not testing it)

int DrawCell(int cellwidth, int cellheight, int cellsacross,
                int cellsdown, int framenumber){
//cellwidth, cellheight are cell (frame) dimensions
//cellsacross and cellsdown are then number of cells across and down
//and framenumber is the cell you are on. This works if your first
//frame is # 0

int yloop;
startx = cellwidth * (framenumber % cellsacross);
//here's that mod function again
starty = cellheight * (framenumber % cellsdown);

display_buffer = (ydrawlocation * SCREENWIDTH) + xdrawlocation;
// set display pointer to correct x,y address for sprite.

sprite1_buffer = (starty * cellwidth * cellsacross) + startx;
//set sprite pointer to point to the correct frame.


for (yloop = 0; yloop < cellheight; yloop++){
  memcpy((void *)display_buffer, (void *)sprite1_buffer, cellwidth);
  displaybuffer += SCREENWIDTH;
  sprite1_buffer += cellwidth * cellsacross;
}

}//end DrawCell

That's just off the top of my head so it's not perfect. depending on the 
implementation there's sure to be a few one-off errors but it's the general 
idea that counts.

now all you do is call this (your working function) whenever you want to 
change frames of the sprite.


Jeff


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

Can somebody help me? I need to draw a simple sprite on the screen,
but I don't know how, can somebody please help me? I have already
initiated the graphics mode, put up a logo screen and now I wish to
create some sprites. Please help. Came somebody also please tell me
how to get the inline assembler to work?

Kind regards,

Lionel Pinkhard

- --

	"The moon could not continue shining if it had to pay attention to
all the dogs barking at it." - Anonymous

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.0.2i

iQA/AwUBOSA5FhyaHU58l8oMEQJjcwCggSZRf7g5eCkRdOpQqb33jSyfzWkAoIQ8
oMw1XT28rZibzdg5TNHTYlv4
=BRUw
-----END PGP SIGNATURE-----

=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html