Re: A89: Re: Re: Tile-based Game Engine in C


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

Re: A89: Re: Re: Tile-based Game Engine in C




if it wasn't clear, "offset" in the DrawTile function is the number of the 
tile in the array. First being 0, second being 1, and so on. It's just 
pointer arithmetic.


void DrawTile (int x, int y, *GREYTILE tile, int offset)
{/*write some code to dereference the pointer and draw it.*/}

for you're map, you'll want a array of chars (if you don't have more than 
256 tiles, and I seriously doubt you will on the 89 =P)

Mike

>From: "Michael Cowart" <freakonaleash881@hotmail.com>
>Reply-To: assembly-89@lists.ticalc.org
>To: assembly-89@lists.ticalc.org
>Subject: Re: A89: Re: Re: Tile-based Game Engine in C
>Date: Mon, 20 Nov 2000 12:25:19 CST
>
>
>this works too;
>
>/*make a structure to hold the tile data (this one holds a 16x16 grey 
>tile*/
>
>typedef struct
>{
>unsigned int darkplane [16];
>unsigned int lightplane [16];
>} GREYTILE;
>
>/*store your tiles in a structure array*/
>
>GREYTILE tileset [1] = {
>
>//id #0 (a 16x16 black box)
>
>{{0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF},
>
>{{0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF}}
>}
>
>/*then write a function to draw the sprite, passing a pointer to the 
>array*/
>
>void DrawTile (int x, int y, *GREYTILE, int offset)
>{ //your code here
>}
>
>this works well, becuause you keep all the data together in memory, and all
>you are doing is passing a pointer to the draw function.
>
>Mike
>
>>From: Joshua Coyne <antgage@apk.net>
>>Reply-To: assembly-89@lists.ticalc.org
>>To: assembly-89@lists.ticalc.org
>>Subject: Re: A89: Re: Re: Tile-based Game Engine in C
>>Date: Sun, 19 Nov 2000 17:51:16 -0500
>>
>>
>>in C would it be something similar to:
>>
>>int sometile1[] = { 0x...};
>>
>>char tilearray[] = {&sometile1,...};
>>
>>Olle Hedman wrote:
>>
>> > You don't save the whole tiles in the array.
>> > What you do is you have an array with say a byte that represents which
>>tile
>> > number to display.
>> > then you have a pointerlist to the different sprites. if you find say
>>the
>> > number 32 in your array, you take the sprite located at the place the
>>32:nd
>> > pointer in the list points out and writes it to screen at the position
>> > designated to that place in the array.
>> > This way you change the list when you change levels, and reuse the same
>> > sprite at multiple places witout dubbling the data.
>> >
>> > ///Olle
>> >
>> > ----- Original Message -----
>> > From: "Josh 'Gage'" <antgage@apk.net>
>> > >
>> > > Yes, I believe you would create all the textures as 32x32 tiles, then
>>your
>> > > 'map' would basically be an array of what tiles to display. for
>>example in
>> > C
>> > > you can, I've never created one so I may be missing something...
>> > >
>> > > What are your thoughts pros? heh :)
>>
>>
>
>_________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>Share information about yourself, create your own public profile at
>http://profiles.msn.com.
>
>

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

Share information about yourself, create your own public profile at 
http://profiles.msn.com.