View Single Post
Here's how the world works (as best as I can explain it)
Old
zero00
Senior Member
 
zero00's Avatar
 
Status: Offline
Posts: 300
Join Date: Oct 2009
Default Here's how the world works (as best as I can explain it) - 11-08-2011, 11:15 PM

I'll explain how my mouse cursor system works

-(Make sure the screen has no black bars on the sides. The bars mess up the program. You can get rid of the bars, by resizing the world window and opening and closing it until the bars are gone.)

-When you click on the little dot in the center, it saves mouse cursor's distance from the top and left edges of the screen. Since the dot is in the center, you get roughly half the distances from the left and top edges of the screen. These values are saved as "x_middle" and "y_middle"

-If the "mouse cursor's distance from the left edge of the screen > 0" and less than "x_middle x 2" (the same applies for the top edge), a dummy object moves to where the mouse cursor is, (using some strange math I can't remember or fully explain Go to the updateCursor method to see the math) then the crosshair object moves to the dummy's position.

There may be other less complicated ways of doing this, but this is the way I came up with. Hope this explains it

(The updateCursor method really is only a few lines long, but the math was a bit hard. Also, the "move to" method's offset by parameter can be very useful! If you don't know what the "offset by" parameter does, this thread will explain it somewhere. )


==============Some of my Games and Ideas===========

Sky Warrior: http://www.alice.org/community/showthread.php?t=6291
Health Bars: http://www.alice.org/community/showthread.php?p=36968#post36968
Sky Warrior: Dual Force: http://www.alice.org/community/showthread.php?t=7174

Want to make your own space game? http://www.alice.org/community/showthread.php?t=6389
   
Reply With Quote