• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Using 2D Arrays and Macros to control character sprites

G

Gami_Pro

Guest
Hello! This will be my first post here, and it's my first time using GML. However, I have studied numerous programming languages at University, and I'm in my junior year. So I have a fairly firm grasp on programming concepts and languages.

Right now I am working on my first game, and I want to control my character using some user defined macros and 2D Arrays. The idea for this comes from u/heartbeast 's video seen here:

This is what I have so far:
sprite[MACRO, STATE] = corresponding sprite.
2D Array Setup.PNG

User Defined Macros

User Defined Macros.PNG

scr_move
Movement Script.PNG

This Unlisted YouTube video shows what is happening when the code runs.

I've done my best to provide all the information I can. I'm looking forward to the community response. Thanks!
 

jo-thijs

Member
Hi and welcome to the GMC!

I can't see anything wrong with the code you've posted.
Perhaps some other code causes this.
Could you give us the object information of your player object (text that appears when clicking on "object information" when editing an object)?
 
Z

zircher

Guest
If hspd or vspd never get set to zero, will the not_moving state ever happen (say hspd = .0000001)
Toss some variable into the GUI and see what's happening numbers wise.
 
G

Gami_Pro

Guest
Hi and welcome to the GMC!

I can't see anything wrong with the code you've posted.
Perhaps some other code causes this.
Could you give us the object information of your player object (text that appears when clicking on "object information" when editing an object)?
Maybe this is what you're looking for?
obj_playerInfo.PNG
 

jo-thijs

Member
You reset the sprite in the step event after you execute the script.
This can cause the given issue if movement is always set to MOVE.
And if you take a look at your code, this is true.
You never set movement to NOT_MOVING,
you always set playerState to NOT_MOVING.
 
G

Gami_Pro

Guest
You reset the sprite in the step event after you execute the script.
This can cause the given issue if movement is always set to MOVE.
And if you take a look at your code, this is true.
You never set movement to NOT_MOVING,
you always set playerState to NOT_MOVING.
This fixed the issue! Thank you :)
One simple line of code caused so much trouble :bash:
 
Top