Stars

Published October 25, 2008
Advertisement
ANOTHER POOR QUALITY WMV IN A ZIP AVAILABLE HERE. 1.6 meg this time. CamStudio rocks the big one, but it appears there is a limit on the quality I can grap, even as the original AVI. Looks much better when actually running.

Well, I was going to do screen fading by having a load of rotating stars expand out from random points on the screen, spinning and growing until the screen was all black, but to be honest, I don't really like the way it looks.

However, just in case anyone ever needs to create a symmetrical five-pointed star out of triangles for some reason, here's the co-ordinates in local space of a five-sided star two units across built from three overlapping triangles:

Triangle 1: [0,-1],[0.38,0.18],[-0.62,0.9]Triangle 2: [-1,-0.28],[1,-0.28],[0,0.46]Triangle 3: [0,-1],[0.62,0.9],[-0.38,0.18]


Took ages to figure that out. I basically drew a star in PaintShop using a preset shape on an image 101x101 pixels, then hovered over the relevant points and wrote down the co-ordinates.

I then deducted 50 from each co-ordinate and divided the result by 50 to get the co-ordinates, then built three triangles from the relevant points.

Hopefully it will be useful to someone, somewhere. [smile]

[LATER]

For my own fading in and out for Pod, I've decided to use a standard fade to black, but combine it with a zoom into the screen as it fades out and a zoom out as it fades in.

This was actually very simple to implement. Because I am using the virtual backbuffer method that I outlined here, all I needed to do was modify the size of the source rectangle for StrectRect().

So basically, there is a FadeAlpha member of engine which, if non-zero, renders a textureless black quad over the entire screen with the relevant alpha value. This is a lot easier to deal with than my previous method of having a global diffuse value that all rendered values were modified by, and while less efficient in some respects, moves the work off the CPU onto the GPU.

Currently, my GraphicsDevice::End() method handles copying the virtual backbuffer onto the actual backbuffer with IDirect3DDevice9::StretchRect(). So all I have done is added a float Zoom parameter to End(), into which I pass FadeAlpha each turn (FadeAlpha being from 0: no fade to 1: all black). End then looks like this:

void GraphicsDevice::End(float Zoom){	Device->EndScene();	RECT SourceRect;		if(!Zoom) SourceRect=CreateSimpleRect(1024,768);	else		{		float Across=1024.0f-(512.0f*Zoom);		float Down=768.0f-(384.0f*Zoom);		SourceRect.left=int((1024.0f-Across)/2.0f);		SourceRect.top=int((768.0f-Down)/2.0f);				SourceRect.right=SourceRect.left+int(Across);		SourceRect.bottom=SourceRect.top+int(Down);		}	Device->SetRenderTarget(0,BackSurface);	BackSurface->Release();	Device->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),0,0);	Device->StretchRect(DrawSurface,&SourceRect,BackSurface,&DestRect,D3DTEXF_NONE);	Device->Present(NULL,NULL,NULL,NULL);}


It's not a brilliant design - End() should probably not really be responsible for the zooming, there should probably be a GraphicsDevice::SetZoom(float) method and maybe when I've finished typing this I'll go back and modify it, but it still works nicely without having to worry any of the other rendering code.

Technically while the fade in is happening, the wrong mouse co-ordinates will get returned by the translator, but I haven't been able to find a situation where this is noticeable, so I'm going to ignore that unless I notice any problems.

Really need to go and redesign this zooming system though - current design sucks. Looks pretty cool on the screen though.
Previous Entry Updates
Next Entry Not a very good day
0 likes 8 comments

Comments

rip-off
I agree, the zoom looks really effective. Noticeably better than a simple fade to black.

Lately I try not to worry overly about design, unless I figure it will get in the way later on. I find I otherwise spend a lot of time trying to find the right way to do something, only later on having to change everything due to the next part I add. There is a balance somewhere between a great design and a program you make progress with.
October 25, 2008 08:06 PM
Aardvajk
Quote:Original post by rip-off
Lately I try not to worry overly about design, unless I figure it will get in the way later on. I find I otherwise spend a lot of time trying to find the right way to do something, only later on having to change everything due to the next part I add. There is a balance somewhere between a great design and a program you make progress with.


Yeah, I do agree that we have to stay practical. I'm just left feeling a bit icky that GraphicsDevice::End() is taking responsibility for also zooming the image. Seems a bit wrong.

Oh well. I guess I was never going to win any program design awards anyway [smile].
October 26, 2008 03:53 AM
Evil Steve
Ooh, nifty [smile]

Something I think would make a big difference would be adding a bit of lag or springyness to the camera, so the target isn't always bang in the middle of the screen. That'd make it feel more fluid IMO.
October 26, 2008 01:12 PM
Aardvajk
Quote:Original post by Evil Steve
Ooh, nifty [smile]


Cheers, I thought so [smile].

Quote:Original post by Evil Steve
Something I think would make a big difference would be adding a bit of lag or springyness to the camera, so the target isn't always bang in the middle of the screen. That'd make it feel more fluid IMO.


Not really sure how you mean. Could you elaborate?
October 26, 2008 02:20 PM
Servant of the Lord
It's looking very sweet; can't wait to play.

In the video, it looks weird that the arm touching the tar causes the entire pod to explode. It might look better if the pod only explodes when the pod itself touches the tar.
October 27, 2008 12:10 AM
Aardvajk
Quote:Original post by Servant of the Lord
It's looking very sweet; can't wait to play.

In the video, it looks weird that the arm touching the tar causes the entire pod to explode. It might look better if the pod only explodes when the pod itself touches the tar.


Yeah, that was the original plan, but it creates an awkward situation where you can then rotate around a block with tar on top and have the arm appear from around the side of the tar. Hard to explain what I mean, but it looks very silly.

There probably will be hazards that you can touch with the arm but not the main Pod, but they'll have to be solid so that the arm can't actually penetrate into them.
October 27, 2008 01:02 AM
Evil Steve
Quote:Original post by EasilyConfused
Quote:Original post by Evil Steve
Something I think would make a big difference would be adding a bit of lag or springyness to the camera, so the target isn't always bang in the middle of the screen. That'd make it feel more fluid IMO.


Not really sure how you mean. Could you elaborate?
Currently, the player is always dead center of the screen. Because of the way the game works, you can get jarred from left to right if you swing from left to right. If there was a bit of lag / springyness / lerping on the camera, the player could move from the center of the screen, and the camera would feel a bit smoother - no sudden jerks left and right.

IMO anyway.
October 27, 2008 09:36 AM
Aardvajk
Quote:Original post by Evil Steve
Quote:Original post by EasilyConfused
Quote:Original post by Evil Steve
Something I think would make a big difference would be adding a bit of lag or springyness to the camera, so the target isn't always bang in the middle of the screen. That'd make it feel more fluid IMO.


Not really sure how you mean. Could you elaborate?
Currently, the player is always dead center of the screen. Because of the way the game works, you can get jarred from left to right if you swing from left to right. If there was a bit of lag / springyness / lerping on the camera, the player could move from the center of the screen, and the camera would feel a bit smoother - no sudden jerks left and right.

IMO anyway.


See what you mean now. To be honest, the zoom is so quick that I'm not really sure there'd be enough time for it to be noticeable, especially since the zoom is coupled with a fade in.

It's also possible that you'll be until the zoom has completed - I'm probably going to end up having you teleport into a level or something, in which case that effect will probably take longer than the zoom.

Thanks for taking the time to explain though. Suggestions like this are one of the many reasons that journalling a project is so handy.
October 31, 2008 01:23 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement