Hello, thanks for visiting GameML, if you are a Game Maker user, this is the site for you, please sign up, or login if you are already a member, or just browse the site! Welcome to GameML!

ATTENTION MEMBERS!!! USERS CAN NOW SIGN UP AGAIN!
Log in

I forgot my password

Search
 
 

Display results as :
 


Rechercher Advanced Search

Site Hits
Free hit counter
These stats started at 0 on July 7th 2009
GameML File Sharing
USERNAME: gamemladmin@gmail.com PASSWORD: gamemlsite Upload Here: http://gameml.iowoi.org/GameML-File-Sharing-h3.htmPlease add only games.
Create A GAMEML BLOG!
Make a Blog on GameML:http://gamemlblogs.wetpaint.com
Keywords


Point to mouse with lite.

View previous topic View next topic Go down

Point to mouse with lite.

Post by CarnivorousA on Wed Jun 03, 2009 1:01 am

With GM pro one of the features is being able to make a sprite point towards the mouse, and us guys that only have lite can't stand that we can't use it. But with a different line of code you can do this with GM lite.
Note: Doesn't work with animated sprites unless you find a way, if you do post it.

First make your sprite rotate 360 degrees in 22 frames. Make sure the first frame faces right.
Then in the step event for that object have this code:
image_single=(point_direction(x,y,mouse_x,mouse_y))/360*22

If it's not good enough make the sprite rotate in 360 degrees in 45 frames or 90. If you do change the 22 in the code to however many frames are in the sprite.
Note: If you use too many frames the game will be slow and stupid.

Hopefully you use this well and make your games that little bit better, no need to give credit if you use it.
avatar
CarnivorousA
Moderator
Moderator

Posts : 1402
Points : 31982
GameML Reputation : 17
Join date : 2009-06-01
Age : 23
Location : At the bottom of the lake.

View user profile http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Js. do not missuse mod privilages.

Post by 3d on Wed Jun 03, 2009 2:13 pm

cool!
Just make the animation 22 frames and then go into animation on the sprite editor select rotate counter clockwise (or clockwise) and 360 * and 22 frames.


Last edited by 3d on Thu Jun 04, 2009 3:57 pm; edited 1 time in total (Reason for editing : Js used mod privilages wrongly)
avatar
3d
Admin
Admin

Posts : 1227
Points : 41766
GameML Reputation : 66
Join date : 2009-05-31
Age : 35
Location : U.S.A

View user profile http://gameml.iowoi.org

Back to top Go down

Re: Point to mouse with lite.

Post by -js1210- on Thu Jun 04, 2009 2:36 pm

Thanks carinivorous! That is a great piece of code. I just might add that in my tutorial with credit to you as creator
avatar
-js1210-
Super 500 GML
Super 500 GML

Posts : 1298
Points : 32132
GameML Reputation : 27
Join date : 2009-06-02
Age : 22
Location : United States

View user profile http://www.yoyogames.com/members/js1210

Back to top Go down

Re: Point to mouse with lite.

Post by 3d on Thu Jun 04, 2009 3:56 pm

JS! if you edit someones post, who doesnt need to be editted, OR if its me your editting i will remove ur mod privliages.

_________________
Creator of GameML, Thanks for Visiting!
avatar
3d
Admin
Admin

Posts : 1227
Points : 41766
GameML Reputation : 66
Join date : 2009-05-31
Age : 35
Location : U.S.A

View user profile http://gameml.iowoi.org

Back to top Go down

Re: Point to mouse with lite.

Post by -js1210- on Thu Jun 04, 2009 4:11 pm

i know im srry i just wanted to try it out. it wont happen again
avatar
-js1210-
Super 500 GML
Super 500 GML

Posts : 1298
Points : 32132
GameML Reputation : 27
Join date : 2009-06-02
Age : 22
Location : United States

View user profile http://www.yoyogames.com/members/js1210

Back to top Go down

Re: Point to mouse with lite.

Post by 3d on Thu Jun 04, 2009 5:14 pm

alright... i was kidding.

and js1210 is the best person ever Smile

_________________
Creator of GameML, Thanks for Visiting!
avatar
3d
Admin
Admin

Posts : 1227
Points : 41766
GameML Reputation : 66
Join date : 2009-05-31
Age : 35
Location : U.S.A

View user profile http://gameml.iowoi.org

Back to top Go down

Re: Point to mouse with lite.

Post by Wiialex8 on Sun Jun 07, 2009 8:44 am

You can make 360 degrees to; in the first sprite editor, when you click on Edit Sprite, you can click on Animation + Rotation Sequence + Counter-Clockwise.

Then you have to enter 360 as Number of Frames and 360 as Degrees.

Then, in the Step event of your object, you just have to put :

image_index=point_direction(x,y,mouse_x,mouse_y)

Hope that'll help!
avatar
Wiialex8
GameML Noob
GameML Noob

Posts : 47
Points : 30050
GameML Reputation : 1
Join date : 2009-06-07
Age : 23
Location : Quebec!

View user profile http://www.gamma-work.com

Back to top Go down

Re: Point to mouse with lite.

Post by -js1210- on Sun Jun 07, 2009 8:46 am

Yeah but that code is Pro only. Its good but this is helpful because its for Lite.
avatar
-js1210-
Super 500 GML
Super 500 GML

Posts : 1298
Points : 32132
GameML Reputation : 27
Join date : 2009-06-02
Age : 22
Location : United States

View user profile http://www.yoyogames.com/members/js1210

Back to top Go down

Re: Point to mouse with lite.

Post by 3d on Sun Jun 07, 2009 8:51 am

yupp.

_________________
Creator of GameML, Thanks for Visiting!
avatar
3d
Admin
Admin

Posts : 1227
Points : 41766
GameML Reputation : 66
Join date : 2009-05-31
Age : 35
Location : U.S.A

View user profile http://gameml.iowoi.org

Back to top Go down

Re: Point to mouse with lite.

Post by Wiialex8 on Sun Jun 07, 2009 9:01 am

Pro? I though it was Lite...let me see...

No! Nothing Pro inside that code!
avatar
Wiialex8
GameML Noob
GameML Noob

Posts : 47
Points : 30050
GameML Reputation : 1
Join date : 2009-06-07
Age : 23
Location : Quebec!

View user profile http://www.gamma-work.com

Back to top Go down

Re: Point to mouse with lite.

Post by -js1210- on Sun Jun 07, 2009 9:20 am

O yeah my bad. i though it said image_angle.
avatar
-js1210-
Super 500 GML
Super 500 GML

Posts : 1298
Points : 32132
GameML Reputation : 27
Join date : 2009-06-02
Age : 22
Location : United States

View user profile http://www.yoyogames.com/members/js1210

Back to top Go down

Re: Point to mouse with lite.

Post by Wiialex8 on Sun Jun 07, 2009 9:24 am

XD image_index!
avatar
Wiialex8
GameML Noob
GameML Noob

Posts : 47
Points : 30050
GameML Reputation : 1
Join date : 2009-06-07
Age : 23
Location : Quebec!

View user profile http://www.gamma-work.com

Back to top Go down

Re: Point to mouse with lite.

Post by 3d on Sun Jun 07, 2009 9:30 am

oh..

_________________
Creator of GameML, Thanks for Visiting!
avatar
3d
Admin
Admin

Posts : 1227
Points : 41766
GameML Reputation : 66
Join date : 2009-05-31
Age : 35
Location : U.S.A

View user profile http://gameml.iowoi.org

Back to top Go down

Re: Point to mouse with lite.

Post by CarnivorousA on Wed Jun 10, 2009 5:34 am

Wiialex8 wrote:You can make 360 degrees to
I did that once, it goes ridiculously slow.

_________________
avatar
CarnivorousA
Moderator
Moderator

Posts : 1402
Points : 31982
GameML Reputation : 17
Join date : 2009-06-01
Age : 23
Location : At the bottom of the lake.

View user profile http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Re: Point to mouse with lite.

Post by Hepolite on Wed Jun 10, 2009 7:25 am

The best solution to rotations, is this:

direction = point_direction(x, y, mouse_x, mouse_y)
image_index = image_number * direction/360

This allows you to have ANY number of sub-images, and it will still work. I recommend 36 or 24 sub-images. Also, if you want animated sprites, here's how you can do this:

Make a new sprite, this contains frame two, repeat as many times as necessary to get all the frames in the animation. Rotate them all anti-clockwise. They should all have the same number of sub-images.
Next step, head over to the object create event, and place this code:
current_frame = 0;
image_frame[0] = 2; // Number of frames
image_frame[1] = spr_frame_1; // Frame 1
image_frame[2]= spr_frame_2; // Frame 2

frame_speed = 1; // Speed of the animation

In the step event, place this code
current_frame += frame_speed;
while (current_frame > image_frame[0]) {current_frame -= image_frame[0];}

In the draw event, place this code:
draw_sprite(image_frame[current_frame], image_index, x, y);

And that should do the job Wink
avatar
Hepolite
GameML Noob
GameML Noob

Posts : 23
Points : 30077
GameML Reputation : 12
Join date : 2009-06-03
Age : 24
Location : Land far, far away from the land far, far awaay

View user profile

Back to top Go down

Re: Point to mouse with lite.

Post by 3d on Wed Jun 10, 2009 10:53 am

wow.

_________________
Creator of GameML, Thanks for Visiting!
avatar
3d
Admin
Admin

Posts : 1227
Points : 41766
GameML Reputation : 66
Join date : 2009-05-31
Age : 35
Location : U.S.A

View user profile http://gameml.iowoi.org

Back to top Go down

Re: Point to mouse with lite.

Post by CarnivorousA on Fri Jun 12, 2009 1:34 am

Making direction equal point_to_mouse probably won't let the object move properly, because direction is already a variable for which direction the object is moving in.

_________________
avatar
CarnivorousA
Moderator
Moderator

Posts : 1402
Points : 31982
GameML Reputation : 17
Join date : 2009-06-01
Age : 23
Location : At the bottom of the lake.

View user profile http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Re: Point to mouse with lite.

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum