Grid in game
Grid in game
How to make all objects in the game act on a grid?
Re: Grid in game
Make the metods for your objects and send the grid to them as object:update (grid, dt)
Re: Grid in game
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.
E.g.:
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}
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Grid in game
Or
you then have to translate that information to a grid in love.draw()
Code: Select all
local person = {}
person[1].x = 50
person[1].y = 50
person[2].x = 100
person[2].y = 20
...
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
Re: Grid in game
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
https://github.com/kikito/bump.lua
Re: Grid in game
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
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Who is online
Users browsing this forum: No registered users and 8 guests