how can u make the view follow ur mouse?

Talk about making games.

how can u make the view follow ur mouse?

Postby Kooldudese » Thu Dec 13, 2007 10:32 pm

Well... pretty much my question is my subject... how can u make the view follow ur mouse...
User avatar
Kooldudese
 
Posts: 128
Joined: Sat Jan 27, 2007 5:20 pm
Location: In a house
Score: 0 Give a positive score

Re: how can u make the view follow ur mouse?

Postby jman » Thu Dec 13, 2007 10:34 pm

yeah good question :D
Labyrinth-just starting
User avatar
jman
 
Posts: 123
Joined: Fri Jul 20, 2007 7:07 pm
Location: Ontario, Canada
Score: 2 Give a positive score

Re: how can u make the view follow ur mouse?

Postby Bee-Ant » Thu Dec 13, 2007 10:40 pm

Put this code on DrawActor of your view actor :
Code: Select all
view.x=mouse.x;
view.y=mouse.y;
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: how can u make the view follow ur mouse?

Postby Game A Gogo » Fri Dec 14, 2007 12:32 am

or how can you move the view with the mouse?
Code: Select all
view.x+=xmouse-(view.width/2);
view.y+=ymouse-(view.height/2);

I think this code should work =3
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: how can u make the view follow ur mouse?

Postby Kooldudese » Sun Dec 16, 2007 6:32 pm

Oh... thx... game a gogo... but i have another question related to this, how can you make a barrier so that the view can only follow the mouse in a certain place oh and can you control the speed that the view moves?
User avatar
Kooldudese
 
Posts: 128
Joined: Sat Jan 27, 2007 5:20 pm
Location: In a house
Score: 0 Give a positive score

Re: how can u make the view follow ur mouse?

Postby Kalladdolf » Sun Dec 16, 2007 7:10 pm

enter script for draw actor

if (view.x > //your right limit position)
{view.x = //your right limit position ;}
if (view.x < //your left limit position)
{view.x = //your left limit position ;}
if (view.y > //your bottom limit position)
{view.y = //your bottom limit position ;}
if (view.y < //your top limit position)
{view.y = //your top limit position ;}

ok, that'll do for your barrier.
but I'm not sure about controlling the speed.
because you can move your mouse in all speeds you want.
maybe a more advanced code would do, but I can't help you here.
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: how can u make the view follow ur mouse?

Postby Game A Gogo » Mon Dec 17, 2007 1:14 am

you would need to create an actor that would be used as a ghost and make it follow the mouse
Code: Select all
double speed=3.5;//This is your speed
if(view.x>M_Ghost.x)view.x-=speed;
else if(view.x<M_Ghost.x)view.x+=speed;
if(view.y>M_Ghost.y)view.y-=speed;
else if(view.y<M_Ghost.y)view.y+=speed;

I'm not sure if this will work, but it should make you able to control the speed
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: how can u make the view follow ur mouse?

Postby Kooldudese » Fri Jan 04, 2008 11:09 pm

Im not sure how the ghost would be like... i tried it and it dident really come out propperly, the view does follow the mouse but the speed isent controlled, the barrier works though thx ==Kalladdolf== could you try to make a demo game a gogo?
User avatar
Kooldudese
 
Posts: 128
Joined: Sat Jan 27, 2007 5:20 pm
Location: In a house
Score: 0 Give a positive score

Re: how can u make the view follow ur mouse?

Postby Game A Gogo » Sat Jan 05, 2008 1:01 am

I will :3
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron