Setting up a very simple tile based system

high,

i have recently decided to make a pacman clone. (keep in mind i am new to
all this, but i have allready finished a pong clone). i figured making it
tile based was my best bet. anyway, i use 32x32 tiles and i make an array
thats 19x25 in size. i have 3 kinds of graphics, open space, wall, and
player. i fill in my array using enums to represent a specific tile, then i
use 2 for loops to feed in the numbers and draw the approriate tile. so far,
this works great. accept i cant figure out how to do collision detection.
for now, i can only move my player 32 pixels at a time, and he will collide
with walls. but this looks stupid, moving 32 pixels at a time looks bad. if
i try having him move a smaller amount, like 2 or 5 pixels, he runs right
through the walls. this is because i have no tiles for any pixels between
those that are divisable by 32. how do i do this? at first i tried making an
array that was like bool map [800][600], meaning an element for each pixel.
i then would use a for loop to make each value to false (as in open space),
then i used for loops and the walls coordinates and w/h to fill in where the
walls were, and did colliosn that way. but it was very sloppy and didnt work
too well. could someone maybe explain to me how this is done? keep in mind
im a newbie =). also, i know that might be asking a lot, so sending me some
links or something would still be appreciated. thank you.

oh, and im using windows and c++ if that matters_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar ? get it now!
http://clk.atdmt.com/AVE/go/onm00200415ave/direct/01/

This is OT in this list, but Bob B can point you to the very good Game
programmer list, where this is very on topic.

PS. I answer to you off list.On Wednesday 03 March 2004 09:33, Graveyard Filla wrote:

high,

i have recently decided to make a pacman clone. (keep in mind i am
new to all this, but i have allready finished a pong clone). i
figured making it tile based was my best bet. anyway, i use 32x32
tiles and i make an array thats 19x25 in size. i have 3 kinds of
graphics, open space, wall, and player. i fill in my array using
enums to represent a specific tile, then i use 2 for loops to feed in
the numbers and draw the approriate tile. so far, this works great.
accept i cant figure out how to do collision detection. for now, i
can only move my player 32 pixels at a time, and he will collide with
walls. but this looks stupid, moving 32 pixels at a time looks bad.
if i try having him move a smaller amount, like 2 or 5 pixels, he
runs right through the walls. this is because i have no tiles for any
pixels between those that are divisable by 32. how do i do this? at
first i tried making an array that was like bool map [800][600],
meaning an element for each pixel. i then would use a for loop to
make each value to false (as in open space), then i used for loops
and the walls coordinates and w/h to fill in where the walls were,
and did colliosn that way. but it was very sloppy and didnt work too
well. could someone maybe explain to me how this is done? keep in
mind im a newbie =). also, i know that might be asking a lot, so
sending me some links or something would still be appreciated. thank
you.

oh, and im using windows and c++ if that matters

high,

i have recently decided to make a pacman clone. (keep in mind i am
new to all this, but i have allready finished a pong clone). i
figured making it tile based was my best bet. anyway, i use 32x32
tiles and i make an array thats 19x25 in size. i have 3 kinds of
graphics, open space, wall, and player. i fill in my array using
enums to represent a specific tile, then i use 2 for loops to feed in
the numbers and draw the approriate tile. so far, this works great.
accept i cant figure out how to do collision detection. for now, i
can only move my player 32 pixels at a time, and he will collide with
walls. but this looks stupid, moving 32 pixels at a time looks bad.
if i try having him move a smaller amount, like 2 or 5 pixels, he
runs right through the walls. this is because i have no tiles for any
pixels between those that are divisable by 32. how do i do this? at
first i tried making an array that was like bool map [800][600],
meaning an element for each pixel. i then would use a for loop to
make each value to false (as in open space), then i used for loops
and the walls coordinates and w/h to fill in where the walls were,
and did colliosn that way. but it was very sloppy and didnt work too
well. could someone maybe explain to me how this is done? keep in
mind im a newbie =). also, i know that might be asking a lot, so
sending me some links or something would still be appreciated. thank
you.

oh, and im using windows and c++ if that matters

This is OT in this list, but Bob B can point you to the very good Game
programmer list, where this is very on topic.

Yep, take this over to the gameprogrammer.com mailing list (sign up at
gameprogrammer.com) andyou can probably get a good long discussion going
onthis topic.

	Bob PendletonOn Wed, 2004-03-03 at 11:59, Sami N??t?nen wrote:

On Wednesday 03 March 2004 09:33, Graveyard Filla wrote:

PS. I answer to you off list.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

±--------------------------------------+

Hello! I’m loading a bitmap with this code.

// …
mBild = SDL_DisplayFormat(SDL_LoadBMP(patchToBMP));
if (mBild == 0)
{
std::cerr << “ERROR” << std::endl;
return 1;
}
// …

And when I run the program I get.
(gdb)r
Starting program: /home/danne/projects/shooter/shooter
[New Thread 16384 (LWP 7893)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 7893)]
0x4004ae02 in SDL_MapSurface () from /usr/lib/libSDL-1.2.so.0
Current language: auto; currently c
(gdb)bt
#0 0x4004ae02 in SDL_MapSurface () from /usr/lib/libSDL-1.2.so.0
#1 0x4004b75a in SDL_LowerBlit () from /usr/lib/libSDL-1.2.so.0
#2 0x4004b9fd in SDL_UpperBlit () from /usr/lib/libSDL-1.2.so.0
#3 0x08049a78 in Back::Draw(SDL_Surface*) (this=0x80560d8, screen=0x804d768)
at cBack.cpp:53
#4 0x08048d80 in Spel::MainLoop() (this=0x804a918) at cSpel.cpp:49
#5 0x08049d75 in main () at main.cpp:7
#6 0x4018abb4 in __libc_start_main () from /lib/libc.so.6

I’m a beginner on this and can’t locate what’s wrong.

// Danne

Daniel L?nnstr?m wrote:

Hello! I’m loading a bitmap with this code.

// …
mBild = SDL_DisplayFormat(SDL_LoadBMP(patchToBMP));
if (mBild == 0)
{
std::cerr << “ERROR” << std::endl;
return 1;
}
// …

Check that you only use SDL_DisplayFormat after you’ve called
SDL_SetVideoMode().

Sebastian