Get color on screen
Get color on screen
Hello !
I've been coding for some time now, my last creation was on PaLib and now I'm learning libnds.
I have a problem and can't manage to find an answer somewhere.
Is it possible to get the straight color on a DS screen ? I want to get color from a coordinate on the screen and then use it for other things.
I tried picking up some lines from the "Screenshot" example but it didn't work. I tried picking some lines from a thread on this forum but didn't too.
I'm pretty n00b with C/C++, but managed to understand a lot of things.
What I basically want to do with is collisions. I want a Tiled Rotating background, and my sprite collisionning (I know it's not a word) with parts of that background. Detecting the color would be a lot easier, I think, and I could do more varied stuff.
I'll stick here for a while, ask me questions if I'm not clear enough
Thanks for helping me
I've been coding for some time now, my last creation was on PaLib and now I'm learning libnds.
I have a problem and can't manage to find an answer somewhere.
Is it possible to get the straight color on a DS screen ? I want to get color from a coordinate on the screen and then use it for other things.
I tried picking up some lines from the "Screenshot" example but it didn't work. I tried picking some lines from a thread on this forum but didn't too.
I'm pretty n00b with C/C++, but managed to understand a lot of things.
What I basically want to do with is collisions. I want a Tiled Rotating background, and my sprite collisionning (I know it's not a word) with parts of that background. Detecting the color would be a lot easier, I think, and I could do more varied stuff.
I'll stick here for a while, ask me questions if I'm not clear enough
Thanks for helping me
Re: Get color on screen
Screenshot is the only way. Ripoff that demo more thoroughly until youve mastered it.
This made me think of a terrible, terrible. idea. You shouldn't do it, this is just to demonstrate how depraved I am.
One could adapt the GPU from an emulator into a more transferable format and use it to render to software buffers on the NDS. Might be useful for debugging. Might be useful for this. Will definitely be slow.
This made me think of a terrible, terrible. idea. You shouldn't do it, this is just to demonstrate how depraved I am.
One could adapt the GPU from an emulator into a more transferable format and use it to render to software buffers on the NDS. Might be useful for debugging. Might be useful for this. Will definitely be slow.
Re: Get color on screen
1- So you're telling me it's impossible to pick a single pixel ?
Dang, sure taking a screenshot will be slow.
2- If I understand well, you can't take a screenshot with an emulator ?
Maybe this is why my code wasn't working ._.
I had an illumination, but it didn't work too, but tell me what you think of it.
I remembered the example on Dev-Scene where you could draw directly to the screen. (It's on day 3).
I thought I could pick this line : VRAM_A[touch.px + touch.py * 256] = rand(); which draw where the stylus is pressed directly in VRAM.
Which means we can change it the other way. Color = VRAM_A[touch.px + touch.py * 256];
Don't you think ?...
I tried.
Still doesn't work
Have any ideas why ...?
Dang, sure taking a screenshot will be slow.
2- If I understand well, you can't take a screenshot with an emulator ?
Maybe this is why my code wasn't working ._.
I had an illumination, but it didn't work too, but tell me what you think of it.
I remembered the example on Dev-Scene where you could draw directly to the screen. (It's on day 3).
I thought I could pick this line : VRAM_A[touch.px + touch.py * 256] = rand(); which draw where the stylus is pressed directly in VRAM.
Which means we can change it the other way. Color = VRAM_A[touch.px + touch.py * 256];
Don't you think ?...
I tried.
Still doesn't work
Have any ideas why ...?
Re: Get color on screen
1. you can only pick a single pixel with a screen shot. but call it display capture, thats what it is called on nds
2. emulators support display capture.
if you can draw directly to the screen, then you can read directly from the screen. are you drawing directly to the screen in this case? if so, then you could read directly from it. ah, but youre not, youre using a rotating BG.
2. emulators support display capture.
if you can draw directly to the screen, then you can read directly from the screen. are you drawing directly to the screen in this case? if so, then you could read directly from it. ah, but youre not, youre using a rotating BG.
Re: Get color on screen
Hm ok. You can't pick up a pixel with VRAM_A if it isn't on the right mode, so I can't use this if I have a rotation tiles background ?
So... What should I use or code if I want to take a single pixel out of the display capture ?
Is there some way to get the complete display capture, not on a single VRAM or anything ?
Here is my video init, if it helps. (consider I'm pretty new to this, might need lot of changes. )
videoSetMode(MODE_0_2D);
vramSetBankA(VRAM_A_MAIN_BG);
vramSetBankB(VRAM_B_MAIN_SPRITE_0x06400000);
oamInit(&oamMain, SpriteMapping_1D_32, false);
int bg = bgInit(3, BgType_Text8bpp, BgSize_R_1024x1024, 0,1);
dmaCopy(TilesTiles, bgGetGfxPtr(bg), sizeof(TilesTiles));
dmaCopy(map, bgGetMapPtr(bg), sizeof(map));
dmaCopy(TilesPal, BG_PALETTE, sizeof(TilesPal));
So... What should I use or code if I want to take a single pixel out of the display capture ?
Is there some way to get the complete display capture, not on a single VRAM or anything ?
Here is my video init, if it helps. (consider I'm pretty new to this, might need lot of changes. )
videoSetMode(MODE_0_2D);
vramSetBankA(VRAM_A_MAIN_BG);
vramSetBankB(VRAM_B_MAIN_SPRITE_0x06400000);
oamInit(&oamMain, SpriteMapping_1D_32, false);
int bg = bgInit(3, BgType_Text8bpp, BgSize_R_1024x1024, 0,1);
dmaCopy(TilesTiles, bgGetGfxPtr(bg), sizeof(TilesTiles));
dmaCopy(map, bgGetMapPtr(bg), sizeof(map));
dmaCopy(TilesPal, BG_PALETTE, sizeof(TilesPal));
Re: Get color on screen
regardless of wether you can/cannot read a pixel from the screen it is most like not the best way to go about collision detection.
Re: Get color on screen
There really is a way to get custom rotated tiles collision ?elhobbs wrote:regardless of wether you can/cannot read a pixel from the screen it is most like not the best way to go about collision detection.
It might not be the best, but the easiest... I think xD
I need help for collisions then.
Let's say I have a small map :
0,0,0,0
0,0,1,0
0,2,1,0
1,1,1,0
Where 0 is transparent, 1 is a full block and 2 is a triangle this way /|
Sprite is going down, hit the 2, collision ! Go change direction to left.
Now what if I rotate it.
It's now
1,0,0,0
1,2,0,0
1,1,1,0
0,0,0,0
Now there is a problem. Sprite goes down, hit the 2, collision ! [strike]Go change direction to left[/strike]
Hum Just thought about something.
Is Background-Tiled Rotation possible with angles ? Like a 40 degrees. Because I want the player to rotate the whole world instead of moving the sprite...
Let's say we can.
Color collision would detect exactly the color under it, so no more need to detect the tile or anything, rotation or not, don't you think ?
Re: Get color on screen
You can rotate a BG any angle on the nds and in general you can code collision for anything if youre smart enough. Or, if you're smart enough, youll rip off someone else's collision engine.
Re: Get color on screen
If I'm smart enough...
Dang, you're giving me a challenge there xD
Hum... let me think.
What if I stock a variable called Angle and change direction... Like going to the left is from (0,0) to (-1,0).
Going to half-left would be kinda (0,0) to (.5, .5)
Hitting tiles /| would result in (-1,0) while having it rotated could be multiplied or have some kind of relation with it.
Yeah ok, it might be OK. xD
Well, Zeromus didn't really answered my question, but I guess this is solved.
Unless you find my idea silly
EDIT :
Thanks a lot, Zeromus. I've changed some of my plans, but it works perfectly now ^^.
At the beginning I wanted real-time tiled-background rotating with real-time bounce, and stuff...
But found out it was really too complicated. So I've switch to a some kind of... Static rotation...?
I'm having 90, 180, 270, and 0 degrees rotations, and it freezes time when you rotate. It's not as I originally wanted, but now I see it's PUR-FECT !
Thanks for helping me, both of you ^^
Dang, you're giving me a challenge there xD
Hum... let me think.
What if I stock a variable called Angle and change direction... Like going to the left is from (0,0) to (-1,0).
Going to half-left would be kinda (0,0) to (.5, .5)
Hitting tiles /| would result in (-1,0) while having it rotated could be multiplied or have some kind of relation with it.
Yeah ok, it might be OK. xD
Well, Zeromus didn't really answered my question, but I guess this is solved.
Unless you find my idea silly
EDIT :
Thanks a lot, Zeromus. I've changed some of my plans, but it works perfectly now ^^.
At the beginning I wanted real-time tiled-background rotating with real-time bounce, and stuff...
But found out it was really too complicated. So I've switch to a some kind of... Static rotation...?
I'm having 90, 180, 270, and 0 degrees rotations, and it freezes time when you rotate. It's not as I originally wanted, but now I see it's PUR-FECT !
Thanks for helping me, both of you ^^
-
- Posts: 84
- Joined: Sun Apr 11, 2010 10:43 am
Re: Get color on screen
You might wanna check my old vector based collsion.
http://www.petesqbsite.com/sections/exp ... tml#bounce
http://www.petesqbsite.com/sections/exp ... tml#bounce
Who is online
Users browsing this forum: No registered users and 1 guest