Grid in game
Posted: Wed Mar 01, 2023 7:23 pm
How to make all objects in the game act on a grid?
Each object (player, enemy, etc.) will have their position initialized using x and y coordinates. Then you can easily update it based on your algo and interaction and draw it.
Code: Select all
passengers[i] = {location = {x = start_x, y = start_y}, destination = {x = end_x, y = end_y}, walking = true, at_stop = false, waiting_for = false, on_board = false, dwell_time = dwell_time}
Code: Select all
local person = {}
person[1].x = 50
person[1].y = 50
person[2].x = 100
person[2].y = 20
...
Sure, if you want something more complicated. If you just simply need to attach objects to a grid, both examples above will work.darkfrei wrote: ↑Thu Mar 02, 2023 8:06 am Actually the Bump.lua principle: one chunk (some bigger type of tile) can have multiple objects and one object can be in several chunks simultaneously.
https://github.com/kikito/bump.lua