Screen-Smash - Test My Game!!!

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Screen-Smash - Test My Game!!!

Post by LuX » November 3rd, 2012, 10:59 pm

suite yourself, I would have gone with the sprite idea to draw it to the cursor.
ʕ •ᴥ•ʔ

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Screen-Smash - Test My Game!!!

Post by thetoddfather » November 3rd, 2012, 11:07 pm

Is there a way I could use the embedded cursor resource images for that method?

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Screen-Smash - Test My Game!!!

Post by Asimov » November 3rd, 2012, 11:36 pm

Hi Todfather,

I experienced lag when I made my sprite in my Missile command game, but I solved it. The lag isn't in the sending to the screen, it is the way it reads the cursor position. The following code that I wrote solves this.

Code: Select all

RECT r;
GetWindowRect( hWnd, &r);
r.right=r.right-5;
r.left= r.left+5;;
r.bottom = r.bottom-100;
ClipCursor( &r );

POINT bn;
GetCursorPos(&bn);
crosshair.Sprite((bn.x-r.left)-27,  (bn.y - r.top)-54,5,2000,&gfx, timetest);
It reads the cursor position in a different way. There is a lot more to this, as you have to pass the window to the Compose frame.

Code: Select all

void Game::ComposeFrame(float timeDelta, HWND hWnd)
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Screen-Smash - Test My Game!!!

Post by thetoddfather » November 4th, 2012, 12:16 am

Ok, I'll try to go that route then. Saves me trying to figure out directx's cursor bull.

So, with missle command all your images are through your resource file? Can you help me now with getting them into the game from their current resource state? The syntax for these things is just not clicking for me.

They are loaded into the .res as 256x256 32 bit cursors. Is there a way I can pull those into a sprite or image I can use for my cursors as you have in misslecommand?? Or am I going to have to redo the .res file and make them bitmaps?

Is there a way I can use this:

Code: Select all

LoadImage(hInst,MAKEINTRESOURCE(IDC_M4B_CURSOR),IMAGE_CURSOR ,256,256,LR_CREATEDIBSECTION);
Basically, how did you pull your resource images and then assign them to sprites and such?

Would help me a ton to get past this issue. Thanks!

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Screen-Smash - Test My Game!!!

Post by Asimov » November 4th, 2012, 12:39 am

Hi Todfather,

I didn't start by loading from a resource. My original routine I loaded straight from a file. You have to get that to work before thinking about resources. I can post some code later, which I meant to do but I have been caught up with learning Vray the last couple of days.

You know how to load an image already. My sprite routine just loads a row of images as one image.
Then it uses a counter. Say I have a 20 frame animation all in one animation strip. All I have to do to advance to the next frame is advance the pointer to the different images.

In the meantime here is my routine for playing my sprite animation

Code: Select all

bool SpriteLoader::Sprite(double x,double y, float Frametime,D3DGraphics* gfx)
{
		DrawSprite((int)x,(int)y,gfx);

		if (Time==0)
		{
			endtime= clock()+Frametime;
			Time=1;
		}
		
		if (clock()>=endtime) {
			Frame=Frame+1;
			Time=0;
		} 

		if (Frame==NumberOfFrames) {
			Frame=0;
			return false;
		} // This starts the animation again
		return true;
}

I setup my face with this

Code: Select all

SpriteLoader Turret;
Then I load my face

Code: Select all

Turret.LoadSprite(L"data//crosshair,41,63,20,861);
41 is the sprite width. 63 is the sprite hieght. There are 20 frames and the whole image is 861 wide.

Or from resource with this

Code: Select all

Turret.LoadSpriteRes(IDR_TURRET,41,63,20,861);
I have overload functions in my class so I can either load from resource or from a file.

First of all you already know how to load an image from a file, so all you have to do is to work out how to take an image of more than one frame and load through it.

I will post my full code for you tomorrow, but I have to take out my encoding algorithm first.
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Screen-Smash - Test My Game!!!

Post by thetoddfather » November 4th, 2012, 8:44 pm

OK! After MUCH toil, I think we're almost there.

Have a look at 0.76 and let me know what you think.

This is fullscreen now so there should be no reason for the scrolling issue to pop up.

Cursor calamity is all but over, maybe that'll be the name of my next game lol.

I think I've put more time into this rewrite than I did to get the game to look like this in windowed mode, but hopefully she runs good now.

Next big issue to tackle is timing. It just runs wayyyy too differently depending on the rig, so that's the next issue.

Thanks Asimov,Lux,Chili for the help!
Last edited by thetoddfather on November 4th, 2012, 10:04 pm, edited 1 time in total.

Muttley
Posts: 39
Joined: October 19th, 2012, 6:00 am

Re: Screen-Smash - Test My Game!!!

Post by Muttley » November 4th, 2012, 9:16 pm

Worked fine here, Win7 x64.

Good job! :D

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Screen-Smash - Test My Game!!!

Post by thetoddfather » November 4th, 2012, 9:25 pm

Thanks Muttley!

Still a few minor things to fix, but all in all it seems to be working good, fingers crossed.

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Screen-Smash - Test My Game!!!

Post by LuX » November 4th, 2012, 9:49 pm

Yup, pretty cool alright.

I would like to see a gas canister you can spray on the screen then set it on fire : -D
ʕ •ᴥ•ʔ

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Screen-Smash - Test My Game!!!

Post by Asimov » November 4th, 2012, 9:55 pm

Hi Todfather,

Sorry it didn't work. In fact it scrolled up so far my laptop fell off the table.

LOL nooooooooooooooooooooo ignore the first line it worked perfectly and doesn't scroll up anymore LOL. I love it now. I knew we could point you in the right direction eventually heh heh.

Hope you didn't have a heart attack after reading my first line LOL
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

Post Reply