How to use bump.lua

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How to use bump.lua

Post by Robin » Wed May 13, 2015 7:52 am

kikito wrote:You could, for example, only allow integer coordinates in your players (so they can be in 163 or 164, but never in 163.819283). You can also try a combination of both.
I would not suggest that. I would suggest keeping the player on the grid, and animating the players when they move from cell to cell, like in every other version of this game I've seen. In which case, you don't really need collision detection, just something simpler to check for walls and stuff.

So yeah, that or a smaller player.
Help us help you: attach a .love.

Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Re: How to use bump.lua

Post by Bindie » Wed May 13, 2015 9:18 am

Kikito: Right, actually the integer solution works fine, and I scaled down the players to 60x60.

Robin: Animating tile to tile, I would like to know more.

User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: How to use bump.lua

Post by kikito » Wed May 13, 2015 10:09 am

Robin wrote:In which case, you don't really need collision detection, just something simpler to check for walls and stuff.
Yes, I forgot to mention that too. In a bomberman style game, your movement is restricted (I think - I have not played that for years).

With the movement restrictions, you don't need a collision detection like bump. You can use the map itself, because the players only "occupy" one tile on each frame. So before moving to the left, you just have to ask "is the cell to my left free"? And allow movement only in that case.

To implement movement restrictions, you have to make your player "commit" to a movement. If you are in one cell and you press "left", the player will keep moving horizontally until you reach the center of the next cell. You can't move "up" or "down", even if they are empty too (you might allow moving back to the right). Once the next center is reached, the player is free to choose another direction. The player is always "aligned with the center of the tiles", at least in one axis. "The cell where the player is standing" is decided by looking at the point in the center of the player's feet.

Doing this in LÖVE is a bit tricky because of dt. If the "center" of a tile is at x=10, in one frame you can be at x=9.55 and on the next one you are at x=10.01, so you have to know "I am moving right and the player is not pressing right any more, so I will stop at x=10 instead of x=10.01".

You don't need to restrict your movement like that if you use bump (but you need to make the player smaller). It won't be exactly like the classical bomberman, but it will also be easier to program IMHO. Your players can be in 4 tiles simultaneously, which would make the kills a bit more realistic too.
When I write def I mean function.

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How to use bump.lua

Post by Robin » Wed May 13, 2015 10:15 am

Basically, you have the internal position, and the position on screen. The former changes when pressing keys, and stays on the grid. The position on screen is updated every frame, so that the player smoothly moves to the actual position.

There are tweening libraries (including one by kikito) that make that easier (and you can also choose how the speed changes, so if it stays the same, or if players accelerate and decelerate over the course of a transition).

You also might want to keep the previous internal position while the position on screen hasn't caught up, so that you can get caught in the blast of a bomb even if you just started moving to another square.
Help us help you: attach a .love.

Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Re: How to use bump.lua

Post by Bindie » Thu May 14, 2015 10:24 am

Aha, cool.
You also might want to keep the previous internal position while the position on screen hasn't caught up, so that you can get caught in the blast of a bomb even if you just started moving to another square.
Exactly, that was tricky to comprehend.

User avatar
zorg
Party member
Posts: 2863
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to use bump.lua

Post by zorg » Fri May 15, 2015 3:36 pm

Robin wrote:...I would suggest keeping the player on the grid, and animating the players when they move from cell to cell, like in every other version of this game I've seen. ...
Just wanted to point out, that the TG-16 and DOS versions of the '91/'92 and '93/'94 versions of Bomberman / Dyna Blaster had that restriction in place only for mobs; the player could stop between tiles as well, and in the former game's case (that i remember), could also do "cornering", i.e. turning early to a perpendicular direction. (don't know how it was implemented though, probably with logic instead of an octagonal bounding box though)
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests