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 / JPG and point() command issues

Author
Message
Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 15th Aug 2006 00:24 Edited at: 15th Aug 2006 00:25
Alright so I made a simple side-scroller type game with color coded collision. Using the point command. If the little guy hits black, gravity is 0, otherwise hes falling. So the collision detection has been working well untill I decided to use a picture I took with my camera and put ladders and walls everywhere so that it looks like your interacting with the picture. And for some reason detection is not working with JPGs... I took a closer look at my picture after I saved it and the true black (0,0,0) I painted over the picture with, was (0,1,0) and other variants. How can I stop this from happening?

I am using Paint to modify the picture.

Oh and heres my code



Read Ender's Game. And all its sequels.
Trowbee
22
Years of Service
User Offline
Joined: 12th Apr 2003
Location: United Kingdom
Posted: 15th Aug 2006 01:59
JPG lose quality, by merging pixel colour with others surrounding it.
Unfortunately, if you want per-pixel collision, don't use JPG.
Use PNG, as its lossless, but also compressed so you don't get the nasty file sizes.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 15th Aug 2006 02:04 Edited at: 15th Aug 2006 02:06
Well, you could 1, paint over all of the black with a true black color. Or, you couls make it so that you are on the ground even when the black is not exactly black, but a small variation of black. Maybe if Point(x,y)<rgb(50,50,50) or something like that. I'm not sure how that RGB stuff works.

So, this:



becomes this:




This is a guess, so if it doesn't work change it right back

Use the Search/Replace feature for this it helps a TON. Select a certain amount of text or it will do the entire program. It's located in the EDIT tab.

Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 15th Aug 2006 02:28
OK, thank you. I will try that idea. How can I change my JPG images into PNG?

Read Ender's Game. And all its sequels.
Trowbee
22
Years of Service
User Offline
Joined: 12th Apr 2003
Location: United Kingdom
Posted: 15th Aug 2006 03:04 Edited at: 15th Aug 2006 03:57
if Point(x,y)<rgb(50,50,50) wouldn't work unfortunatly.
The rgb command performs a calculation on the red, green and blue values;
(red*[255x255]) + (blue*255) + (green)
So, rgb(50,50,50) yields an internal result of 3,264,050
Thats a lot of colour that could be mistaken as a side effect .
Pretty much anything without a high red value in would be mistaken for being black:
bright blue = rgb(0,0,255) = 255
bright green = rgb(0,255,0) = 65,025
And so on.

Something along the lines of:


should work as you want, although point is pretty slow, so be warned.
Returned values are 1, if the pixel is below 50, otherwise 0

Additionally, you can just use paint to convert to PNG. However, now that you saved as jpg, the pixels that have been lost are now lost, so you'd have to retake the photo in high quality or a different format.
Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 16th Aug 2006 06:12
OK, yeah, I converted the image to a PNG, and everything is working. Thanks.

Read Ender's Game. And all its sequels.

Login to post a reply

Server time is: 2025-05-25 08:25:09
Your offset time is: 2025-05-25 08:25:09