The Daily Click ::. Forums ::. Klik Coding Help ::. Recording Mouse Movement
 

Post Reply  Post Oekaki 
 

Posted By Message

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
6th December, 2004 at 21:41:37 -

I'm making a grid based game at the moment, but I've hit a problem with the movement system.

I want to make it so you click on a character to select them and then click again at the destination square for them to move. Unfortunately, its not that simple.

I dont want to use pathfinding to find the route to follow (which would be simple enough I know) - instead I want to detect which squares the mouse pointer passes over, so the player has complete control over the movement without having to click more than once.

The problem is, I cant make it detect every square the mouse passes over if you move the mouse at all quickly.

At the most basic level, what I need is to be able to move the mouse over a grid of objects and have have them change their animation / alterable value on contact, regardless of how quickly the mouse is moved.

I've tried having an object that moves towards the mouse using fastloops, I've tried the move safely extension, and tried plenty of other complicated ideas.

Any help with this would be VERY greatly appreciated, as its something I've been trying to figure out for an extremely long time (I posted a similar problem on the clickteam forum months ago (subject; advance wars arrow)), or if someone could actually manage a working demo that would be fantastic.

Image Edited by the Author.

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
6th December, 2004 at 22:56:59 -

Well, the problem is that when you move the mouse, it isn't passing through every point but rather jumping to a location relative to it's last position depending how it was moved. What I would do is have a fake mouse object that moves when you move the mouse (say, if at any point the X position of the mouse is greater than the previous recorded position, move the fake cursor right a bit). That way you can control the rate at which the cursor moves and make sure it doesn't jump. The problem with that is that the real mouse can't move any further than the edge of the screen.
I think I remember doing something similar in the past, with the mouse's movement limited by a mouse-controlled object that returns to a central position every second... I think.
It might take some fiddling, but you should be able to avoid that problem by having the mouse position on the screen somehow relative to the real mouse, and not using a mousescroll system. Um.
Actually, it's all a fiddly kind of thing. I can't think of any sure-fire solution, at least not one that's generally applicable.
Maybe with more information on the game mechanics I could come up with something specific.

Considering it's going to be a pain in the ass no matter what, have you thought about using a more AW-like system that just determines the shortest path to your destination (including the movement value of each space, of course)? Have a look on the net for weighted tree pathfinding. I can't remember much from my discrete maths course, but I do recall the algorithms being fairly simple.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
7th December, 2004 at 10:59:26 -

Thanks for the reply.

I think what you're suggesting sounds like what i tried with moving an object using fastloops, towards the mouse (without fastloops it required that the active object move VERY slowly, making it cut corners). I've had a bit more of think and Im afraid my requirements have changed somewhat now, though it still boils down to the same thing.
I now need to CREATE an active object at the mouses position, but do it so that the line it draws wont have any gaps when you move the mouse quickly.

heres what I'm trying to achieve (but using mouse instead of keyboard)
http://free.angeltowns.com/spacecadet/AWeg.cca

With regards Advance Wars, the movement system in that game doesn't just "determine the shortest path to your destination (including the movement value of each space".
It actually does what I'm suggesting, unless the cursor goes over a terrain square which the selected unit cannot cross (eg. if the mouse is over a river tile when a tank is selected). Only then does it calculate the shortest path, and even then, only the shortest path from the last valid place you left the cursor. If you dont believe me, have a look at the last mission of field training (special intel) which explains the movement system. It also has a neat trick where if you make a long path that loops back on itself at some point, the extra part of the path is deleted. In AW this complex system is essential for avoiding "ambushes" when you think you know where an enemy is but dont have a unit that can actually spot them.

Image

The thing is, AW uses a direction pad (or keyboard if you use an emulator like me) instead of a mouse. I could solve my problem this way (I've already made a working example with all these features), but for a pc strategy game to have keyboard movement is pretty lame I think.

Image Edited by the Author.

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
7th December, 2004 at 17:13:55 -

or keyboard if you use an emulator like me
Gasp! You crook! Help yourself then.

Okay, whatever. I PAID MONEY for AW2, but I don't like it very much and I haven't played it in ages. Is your game going to have ambushes? It seems to me that you're trying to imitate the advance wars movement too closely. You need to find a movement system that you're capable of coding if the way you want is out of your reach.
Heres a possible compromise:
-If the player left-clicks any cell the shortest weighted distance is calculated. Another click on the selected cell confirms it and the unit moves.
-If the player right-clicks on any cell, movement DIRECTLY to that space is displayed, provided it's due north, south, east or west of a previously selected point. This can be done multiple times to establish a specific path.
-Clicking outside the movement range of the unit cancels the selection, and clicking on the unit re-selects it, resetting it's path.

Something like that, anyway. I just don't think what you're describing is possible in a klik product at this point, at least until someone comes up with an advanced mouse control extension. I'd probably get tired of moving the mouse carefully enough for it to track the path I want anyway.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
7th December, 2004 at 19:14:58 -

I think maybe you're right about making it unnecessarily complicated. Since most of the time you do just want the shortest path I may aswell make always do that and then have an option for "continue moving" in the same little menu as "attack" and "wait" etc.
I also dont reckon its too bad having an emulated copy of a GBA game.
The whole point of a gba is that its portable - you use it when you cant get to your pc so its not like theyre losing any sales from it(i dont have a laptop). If it were a pc or playstation game that might be different. Noones going to buy a gba just for one game are they, and from what i can tell, pretty much every other gba game sucks.
Thanks very much for all your suggestions though - I will work it out eventually, but I'm gonna give up for now and use an alternate system.

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
7th December, 2004 at 23:22:44 -

I was kidding. I've got a flash cart, which I use all the time.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click