Jump to content


Photo

mouse


  • Please log in to reply
11 replies to this topic

#1 slojanko

slojanko

    HARD GAMER

  • GMC Member
  • 410 posts
  • Version:GM8

Posted 26 April 2012 - 09:59 AM

I am making a mini game like a puzzle, where you have to lead the mouse thro a series of mazes, without touching the wall, but I cant do it becouse I cant make the mouse to jump at player's position. Any ideas?
  • 0

#2 NukeTheCat

NukeTheCat

    GMC Member

  • GMC Member
  • 461 posts
  • Version:GM8.1

Posted 26 April 2012 - 10:26 AM

I recommend you don't do that because that equivalent to hacking -- if the player can't exit the game because the mouse is set at the position.
Also if the level is too hard then how do you think the player going to do anything with the mouse jammed up (You can't do anything until you pass the level. Wahahahaha >:D)
I recommend have an object at mouse position and let the object follow the mouse.

Edited by Jlm07, 26 April 2012 - 10:27 AM.

  • 0

#3 slojanko

slojanko

    HARD GAMER

  • GMC Member
  • 410 posts
  • Version:GM8

Posted 26 April 2012 - 10:31 AM

This is what I want: When the room starts the mouse should jump on player, and then the player should move with the mouse.
Almost like scary game maze game.

Edited by original games, 26 April 2012 - 10:32 AM.

  • 0

#4 TerraFriedSheep

TerraFriedSheep

    GMC Member

  • GMC Member
  • 2825 posts
  • Version:GM:Studio

Posted 26 April 2012 - 11:01 AM

Just put the following code in the players step event:

x=mouse_x;
y=mouse_y;

That will set the players x and y coordinates to the x,y coordinates of the mouse :thumbsup:
  • 0

#5 slojanko

slojanko

    HARD GAMER

  • GMC Member
  • 410 posts
  • Version:GM8

Posted 26 April 2012 - 11:03 AM

You obviously arent listening to me. If i set that, the player will instantly jump to wherever the mouse it. So the palyer could win the maze when he starts, if he knows where the finish is
  • 0

#6 TerraFriedSheep

TerraFriedSheep

    GMC Member

  • GMC Member
  • 2825 posts
  • Version:GM:Studio

Posted 26 April 2012 - 11:17 AM

You obviously arent listening to me. If i set that, the player will instantly jump to wherever the mouse it. So the palyer could win the maze when he starts, if he knows where the finish is


Yeah sorry, I was more replying to the other posters comments about setting the mouse positions, and overlooked the original question. If you're wall objects are solid, you can just move towards the position of the mouse, and when you collide with the walls you'll be set back to the position before you tried moving, hence you won't be able to go through the wall. I would post a more thorough explanation, but I see FiaB is posting, so I'll probably be ninja'd :ninja:
  • 0

#7 slojanko

slojanko

    HARD GAMER

  • GMC Member
  • 410 posts
  • Version:GM8

Posted 26 April 2012 - 11:26 AM

If i make the walls solid, it wot help at all, if i do:

x=mouse_x
y=mouse_y

Becouse the player can jump thro the wall.
  • 0

#8 TerraFriedSheep

TerraFriedSheep

    GMC Member

  • GMC Member
  • 2825 posts
  • Version:GM:Studio

Posted 26 April 2012 - 11:29 AM

If i make the walls solid, it wot help at all, if i do:

x=mouse_x
y=mouse_y

Becouse the player can jump thro the wall.


"You obviously arn't listening to me", ironically.

I said if you move towards the position of the mouse, not set the position as the mouse.

direction=point_direction(x,y,mouse_x,mouse_y);
speed=4;

So the player will try to move 4 pixels towards the mouse position. Then, when the player collides with the solid walls, the x and y positions are automatically set back to their previous x and y positions before the collision.

It's a simple technique, and won't be smooth, but it's a starting point.
  • 0

#9 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5400 posts
  • Version:GM:Studio

Posted 26 April 2012 - 11:31 AM

then why don't you do it like all the other mouse maze games do it, make a button in the previous room, when you press/move over it you get taken to the next room, and the start is at the same position as the button was in the last room.. and if he moves outside it again, then delete the marker and create the start button at the point where the cursor object started out..

anyway.. here is one way using the diffrent position of the mouse to move the cursor

create event:
last_x=mouse_x;
last_y=mouse_y;
step event:
x+=mouse_x-last_x;
y+=mouse_y-last_y;

last_x=mouse_x;
last_y=mouse_y;

but you might do it something like this:

create event:
window_mouse_set(x,y)
window_set_cursor(cr_none) // or cr_cross
with the code that Soulsnatcher posted in the step event.. if you use the button method you don't even need the window_mouse_set

when you hit a wall, then do it like the flash games does:
intance_create(xstart,ystart,obj_restart_button)
window_set_cursor(cr_default)
instance_destroy()
making a restart button where the start position was, and on mouse enter you create the cursor object again at its position while destroying the button

if you fear cheaters using drawpads to just click at the goal position, then make the cursor object do a collision check between x,y and mouse_x,mouse_y, if it finds anything between there, then restart
EDIT: and might also be an idea to check the distance between the two points aswell

.. make it possible to collect coins to buy checkpoints x3

Edited by FoxInABox, 26 April 2012 - 11:34 AM.

  • 0

#10 slojanko

slojanko

    HARD GAMER

  • GMC Member
  • 410 posts
  • Version:GM8

Posted 26 April 2012 - 11:50 AM

.. make it possible to collect coins to buy checkpoints x3


Already did it

window_mouse_set(x,y)

This is what I was looking for, thx

Edited by original games, 26 April 2012 - 11:51 AM.

  • 0

#11 quantumleap2099

quantumleap2099

    GMC Member

  • GMC Member
  • 7 posts
  • Version:GM8

Posted 26 May 2012 - 04:49 AM

u could just have a button labeled Click ME right infront of the object u want to move, so have two of the object u want to move(one that is the actual object(call it obj_char), and one that does nothing(call it obj_nothing.) so when u click on Click ME
the button is deleted and obj_nothing is changed to obj_char
then use mouse_x,mouse_y

Edited by quantumleap2099, 26 May 2012 - 04:55 AM.

  • 0

#12 slojanko

slojanko

    HARD GAMER

  • GMC Member
  • 410 posts
  • Version:GM8

Posted 26 May 2012 - 04:56 AM

I found the solution thanks to GMC
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users