Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1] 2   Go Down

Author Topic: Help with Objects  (Read 2304 times)

0 Members and 1 Guest are viewing this topic.

The gold chuchu

Maybe not?...
Help with Objects
« on: February 07, 2007, 11:31:16 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 387
What code would make a Object(if you move the mouse)follow another object?Very simple queston huh? :jellytime:

Dayjo: I put the topic icon on. Please remember to do it next time. Thanks  ;D
« Last Edit: February 08, 2007, 05:17:23 pm by Dayjo »
Logged
Re: Help with Objects
« Reply #1 on: February 07, 2007, 11:48:35 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
Depends what you are doing it in, in GM its probably just a matter of calling a function - In a programming language its a matter of spending a few hours reading up on sine and cosine.
Logged

mit

Re: Help with Objects
« Reply #2 on: February 07, 2007, 11:51:06 pm »
  • QBASIC programmer since age 4. Take that, world.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 1079
Not quite sure what you mean. Move towards the mouse? Move the mouse towards an object?

You can get the mouse positions using mouse_x and mouse_y.

You can move towards an object with move_towards_point() etc, but I don't really get what you're trying to do.
Logged
Programmer / Spriter / Level designer / Game Director / Web Designer / Music Sequencer for
Random Highscore table:

Play the Kousou Arcade today!
  • Kousou Games

The gold chuchu

Maybe not?...
Re: Help with Objects
« Reply #3 on: February 08, 2007, 12:02:44 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 387
Its in GM6,I'm saying move the mouse and a object follows the the mouse object,Get me?
Logged
Re: Help with Objects
« Reply #4 on: February 08, 2007, 01:09:53 am »
  • Lionfish App dev
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3456
Use this on the object:

Code: [Select]
x=mouse.x
y=mouse.y

That'll do the trick. :P
Logged
  • Lionfish Apps

The gold chuchu

Maybe not?...
Re: Help with Objects
« Reply #5 on: February 08, 2007, 01:12:57 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 387
In what Event?Step,Create,etc.
Logged
Re: Help with Objects
« Reply #6 on: February 08, 2007, 01:22:29 am »
  • Lionfish App dev
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3456
Ah, my bad. Step (so it will repeat it every step, which will update the position however many times you set Room Speed to every second).
Logged
  • Lionfish Apps

The gold chuchu

Maybe not?...
Re: Help with Objects
« Reply #7 on: February 08, 2007, 01:48:51 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 387
Its not working.Do you want to see what i'm working on? Maybe then you can help alot more.
Logged
Re: Help with Objects
« Reply #8 on: February 08, 2007, 02:03:39 am »
  • Lionfish App dev
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3456
It shouldn't be that complicated...

K, the object that you want to follow the mouse is called (in this assumption) MouseMan.

So, double click on the MouseMan object to open his preferences. Add a Step (Step) event to him, and inside that add a script from drag and drop. Then in the script, write what I said above. Now add MouseMan to a room and run the program. It should work just fine. Wait... I bet it's mouse_x and moues_y instead of mouse.x and mouse.y... I'm an idiot. :P Try those and see if it works then. lol
Logged
  • Lionfish Apps

A Storm in the Desert

Eternal Triangle
Re: Help with Objects
« Reply #9 on: February 08, 2007, 02:04:56 am »
  • Wear the Deku Sprout Smile :]
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 222
If you want an object to follow the mouse's co-ords:

x=mouse_x
y=mouse_y

Or if you want it to follow another object:

x=(objectname).x
y=(objectname).y

Where (objectname) is quite obviously the name of the object you want to follow. This method (when placed in Step as a code) will make the object's co-ordinates snap directly to the followed object. If you just want it to move towards the mouse or object, then instead you'd use:

move_towards_point(mouse_x,mouse_y,(speed))

Or alternately:

move_towards_point((objectname).x,(objectname).y,(speed))

Where (speed) is the speed at which the object will move. Obviously.
Logged
Surely you can do it!
Believe in your strengths...Believe...

        -Happy Mask Salesman

The gold chuchu

Maybe not?...
Re: Help with Objects
« Reply #10 on: February 08, 2007, 02:16:08 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 387
I must be setting it up wrong,It comes so close that it disappears! I must be doing something wrong?
Code: [Select]
x =mouse_x
y =mouse_y

Thats the right code right? ???
Logged
Re: Help with Objects
« Reply #11 on: February 08, 2007, 06:46:33 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 4588
So close it dissapears? What the... is it a small image?
Logged
the a o d c

The gold chuchu

Maybe not?...
Re: Help with Objects
« Reply #12 on: February 08, 2007, 12:17:24 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 387
My bad,it hides behide the object that i want it to follow.
Logged
Re: Help with Objects
« Reply #13 on: February 08, 2007, 01:24:55 pm »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
That can be fixed; set the objects' depth values, the object with the lower depth value will show up above the one with the higher depth value
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog

mit

Re: Help with Objects
« Reply #14 on: February 08, 2007, 02:59:18 pm »
  • QBASIC programmer since age 4. Take that, world.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 1079
I understand now. I think.

You have an object where your mouse is, and you want an object to move towards that mouse object.

So this:
Code: [Select]
x=mouse_x
y=mouse_y
should go in the mouse object's step event.

And this:
Code: [Select]
move_towards_point((objectname).x, (objectname).y, speed) needs to go in the object that you want to move towards the mouse's step event. Where (objectname) is the name of the object at the mouse's position, and speed is the speed you want it to go at.
Logged
Programmer / Spriter / Level designer / Game Director / Web Designer / Music Sequencer for
Random Highscore table:

Play the Kousou Arcade today!
  • Kousou Games

The gold chuchu

Maybe not?...
Re: Help with Objects
« Reply #15 on: February 08, 2007, 09:20:42 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 387
Heres the truth guys, I'm working on a Wii(Mouse sim but it sound cooler that way.)engine.
Check it out, youl see what I mean.

http://www.esnips.com/doc/c38d397f-3368-4c54-ab60-de3e1a187bd0/The-WII-project
Logged

gm112

Re: Help with Objects
« Reply #16 on: February 08, 2007, 09:26:57 pm »
Quote
roken Link
The link you clicked on is not complete.
If you clicked a link within an e-mail message, please verify that the link was not broken in the middle.
If it is broken, copy and paste the entire link into your browser.
You will be redirected to the eSnips home in a few seconds...
Copy + pasted into my browser and still didn't work. Please fix your link..
Logged

The gold chuchu

Maybe not?...
Re: Help with Objects
« Reply #17 on: February 08, 2007, 09:50:40 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 387
http://www.esnips.com
Just scroll down to "The Wii project" and download.
EDIT:How do i make a charther move by using mouse events?
« Last Edit: February 09, 2007, 01:34:18 am by The gold chuchu »
Logged

The gold chuchu

Maybe not?...
Re: Help with Objects
« Reply #18 on: February 10, 2007, 03:00:24 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 387
Oppsy!Sorry for the dobble post but i think i got it this time.
EDIT:I fixed the promblem....but i still need help on this.
http://www.sharebigfile.com/file/79780/The-WII-project-gm6.html
How do i make a Object(Mario)move left/right if you press the mouse keys(left key or right key)?get me?
Logged
Re: Help with Objects
« Reply #19 on: February 10, 2007, 01:18:39 pm »
  • IBV
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 1075
mouse_x and mouse_y also are relative to the window, I think. So if you have scrolled in the window by using views you'll have to add the view-coordinates to the mouse coordinates to get the correct position in the room.
Logged
My signature is empty.
Pages: [1] 2   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.064 seconds with 74 queries.