Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Hello,

I don't suppose you have a tutorial, do you?  I am trying to figure out what parts of the code I need for my keyboard controlled top-down game.  My hope is to use the Basic code.  I understand some of what I need, but maybe not all of it, or where it should all go.  

I have placed movement_and_collision(dir,walkSpeed,oWall); in my oPlayer's Step event, and have copied the movement_and_collision Script into my own project.  Do I need the General Helpers or Vec2 scripts?  Is there other movement and/or collision code I need elsewhere.  What I have done doesn't seem to work.

I apologize for my ignorance.  I'm trying to figure this out, and there are very little comments within the code.  Any advice would be appreciated.  

Thanks so much!

(1 edit)

Yeah, sorry, a tutorial is planned but on the back-burner a bit.

Ultimately the only thing you NEED is to call the script.
You do the work to determine the direction you want the character to move in.
You do the work to determine the speed you want the character to move.

Pass both of those to the script and it will take care of the rest.

So the absolutely easiest implementation would be this:

var _hori = keyboard_check(vk_right) - keyboard_check(vk_left);
var _vert = keyboard_check(vk_down) - keyboard_check(vk_up);

var _dir = -1;
if(point_distance(0,0,_hori,_vert) > 0) {
    _dir = point_direction(0,0,_hori,_vert);
}
movement_and_collision(_dir,walkSpeed,oWall)

If you have further questions, feel free to hit me up on Discord.  DMs are open to anyone who has joined the GMS Discord Server: https://discord.gg/By6u9pC