Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Command & Conquer style

Author
Message
Terry
16
Years of Service
User Offline
Joined: 12th Nov 2008
Location:
Posted: 24th Aug 2009 04:16
Hi Hope someone can help
I am making a small 2D game, and I would like to use the mouse to controlThe Sprite I would like to achieve this by selecting (drawing a box around my hero sprite) and then pointing and clicking a bit further away and then having my hero go to this new position.Rather like Command & Conquer style anybody got any Ideas as how to code this?
Any help would be greatly appreciated.
Thanks.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 24th Aug 2009 15:01
Hey,
I'm pretty much a newbie, but I believe it would be something similar to this.

-Get co-ords of mouse when mouse is clicked using mousex() mousey() and mouseclick()

-Then get the actual area highlighted by using mousemovex() and mousemovey()

-If you have some sort of array for your units, or just your hero, check whether thier x and y co-ords are greater than the original click position and less than the original + mousemove

-Then have some array that stores the units selected, then get mousex() and mousey() again, and move all units to those co-ords?

I Hope That Helps

Omricon W.I.P
SAAB Driver
19
Years of Service
User Offline
Joined: 1st Nov 2005
Location:
Posted: 24th Aug 2009 20:58
I would suggest you to buy Dark Ai. With Dark Ai you can both do thoose kind of things and set the "player objects" and the "enemiesobjects" ai so they attack eachother - with just a few lines of code. Very easy to use.



Hello!
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 25th Aug 2009 09:45
Hey terry, i made an example, it works like this:

you select the units with the left mouse button and holding it to make a box, and you righ click to make the units move somewhere

here is the code:



Hope it helps

Terry
16
Years of Service
User Offline
Joined: 12th Nov 2008
Location:
Posted: 25th Aug 2009 15:03
Hi bobbel
Thanks that’s fantastic just the sort of thing I’m looking for, could you do me a favour And comment the code as I’m not an expert at this programming and would help Me and others to understand how and why it works, so I can learn a little more and inspire to
Be as good a programmer as you obviously are, thanks ever so much.

Login to post a reply

Server time is: 2024-11-25 02:27:24
Your offset time is: 2024-11-25 02:27:24