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!

Join the forum, it's quick and easy

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!
Would you like to react to this message? Create an account in a few clicks or log in to continue.
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: https://gameml.forumotion.com/GameML-File-Sharing-h3.htmPlease add only games.
Create A GAMEML BLOG!
Make a Blog on GameML:http://gamemlblogs.wetpaint.com

Point to mouse with lite.

5 posters

Go down

Point to mouse with lite. Empty Point to mouse with lite.

Post by CarnivorousA 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.
CarnivorousA
CarnivorousA
Moderator
Moderator

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

http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Point to mouse with lite. Empty Js. do not missuse mod privilages.

Post by 3d 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)
3d
3d
Admin
Admin

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

https://gameml.forumotion.com

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

Post by -js1210- 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
-js1210-
-js1210-
Super 500 GML
Super 500 GML

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

http://www.yoyogames.com/members/js1210

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

Post by 3d 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.
3d
3d
Admin
Admin

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

https://gameml.forumotion.com

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

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

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

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

http://www.yoyogames.com/members/js1210

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

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

alright... i was kidding.

and js1210 is the best person ever Smile
3d
3d
Admin
Admin

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

https://gameml.forumotion.com

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

Post by Wiialex8 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!
Wiialex8
Wiialex8
GameML Noob
GameML Noob

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

http://www.gamma-work.com

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

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

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

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

http://www.yoyogames.com/members/js1210

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

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

yupp.
3d
3d
Admin
Admin

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

https://gameml.forumotion.com

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

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

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

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

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

http://www.gamma-work.com

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

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

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

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

http://www.yoyogames.com/members/js1210

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

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

XD image_index!
Wiialex8
Wiialex8
GameML Noob
GameML Noob

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

http://www.gamma-work.com

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

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

oh..
3d
3d
Admin
Admin

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

https://gameml.forumotion.com

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

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

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

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

http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

Post by Hepolite 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
Hepolite
Hepolite
GameML Noob
GameML Noob

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

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

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

wow.
3d
3d
Admin
Admin

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

https://gameml.forumotion.com

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

Post by CarnivorousA 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.
CarnivorousA
CarnivorousA
Moderator
Moderator

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

http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Point to mouse with lite. Empty Re: Point to mouse with lite.

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

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