Phant00m
TIGBaby
|
|
« 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!
|