GPWiki.org
GPWiki.org
It is currently Wed Jun 19, 2013 9:12 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: moving the mouse
PostPosted: Sat Jan 24, 2009 2:26 pm 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2217
Location: England
Just a quick question.

What vb6 code do I need to set the mouse coordinate to a custom point?

Also, while I'm here, is there code to enable/disable the mouse cursor visibility, other than using a null cursor graphic?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 24, 2009 2:46 pm 
Dexterous Droid

Joined: Fri Aug 19, 2005 10:34 am
Posts: 3650
Here is one I remember from waaayyy back in the day:

http://pscode.com/vb/scripts/ShowCode.a ... 5&lngWId=1

_________________
NetGore - Open source online RPG engine


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 24, 2009 6:36 pm 
Funky Monkey

Joined: Mon Aug 16, 2004 2:48 pm
Posts: 1604
Location: Minneapolis, MN USA
From Spodi's link, the API declaration that matters to your setting the mouse X/Y:

Code:
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long


And here's a wrapper that uses that and allows for you to pass a window's handle in case you want to give an X/Y that is relative to that window:
http://www.devx.com/vb2themax/Tip/19125

And here's info on hiding/showing the mouse pointer:
http://www.devx.com/vb2themax/Tip/18490

HTH,
-Bryk

_________________
www.mwgames.com ... Dicey Curves, Space Mission, Jump Gate, Gem Raider, DareBase, Castle Danger, Keeps & Moats Chess


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 24, 2009 8:03 pm 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2217
Location: England
Thanks both. With your help I've got it working now. :)

What I was doing was looking into my idea for a real-time worms game. I had to dig out my old copy of the game to remember how the pointer pushes around the map, and discovered that as the pointer nears the edges, the game slides it back at the same speed that it scrolls the map, so it just feels like a really wide virtual screen... Hence the need for the mouse API.

At the moment I've got a 4096x1536 pixel game world. I've created some projectiles and got them to fly about and crash into the terrain and explode out a circle of it. Then I started on collision detection and had projectiles bouncing... which wasn't the best bouncing I've seen. (It's not obvious how to find normal vectors from bitmapped terrain.)

I've had some trouble with collision detection though. Each delta-time step the projectiles are moving 20 pixels or so, and sometimes that step takes them inside the terrain, (or could miss a tiny lump of terrain if it skips over it in one time step.)

So I've changed this and introduced a pixel by pixel stepping within each delta-time step. But with 100 projectiles, delta time increases, causing more pixels being traced next time step, causing delta time to increase again, etc. And the program steadily grinds to a halt, and numbers explode because of the large delta-time, causing it to crash.

I could buffer the terrain to an array instead of sampling pixels from the bitmap for the collision detection. I expect that will give me more speed. But if that isn't enough, I'm not sure how I'll fix this. :P


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 24, 2009 9:53 pm 
Funky Monkey

Joined: Mon Aug 16, 2004 2:48 pm
Posts: 1604
Location: Minneapolis, MN USA
Working with an array should be much faster than reading pixel color values every loop. {It would also allow you to change up your on-screen background color (or use a background picture) and only track the terrain bits in the array. But that might not be a value-add for what your doing.}

That will definitely speed the "nearing" portion of your collision routine

I know you like to do real-life math works wrt to physics in your games, but in this case you may need to find a good-enough efficient approach. Once you've picked the impact pixel, can you do a quick sample in a 3x3 (or 5x5) grid centered on that pixel to determine the slow of the nearby terrain and do flat-surface collision responses based on that sampled normal?

-Bryk

_________________
www.mwgames.com ... Dicey Curves, Space Mission, Jump Gate, Gem Raider, DareBase, Castle Danger, Keeps & Moats Chess


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2009 7:42 pm 
Mumbo Jumbo
User avatar

Joined: Fri Aug 20, 2004 1:15 pm
Posts: 804
Location: Michigan, USA
how about once you get a collision with the terrain, do a pixel by pixel check back along the path of the projectile until you get to the edge of the terrain, and explode it there.

_________________
The path to hell is paved with clever code.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2009 7:50 pm 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2217
Location: England
Moglor wrote:
how about once you get a collision with the terrain, do a pixel by pixel check back along the path of the projectile until you get to the edge of the terrain, and explode it there.


That's a good idea Moglor :) But I'm not sure it would work for collisions with small isolated lumps of terrain. Would it just step over them, and not collide?

btw, I haven't updated this game yet. I've got about 20 projects going on at the moment. Tonight I'm finishing the levels for ISIS, and altering some of the earlier ones around a little :P


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2009 8:31 pm 
Mumbo Jumbo
User avatar

Joined: Fri Aug 20, 2004 1:15 pm
Posts: 804
Location: Michigan, USA
you could do a pre-calculation of where the missile will explode before you launch it. you would get a more precise ending destination because you wouldnt be skipping large chunks. and then after the missile is launched, when it is >= the predetermined destination, explode it at the destination. the user will never know.

i'm thinking Bryk is right about making an array to improve speed.

_________________
The path to hell is paved with clever code.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group