Mail Archives: djgpp/1998/12/23/18:35:12
From: | "Jado" <jado AT www DOT jado DOT org>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Working on tilebased game...
|
Date: | Wed, 23 Dec 1998 23:36:35 -0000
|
Organization: | BT Internet
|
Lines: | 80
|
Message-ID: | <75ruhs$kn3$1@mendelevium.btinternet.com>
|
References: | <75lokv$srg$1 AT tron DOT sci DOT fi>
|
NNTP-Posting-Host: | host62-172-93-150.btinternet.com
|
X-Newsreader: | Microsoft Outlook Express 4.72.3007.0
|
X-MimeOLE: | Produced By Microsoft MimeOLE V4.72.3007.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hi Programmer,
This is a cheesy idea I know (and a little resource consumptive (is that
real word?) if you're loading the whole map in at the start of a level or
whatever), I'm guessing your map will be just a straight array of unsigned
chars (value 0-255 BTW), the way that I'm thinking about here (the one that
would be 'consumptive :) is to have something like
typedef struct{
unsigned char bmp_ref;
unsigned char unwalkable;
}map_element;
then
map_element tiles[];
(with tiles[0].bmp_ref 1 and tiles[0].unwalkable 0 (a nice walkable grass
tile))
then
map_element acid;
(with tiles[1].bmp_ref 2 and tiles[1].unwalkable 1 (an acidic tile that the
character knows not to walk on))
then a map like this
unsigned char map[5][5]={0,0,0,0,0,
0,0,0,0,0,
0,0,1,0,0,
0,0,0,0,0,
0,0,0,0,0};
then in your main loop, check where your character is, and if he's going to
wander onto any tiles with an unwalkable value of 1, stop him.
i.e. if(next_tile_we_are_wandering_onto.unwalkable)
It's a cheesy example and my codes probably all wrong (been a very long day
(bah humbug :)) so drop me an email if you can't get it working and I'll
give you a hand with it.
Hope I helped,
Jado.
---------------------------------------------------
Site admin www.jado.org
free webspace and banner exchange
for all keen coders :)
---------------------------------------------------
Programmer wrote in message <75lokv$srg$1 AT tron DOT sci DOT fi>...
>Hello!
>
>Yes i'am currently making tilebased game..This far everything has worked
>fine, but now i went to dead end. I don't know how to make or write the
code
>to check if player has walked on tile which isn't walkable.
>
>I have read some faqs about tilebased games, It explaind lot, In my mind
>everything is simple but when i should write it...bah.
>
>The writer of the faq file used 'unsigned char', because its lenght is from
>0 to 127 right?.
>
>The map is drawn with two FOR loops, so i was thinking can i use loops to
>check if player is in wrong place?.. Please, if you know how to write the
>code..I´m confused from all the texts i have read...I would use any code
>only as my reference, no need to copy.
>
>Thanks for all the help!!
>
>'''Using allegro v3.01b'''
>
>
>
- Raw text -