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 / Collision problem

Author
Message
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 24th Mar 2009 20:54
Ok well i was fooling around making a Heads up zelda type engine and i was going do collision by having a image that is black and red and then test if the position your trying to move is red if so then you can't walk on it.

i am going to switch to using memblocks but right now i'm using another bitmap and the point command. but it takes forever to execute.

what i'm doing is like if the direction is left then it checks every pixel from top to bottom and one pixel to the left of the character.
but it's not doing it quickly like it should. heres the function i'm using. (dir = 1(left) 2(up) 3(right) 4(down))

i know the character is a weird size (25x29) but i couldn't find a 32 by 32 character on google and i am new to pixel editing lol.



i think it's testing all the selects so its trying to cycle through left, right, top, and bottom but it still shouldn't take that long.


i tried putting a print command then a break to print the value to see if it was returning one for no reason but it wouldn't ever get to the break command. i don't know why though

New Site! Check it out \/
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th Mar 2009 00:30
dude u just stole ashingdas idea for DarkNOOBS!?!?!

that is EXACTLY his plan for our collision, how dare u!!!!
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 25th Mar 2009 00:57
lol i was thinking of doing this the same day i saw that post although i did use the same colors as him lol

but he didn't produce any code yet that i've seen so its not like i took his code and copied it. and thats a common way of doing it i think lol it seems like the best way



and I'm not sure if you're actually ticked off because its the same idea but if you are then why? it's just a idea.


and are you saying i stole the idea for the hole game or just the collision? lol cuz it is the same type of game. and actually i did decide to mess around with it because of dark noobs. i would have helped in that but I'm not to reliable in the hole team thing so i wouldn't work well with it.



and if you arn't mad then try not to use so many exlamations and don't bold stuff when your being sarcastic online its hard to tell the difference

New Site! Check it out \/
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th Mar 2009 02:09
well i was a little irratated but i prolly went a little overboard with the exclamations, lol. i guess ur right, its no like u stole his code so i can understand where ur coming from, 4 get i said nething and btw i have no clue on ur problem
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Mar 2009 02:39
Everytime you call point, point automatically calls a sync. Multiple syncs in a loop slow the code way down. So calling point in a segregated loop is a bad idea if you want speedy code.

If you want to use point for the detection instead of memblocks, you may want to create a bitmap that represents things by pixel only. For example, if your map fits on the screen, and the screen is 640,480 and there are ladders, and pipes, and whatever, then create a small bitmap where individual pixels represent the items. The offscreen bitmap might be 64x48 where each yellow pixel represents a ladder, and maybe each brown pixel represents the ground. Then, for every ten pixels moved by your character, you move your tracking position on the small bitmap and use point to test the color of the small bitmap to see if it's something that can be collided with. This is a pretty simple and fast method and should only be calling point once at the end of your main loop (and don't use SYNC because point will call SYNC itself). This method only deals in blocks so if your character had transparency it wouldn't matter - the collision would still detect.

But maybe you can expand on the idea.

Enjoy your day.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 25th Mar 2009 02:40 Edited at: 25th Mar 2009 02:49
lol ok it's all good.
and ok thats cool



Edit:

--Latch--

that might work(the 64/48 bitmap thing)

and the only reason i'm using point is because i'm still trying to find the way to get the position of a certain pixel in the memblock image. in my head it sounds like you should just be able to multiply x times y of the x/y position of the pixel but thats not right i don't think.

New Site! Check it out \/
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Mar 2009 03:33
I can't figure out a way to get the 64/48 thing to work without calling POINT multiple times, otherwise it only detexts a single position... check out the example - move the CYAN square with the arrow keys. Detection only occurs on the upper left corner of the block:




If you check around the forums, I've posted the memblock formula many times to get the colors.

Enjoy your day.
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th Mar 2009 03:59
o so thats how our collision is gona work, also ive never heard of the select, case, and endselect code family b4, that would have saved me alot of time had i known, tnx
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 26th Mar 2009 04:27
ya i didn't know about it till acouple months ago it can be very useful.


Latch

I'll search around see if i can find ti.

New Site! Check it out \/

Login to post a reply

Server time is: 2025-05-16 08:28:00
Your offset time is: 2025-05-16 08:28:00