Page 1 of 1

[STI & hump] Movement system help

Posted: Fri Aug 16, 2019 9:37 pm
by miniaturedog
Hey everyone, I've been working with Love2d to create a rough movement system for a game, only using the STI and hump libraries so far. I've got almost everything working, but I've run into a few problems. The intent is to have the player object (a 32x32 purple square hastily downloaded from a tutorial) remaining in the exact middle of the onscreen tiles. Movement should be achieved by moving the map instead of the player in 32-pixel increments to achieve a gridlocked effect, and the map should actually be zoomed in a bit so only a few tiles are visible around the player (think Stardew Valley or something similar). I don't really know enough about Love2d to achieve these sort of effects (I could sure try for hours though and get close), so could anyone give me a few pointers? The love file with everything I have in it so far is included. Thank you!

Re: [STI & hump] Movement system help

Posted: Sat Aug 17, 2019 12:57 am
by JoshGrams
The hump.camera documentation says

Code: Select all

Camera.new(x, y, zoom, rot)
so I'd assume you could just pass a number bigger than 1 there to zoom in. Except...that doesn't work. And it looks like STI is thoroughly obnoxious and resets the transform. I mean, I can see why they did it: to avoid tearing. But it means that it will completely ignore any camera libraries or LOVE2D transform functions that you're using. So if you want to use STI you'll have to figure out the transform properties for the "camera" yourself and pass them directly to STI.

The player is moving on 32-pixel increments, but you're initially placing it in the center of the window, and neither 800/2 nor 600/2 are a multiple of 32, so it's not on a grid cell. And also for some reason you're drawing it at a 16-pixel x-offset? Dunno what's up with that. If you fix those two things (and disable the camera so you can see what's going on) then it will line up with the grid cells.

Re: [STI & hump] Movement system help

Posted: Sun Aug 18, 2019 11:08 pm
by miniaturedog
Thank you! I fixed it (mostly) by just deciding not to use a camera at all since I looked around the forum and other people have had the same problems with STI and hump.
The player is moving on 32-pixel increments, but you're initially placing it in the center of the window, and neither 800/2 nor 600/2 are a multiple of 32, so it's not on a grid cell. And also for some reason you're drawing it at a 16-pixel x-offset? Dunno what's up with that. If you fix those two things (and disable the camera so you can see what's going on) then it will line up with the grid cells.
Right, I have no idea what I was thinking when I added the offset value and neglected to do my math but all I can say is that I was tired, LOL. Currently working on placing the player in the middle of the screen (and on a tile), so for now I've made the map move in 32-pixel increments instead of the player. I also am trying to establish map boundaries for the player so it doesn't just shoot off the screen at a the press of a key.