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! / Can anyone please help me?

Author
Message
DracoFireDragon
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location:
Posted: 25th Feb 2004 04:48
Ive been smacking my head against the wall for the past 2 hours trying to get any decent 'array'/data 2d collsion to work properly on this little atari-esque map I created Ive tryed pushing my red block man where he is supposed to go and trying to get the location between him and the X and Y parts of the map correctly, but it doesnt seem to work....

I would appriciate if some programmer whiz could fill me in or fiddle with my code....I made this in DB pro..


This source requires no media.....All tiles are 10x10 on a 320 x 240 screen You might need to put that screen resolution change in because I just enabled it within the DB pro file...
PowerFang
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location: Australia (But currently in the USA)
Posted: 25th Feb 2004 18:25
Check Collision:

Tile = Map(x,y)

REM if hit a wall
if Tile = 1
REM take back movement
Playerx# = Playerx# - xmove#
Playery# = Playery# - ymove#
endif

REM Draw player/refresh screen
Gosub DrawPlayer

return

This is real simple array collision and i use it alot. You need to add a xmove# and ymove# variable so when you hit a wall, you can take back the movement. Without these variables its alot harder to know which direction the sprite was travelling at the time so its harder to make it look like the sprite stops after hitting a wall.

I dont use DATA statements so i want quite sure how your code was going but if you convert it to an array then collision is easy.

One thing is you need to be able to work out what tile you are in so you can check collision.

But i'll load the code and come back with an alternative solution....or try
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 25th Feb 2004 18:43
Using floats for sprite location is a bad idea. I suggest integers since you're using screen coordinates.

Also, you are constantly incrementing your sprite number. No need for that. Create the sprites once and then control them.
--
TAZ

PowerFang
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location: Australia (But currently in the USA)
Posted: 25th Feb 2004 18:46
Heres the editted version of your program and it works. What i did:

* Converted the DATA into an array called MAP
* Made your FOR loop go from 0 -> 23 0 -> 31 to accomodate for the array
* Therefore i took out the -10 in the Sprite print statement
* Changed your collision detection and deleted what i didnt use (you can obviously put it back in) and i implemented a ymove# variable instead of (+ 0.8*Speed#)


CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 27th Feb 2004 06:16
Quote: "floating integers"


RGT may be gone but the best DBP forum is still alive and kicking, check it out.
http://www.dannywartnaby.co.uk/rgt/

Login to post a reply

Server time is: 2024-05-17 04:28:45
Your offset time is: 2024-05-17 04:28:45