1up Indie
Member
GM Version: GMS2
Target Platform: All
Summary:
This video tutorial shows you how to make 2 types of segmented enemy in gamemaker studio 2.
What are these types? Well, they are like those iconic enemies that you see in a good old mario game. One where the segments are flying after each other and one where the segments are "on rails".
The idea is that it is only one simple object "cloning" itself. No real magic here.
Tutorial bombhead snake thing:
Create:
Step:
Tutorial cactus dude:
Create:
Step:
Alarm[1]:
Target Platform: All
Summary:
This video tutorial shows you how to make 2 types of segmented enemy in gamemaker studio 2.
What are these types? Well, they are like those iconic enemies that you see in a good old mario game. One where the segments are flying after each other and one where the segments are "on rails".
The idea is that it is only one simple object "cloning" itself. No real magic here.
Tutorial bombhead snake thing:
Create:
Code:
tail_parts = 4;
follow = false;
takeThis_Id = id;
followThisOne = id;
// create follwing ball
checkOnce = false;
Code:
// head ->
if (follow == false) {
x = lerp(x, mouse_x, 0.02);
y = lerp(y, mouse_y, 0.02);
}
//
if (follow == true) {
x = lerp(x, followThisOne.x, 001);
y = lerp(y, followThisOne.y, 0.1);
}
// flip image
if (x > xprevious) { image_xscale = -1; }
if (x < xprevious) { image_xscale = 1; }
if (tail_parts > 0 and checkOnce == false) { tail_parts -= 1; checkOnce = true;
if (tail_parts == 0) {
with instance_create_layer(x,y, "Instances", obj_BossSnake) {
tail_parts = other.tail_parts;
follow = true;
followThisOne = other.takeThis_Id;
sprite_index = spr_Boss_End;
}} else
with instance_create_layer(x,y, "Instances", obj_BossSnake) {
tail_parts = other.tail_parts;
follow = true;
followThisOne = other.takeThis_Id;
sprite_index = spr_Boss_Part;
}
}
Tutorial cactus dude:
Create:
Code:
tail_parts = 4;
follow = false;
takeThis_Id = id;
followThisOne = id;
// create follwing ball
checkOnce = false;
// ease move
start = -1.5;
dest = 1.5;
duration = 120;
time = 0;
move = 0; // ease function -1.5 to 1.5
// wiggle movement
start_X = x;
realmovement = 0;
startEasing = false;
// delay for each following part
startChecking = false;
alarm[0] = 30; // delay to check
Step:
Code:
// head ->
// Ease function
if (startEasing == true) {
if ( time < duration) {
move = ease_in_and_out(time, start, dest - start, duration);
time++;
}
else {
var tempStart = start;
start = dest;
dest = tempStart;
time = 0; }}
if (follow == false) {
x = start_X + move + realmovement;
// actual movement
realmovement += 0.05; }
if (follow == true ) {
x = followThisOne.x + move;
}
// flip image
if (x > xprevious) { image_xscale = -1; }
if (x < xprevious) { image_xscale = 1; }
if (tail_parts > 0 and checkOnce == false and startChecking == true) {
tail_parts -= 1; checkOnce = true;
with instance_create_layer(start_X, y + 14, "Instances", obj_BossCactus) {
tail_parts = other.tail_parts;
follow = true;
followThisOne = other.takeThis_Id;
sprite_index = spr_Cactus_Body;
}
}
Alarm[1]:
Code:
/// @description start checking
startChecking = true;
startEasing = true;
Last edited by a moderator: