Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411507 Posts in 69374 Topics- by 58429 Members - Latest Member: Alternalo

April 26, 2024, 12:26:38 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)GM:S - Mimic of Player?
Pages: [1]
Print
Author Topic: GM:S - Mimic of Player?  (Read 862 times)
Phant00m
TIGBaby
*


View Profile
« on: February 26, 2015, 07:54:41 AM »

Hi,

First post here on the Tigsource forums, been lurking just as a guest for a while now (actually started of with Derek's GM tutorials).
 
Currently I'm making a fairly simple platformer game (bases off RM2KDev's physics-based platform playlist featured on the "Advanced" section of GM tutorials on the GM website), but I'm slowing adding on new mechanics as a learning experience.
 
One I'm currently having trouble with is making a "mimic" of the player.
 
I am currently using an object which stores the players movement using queues, and then draws a sprite using queue on a slight delay (as if it is chasing the players).
 
Code is as follows...:
Create:

yfol = ds_queue_create();
xfol = ds_queue_create();
alarm[2] = room_speed;
active = 0;

Alarm 2:

active = 1;

Step:

ds_queue_enqueue(xfol, o_Player.x);
ds_queue_enqueue(yfol, o_Player.y);
if active
{
    x = ds_queue_dequeue(xfol);
    y = ds_queue_dequeue(yfol);
}

Draw:

draw_sprite(s_Player_Trail,0,x,y);



This is all well and good when using sprites, and I am really happy with the result (looks smooth, accurate, etc.)
 
However I want to expand it further, and I'm not sure where to go next.
 
For example, how would I make it so that the player can collide with this "sprite", and make it restart the room (what I'm currently trying to do). How would I go about doing something like that in the Draw Event, or would I have to change something?
 
Looking for some advice, it is greatly appreciated.
 
Thanks!
Logged
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #1 on: February 26, 2015, 09:24:15 AM »

Well, you seem to be using the x and y position of the object following the player, so you would only really need to add a mask to that object to make it register collisions. You'd then need to add a collision detection event in your player object where if the player touches the trail object, it restarts the room.

Actually, I'm pretty sure Game Maker uses the mask of the current sprite by default, so I'm pretty confident in saying you only need the collision detection. I'm also pretty sure the code in your draw event is superfluous.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic