Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Tile based collision help

Author
Message
Darksyde
21
Years of Service
User Offline
Joined: 13th Sep 2003
Location: Staffordshire, UK
Posted: 17th Aug 2004 06:22
Righto, I've started making a game, well its just a level at the moment. Im using data statements to load in the 32*32 level tiles ala mario, but now i haven't got the foggiest how to make it so that my player sprite will stay on top of the ones that are platforms. Could someone please point me in the right direction, or give me some help. I could do with it being explained quite well, as my brains like a sieve... and i tend to kinda think i understand it when i actually dont a lot of the time.

Cheers



Im willing to find out what impossible means.
Darksyde
21
Years of Service
User Offline
Joined: 13th Sep 2003
Location: Staffordshire, UK
Posted: 17th Aug 2004 06:23
Sorry about double post. I couldnt find an edit button.

Also I intend on making the level scroll eventually. Will using data statements cause any problems with this?



Im willing to find out what impossible means.
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 17th Aug 2004 09:00
My tutorial covers that, click on the web button below my sig.



Darksyde
21
Years of Service
User Offline
Joined: 13th Sep 2003
Location: Staffordshire, UK
Posted: 17th Aug 2004 09:06
Thank you. That's just what I'm looking for. Lol, I had checked your site before, but somehow missed the tutorial. Anyways thanks a lot, I've bookmarked it for now. Will have a read through it in the morning.

Cheers



Im willing to find out what impossible means.
Darksyde
21
Years of Service
User Offline
Joined: 13th Sep 2003
Location: Staffordshire, UK
Posted: 18th Aug 2004 20:22
Hi. After looking through your tutorial I'm slightly confused. In the bit of code I've been using to draw my map, I haven't yet used arrays... which is probably my problem. I've just used the for loop with the data. I guess I need to pass those values into an array so I can redraw the map each loop, yes/no? Also, I notice that your tutorial says for DarkBasic Classic, I'm using DBPro (sorry, I should have mentioned) will this cause any problems?

Cheers



Im willing to find out what impossible means.
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 18th Aug 2004 21:08
It works perfectly with dbpro. You can use data as well, but I prefer arrays. You can create a new array, dim tiles(x,y), and use a for loop to load in the values from the datablock.



Darksyde
21
Years of Service
User Offline
Joined: 13th Sep 2003
Location: Staffordshire, UK
Posted: 19th Aug 2004 00:05
I couldn't really follow your tutorial, sorry.
This is my code so far,


Is there a way of dividing the whole screen up into 32*32 to tiles, and then locating which one the player is in? I guess this would also involve arrays. The I suppose I'd need to compare that array with the one that draws my map or something to find out which tiles cant be moved into... I guess I need just a very basic example of this.

Cheers



Im willing to find out what impossible means.
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 19th Aug 2004 02:00 Edited at: 19th Aug 2004 02:02
This code works with 32x32 tiles and a 32x32 mario. Otherwise you'll have to change it here and there.


I guess I should update my tutorial, using this better method.



Darksyde
21
Years of Service
User Offline
Joined: 13th Sep 2003
Location: Staffordshire, UK
Posted: 19th Aug 2004 04:18
Thanks again. Im still running into problems unfortunately. My source code is below...


The collision isn't working correctly... its like offset by a tile I think. (down one and right one)



Im willing to find out what impossible means.
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 19th Aug 2004 08:59
Play around with these numbers:



Add a -2, -1, +1, +2 or nothing at all at these places:

rem These for Y offset
if map(int(xpos / 32),int(ypos / 32)+1) = 2
ypos = (int(ypos / 32) -1) * 32 + 31
endif

rem These for X offset
if map(int(xpos / 32)+0,int(ypos / 32)) = 2
if x_move < 0
xpos = (int(xpos / 32) + 1)*32
else
xpos = (int(xpos / 32) - 1)*32 + 31
endif
endif



Darksyde
21
Years of Service
User Offline
Joined: 13th Sep 2003
Location: Staffordshire, UK
Posted: 19th Aug 2004 20:25
Yer, I managed to get the y-axis one right last night, by changing;

if map(int(xpos / 32),int(ypos / 32)+1) = 2
to
if map(int(xpos / 32),int(ypos / 32)+2) = 2

but I still haven't found the right combination for the x-axis.

Cheers



Im willing to find out what impossible means.
Darksyde
21
Years of Service
User Offline
Joined: 13th Sep 2003
Location: Staffordshire, UK
Posted: 24th Aug 2004 07:23
*bump* im still having the above problem. I can't get the x-axis collision working right. Anybody got any ideas at where I need to alter... Im pretty certain I tried all the combinations that were mentioned above.

Cheers



Im willing to find out what impossible means.
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 25th Aug 2004 23:48
There's tile base collision stuff here..

http://www.Dbcode.underwaredesign.com

Kevin Picone
[url]www.underwaredesign.com[/url]
Play Nice! Play Basic V2.21 (Out Now!)

Login to post a reply

Server time is: 2025-05-17 09:39:11
Your offset time is: 2025-05-17 09:39:11