Snap to grid help.

Talk about making games.

Snap to grid help.

Postby NevenResnik » Fri Jul 02, 2010 9:27 am

Hey!

EDITED:
I have a problem with my GAMEPlay. I don't mean the following in terms when editing the game, but in Game Mode, while it is running. I was wandering if there was a way to make characters snap to a grid when moved over it with a mouse. The Character would follow the mouse, off course. I just don't know how to make it snap to a square grid when moved over it (it's a grid field, like a big square, it would include many of them.)
Last edited by NevenResnik on Fri Jul 02, 2010 11:33 am, edited 1 time in total.
NevenResnik
 
Posts: 42
Joined: Mon May 31, 2010 9:59 am
Score: 0 Give a positive score

Re: Snap to grid help.

Postby Bee-Ant » Fri Jul 02, 2010 10:41 am

Press "Shift"...
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Snap to grid help.

Postby NevenResnik » Fri Jul 02, 2010 11:25 am

Oops! There seems to be a misunderstanding. What I meant was, in the GAMEPLAY itself. I set the actor with the "Follow Mouse" rule. And when I hover my mouse above the grid it snaps to each field. Have you played Plants versus Zombies, or any other Tower Defense game? When you place the towers, they can be placed only in specific square fields, not anywhere on the map. I'm sorry for not being clear. I need the actor to snap to the grid (Which I will draw) in the gameplay while the game is running.
NevenResnik
 
Posts: 42
Joined: Mon May 31, 2010 9:59 am
Score: 0 Give a positive score

Re: Snap to grid help.

Postby Bee-Ant » Fri Jul 02, 2010 12:04 pm

Try this on DrawActor:
Code: Select all
int xx,yy;
int grid=40;

xx=(xmouse+view.x)/grid;
yy=(ymouse+view.y)/grid;

if(drag==1)
{
    x=xx*grid;
    y=yy*grid;
}

I use this code to drag the object snappy...
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest