From: uhfgood AT aol DOT com (Uhfgood) Newsgroups: comp.os.msdos.djgpp Subject: Re: Working on tilebased game... Lines: 56 NNTP-Posting-Host: ladder03.news.aol.com X-Admin: news AT aol DOT com Date: 21 Dec 1998 15:41:24 GMT Organization: AOL http://www.aol.com References: <75lokv$srg$1 AT tron DOT sci DOT fi> Message-ID: <19981221104124.13710.00002007@ng119.aol.com> To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I'm actually having the same problem (sort of) but i have figured some stuff out. (My stuff is in dos real mode... i'll be converting to allegro when this thing works out)... Anyways, you need to find the cell the player is in... assuming your screen is a matrix of tiles... terrain[ y ][ x ] - where y are the rows, and x is the columns... you need to for loops for y and x which are each of the cells in the matrix... then to find out what cell the player is in you use this formula x = player.x / cell_width; y = player.y / cell_height; But don't take this as the last word... when doing this you have to test for particular cases... if the player is touching the ground you'll have to test if he's touching the ground... something like y = player.y + cell_height / cell_height... for test to see if the player bumped his head, it's just player.y, if you're running right you have to check the left side, (that is checking to see if the player is touching the ground or the ceiling you have to check opposite sides, and the reason is because you want to player to go right off the edge not before the edge... And then you also have to test for cases of just moving left or right to see if the player hit a wall... in that case you have to test exactly where the players going... (if you aren't jumping or falling off but just moving, check for the side the player is going toward... left if he's going left or right if he's going right)... and usually i use some kind of if statement... like if the right side of the player is greater than the left side of the tile, then left side of the player is equal to the right side of the tile.... And things of this nature... just remember that the top and left sides of the player are player.x and player.y and the bottom and right are player.x + cell_width and player.y + cell_height... My code was too sloppy so I rewrote the steps i'm going to try today... first check what key is pressed and ONLY modify the velocity (or delta values if you prefer)... then check to see if the player hit the tile in any ways... then translate the player and update frame counters... (it really doesn't matter when you change the animation frames, since you should only be drawing after all movement is done) I hope this helps. If my explanation seems to cryptic, email me, and i'll try to re-explain it better... (I usually can the second time anyhow)... Also please email me for 2 things... 1 if you need help, and 2 if you manage to be successful before I! Well i'll ttyl -Keith Weatherby II -Uhfgood AT aol DOT com -Vice AT aol DOT com *Keith Weatherby II* *Uhfgood AT aol DOT com* *Vice AT gconn DOT com*