Blog

GameMaker Studio 2 Follow Player Smoothly

Example:

As we can see, the key and the owl follow the player.

Here’s the code:

 

if (instance_exists(oPlayer)) {

    if(oPlayer.x >= x){
        image_xscale = 1;
        x += (oPlayer.x-10 – x) * 0.04
       y += (oPlayer.y-15 – y) * 0.04
    }else{
        image_xscale = -1;
        x += (oPlayer.x+10 – x) * 0.04
        y += (oPlayer.y-15 – y) * 0.04
    }
}

Cursor Trails in GameMaker Studio 2

GMS2 "Cursor Trails"

Here is a quick cursor trail effect for your GameMaker Studio 2 game!

Here’s an example of the effect we will be creating:

As we can see, the spear and the cursor have a great effect that makes them stand out.

Create Event

// Maximum number of line points
trail_steps = 10;

// Initialize lists for mouse positions (x, y)
trail_x = ds_list_create();
trail_y = ds_list_create();

Step Event

// Insert current mouse postion in the list
ds_list_insert(trail_x, 0, mouse_x);
ds_list_insert(trail_y, 0, mouse_y);

// Remove the last point if exceed the maximum points limit
if ds_list_size(trail_x) >= trail_steps
{
ds_list_delete(trail_x, ds_list_size(trail_x) – 1);
ds_list_delete(trail_y, ds_list_size(trail_y) – 1);
}

 

(if you change mouse_x,mouse_y to another point it will follow that point)

Draw Event

// Draw current sprite
draw_self();

// Init a primitive drawing
draw_primitive_begin(pr_trianglestrip);

// Stores the size of list
var l_size = ds_list_size(trail_x);

// List iteration
for (var i = 0; i < l_size; i++)
{
// Current position
var x1 = ds_list_find_value(trail_x, i);
var y1 = ds_list_find_value(trail_y, i);

// Next position
var x2 = ds_list_find_value(trail_x, min(i + 1, l_size – 1));
var y2 = ds_list_find_value(trail_y, min(i + 1, l_size – 1));

// Set the line ‘thickness’
var rr = 2 – ((i / l_size) * 2);

// Direction
var dd = point_direction(x1, y1, x2, y2);

// Opacity
var aa = 1 – ((i / l_size));

// Color
var cc = make_color_hsv((current_time * 0.5) mod 255, 255, 255); // or use c_white

// Draw first vertice
draw_vertex_color( x1 + lengthdir_x(rr, dd + 90),
y1 + lengthdir_y(rr, dd + 90),
cc, aa);

// Draw second vertice only if is not the fisrt or last point
if i != 0 or i != l_size-1
draw_vertex_color( x1 + lengthdir_x(rr, dd – 90),
y1 + lengthdir_y(rr, dd – 90),
cc, aa);
}

// Finishes primitive drawing
draw_primitive_end();

How it Works

Download Example – https://alex-fc.itch.io/gms2-mouse-trail-effect

GameMaker Studio 2 Grass

Grass ‘Squish’ Effect

image

Here is a quick rundown of how I achieved the ‘squish’ effect for the grass in the gif above. It’s really pretty simple and adds quite a bit of ‘feel’ to the game.

The basic concept is that you are just skewing the top of the grass sprite away from anything that touches it and flattening it a little bit. You can see it better in this gif where boxes are drawn around the sprites.

image

I did this in GameMaker but you should be able to apply this to anything.


I’ll explain this by showing you each event that I created in my object.

Create

First thing to do is create your ‘grass’ object and declare a couple variables in it for keeping track of the skew amount of your grass. I simply used xVar and yVar.

xVar = 0;
yVar = 0;

Collide

Next you’ll need to add a collision event with whatever you want to affect the grass. In it you’ll need to calculate the horizontal distance between the object and the grass and use that to set your grass variables:

var xDist = x – other.x;
var flattenAmount = .3;
xVar = xDist;
yVar = xDist * flattenAmount;   

(This is a simplified equation for yVar, ideally you should divide the xdist by the max amount it can be and use that to flatten the sprite, but I didn’t want to over complicate this explanation.)

End Step

At each step we should approach our normal scale.

xVar = xVar * .8;
yVar = yVar * .8;

(Again this is simplified, you could easily do some sort of easing function here and it would look much better)

Draw

Finally drawing the sprite. Just draw the sprite and skew/flatten the top of it

draw_sprite_pos(sprite_index, image_index,
   bbox_left + xVar,
   bbox_top + yVar,
   bbox_right + xVar,
   bbox_top + yVar,
   bbox_right,
   bbox_bottom + 1,
   bbox_left,
   bbox_bottom + 1,
   1)

There you have it! Squishy grass! 

Source: https://blog.maggard.me/post/134683639250/grass-squish-effect

      • Josh Maggard

Spearited Version 0.5.0

Version 0.5.0 is coming out in early November!

Here’s what to expect:

  • Platforming
    • Winter obstacles
      • Icicles
      • Snow blocks
      • Ice blocks
    • Water
      • New Particles
      • New Animations
      • Floating/Still
      • Waterfalls
    • Puzzles
      • Switches and buttons
      • Doors
      • Open level design
  • Player
    • Player sprite redraw
    • New animations
    • Sliding Cooldown
    • Slower movement
    • Better Physics
    • Swimming
    • Hats
  • Audio
    • New Sounds
    • New Music (Imakemusic SC)
  • Story Development
    • No spoilers here!
Notes:
This update is a pretty big deal! In fact, it is our biggest update EVER. This update will make Spearited a completely different game! New art will make the game’s visuals very different. The new level design will be much better than the last! Difficult puzzles, open exploration, and new visuals will all make this game stand out among the other plaformers.
 
Spearited will be available for purchase in mid-December with a few options for purchase. 
 
Prices:
Standard – $4.99
  • Access to all standard levels.
  • Access to most cosmetic items.
Gold – $9.99
  • All standard levels + DLC content
  • Access to ALL cosmetic items

All playtesters receive the game for free. Playtester positions close in December.

All Patreons receive the game + Bonus content for free.

What makes a good platformer?

What Makes a platformer?

Many new developers make a platformer as their first game. Platformers can be easy to make, but they can be not so fun to play if made incorrectly. When you play a platformer, you expect it to feel smooth and responsive. As a judge for many game jams, I have seen beautiful platformers as well as ugly ones. A platformer requires a player. This player needs to be able to have horizontal and vertical movement (unless the game prevents it). When making such game, be sure to include acceleration, deceleration, accurate gravity, friction, and any other component to help your platformer feel better.

Let’s talk about responsiveness. When I press the spacebar, the player should jump. When there is a delay, or when I am just 1 pixel off from a perfect jump, it frustrates me.  When your player jumps, they should jump slightly off the ground if you just tap the spacebar. If you hold it down, the player should jump much, much higher. This makes your game feel responsive. One of the biggest issues in indie platformers are the pixel-perfect jumps. When I jump off of a platform and I am just a pixel off, I tend to see the game as unresponsive. To fix this, just add a timer after the player leaves a platform and if they are just a pixel off, alow them to jump.

Now let’s talk movement. Your player should follow the laws of gravity! If you have a space platformer, you should have lower gravity (or higher). Gravity makes the player fall at an increasing speed. Another key aspect is acceleration and deceleration. When the player moves, they should gradually pick up speed. Super Mario Bros. 3 is the perfect example of acceleration and deceleration, though there was just a little too much. When your player is in the air, they should move around slower (horizontally, that is). By adding a separate variable, you can make it easy to include this feature. My final tip is to have one variable that controls the rest of the variables. I use “m’ and multiply every value relating to movement by that variable. Here’s an example:

m = 0.5;

hspeed = 2*m;

vspeed = 2*m;

Lots of Martians 1.0.0!

Lots of Martians Official Release!

Lots of Martians is receiving it’s first MAJOR update! Tons of new features has been added! From improved gameplay to new modes, everybody is excited for what UEG Productions has to offer with this update. The launch will cost $4.99, but since this is our very first official release, Lots of Martians will be on sale! Check out the games tab for more info or click HERE

Days
Hours
Minutes
Seconds
Lots of Martians will be released shortly, please be patient, updates take a while!