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.

DarkBASIC Discussion / 2d problem

Author
Message
Gravekeeper
21
Years of Service
User Offline
Joined: 12th Nov 2002
Location:
Posted: 20th Nov 2002 23:16
I've been trying to make a program in DB where an image overlaps another image depending on whether the y position is higher or lower.

The character is behind a tree or in front of it, etc.

I need it to work with multiple images.

I've tried everything I can think of, but the only way I've got it to work is way too slow.

Does anyone know of a way to do this or maybe has some code for this?
TheCyborg
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 21st Nov 2002 00:34
How did you get it to work? (so that no one comes with a solution you already tried)

Try:


TheCyborg Development.
http://TheCyborg.Amok.dk
The Ultimate Source To DarkBASIC Programming.
Gravekeeper
21
Years of Service
User Offline
Joined: 12th Nov 2002
Location:
Posted: 21st Nov 2002 01:42
Well, I made a big bitmap and pasted my tiles onto it to make a map.

I then made another big bitmap of the same size and pasted all the images for trees, etc. where they needed to be.

Then I copied a section of the map from the 1st bitmap to the screen.

After that I got an image from a section of the 2nd bitmap using the same coordinates for the get image command.

Then pasted the character and the image I got onto the screen in order, depending on whether the character was higher than the tree.

I pasted them with black being transparent.

It's like I have 2 layers, the map and the objects, with the character pasted on top of that.

Anyway, this worked, but was way too slow.

Gravekeeper
21
Years of Service
User Offline
Joined: 12th Nov 2002
Location:
Posted: 21st Nov 2002 01:47
I tried it with sprites. It didn't work. Anyone have an answer?

Thanks for replying.

Stevil
21
Years of Service
User Offline
Joined: 31st Oct 2002
Location: Australia
Posted: 21st Nov 2002 01:47
I wrote code to handle this awhile back alas I don't have it on me so I'll just explain it

Basically how I did it was I'd store the "layer" position in an array I had *ponders* upto 5 layers in mine I believe it was. You have a for next loop loop threw the array, if the loop index matches the array

(small example)
for a = 1 to (# of images)
for b = 1 to 5
if Layer(a) = b
`Paste Image Here
Endif
Next b
Next a

This worked fine for me with 100+ images *ponders again* I may finish that project one day thinking about it, that was kinda funky.

Gravekeeper
21
Years of Service
User Offline
Joined: 12th Nov 2002
Location:
Posted: 21st Nov 2002 18:31
Thanks. I have thought about something like that, but I'd rather use the y position of the objects to determine which is pasted 1st,2nd,etc. I'll think about the layer thing though. Maybe I could get it to work.

The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 22nd Nov 2002 00:37
The sprites are drawn by number - i.e. a sprite with a higher number will be drawn over a sprite with a lower number. To draw your scene in the correct order, you will need to assign sprite numbers depending on the y coordinate. This means as you are changing sprite numbers round every so often, you'll need to recalculate offsets and mirrors and stuff based on what you are trying to draw, not the sprite number.
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 22nd Nov 2002 01:45
Id go with a 3d plain method

this would be an easy method to handle altering, whos in front issues that will be handled by altering the z dimension on the plains u want either forward or backwards etc.


here is a few functions that will help if u go this way




Login to post a reply

Server time is: 2024-04-16 10:26:16
Your offset time is: 2024-04-16 10:26:16