Help in bomberman like game with bump.lua (slide in blocks edges)

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
bahamut
Prole
Posts: 13
Joined: Thu Mar 23, 2017 4:36 pm
Location: Brazil

Help in bomberman like game with bump.lua (slide in blocks edges)

Post by bahamut » Fri Mar 24, 2017 12:46 am

(I dont talk english very good, read with it in mind)

Hi, I'm making a bomberman-like game, and have a trouble with collision in the edge of blocks. I'm making a code that solve it, but I solve one problem, and other appear... After try for 3 days, I'm here asking for help.
I'm using bump.lua, and the lines for this solution/trouble are 79 - 87, in controls.lua.
Arrows move the char, and Z drop a bomb. I'm very dumb in programing, so, my code looks like messy.
The problem (at moment) is: when I move to Down and Right (or Down and Left) next to the block edge, my char start to trembling sometimes, and eventually enter in the vein.
I'm trying do first the vertical slides, and when work perfectly, add the horizontal slides too.
If someone can fix my code or give me other way to do it, i will appreciate so much. But, if possible, fix my code or do something easy to understand. A found other codes that do it, and I understand nothing... Like I written, I'm dumb in programming.
(PS: I know a other bugs in my code, like placing 2 bombs from right to left, destroy 2 barrels instead of one, and pick powerups without "stomp" them. If you find another, please, tellme. In my attempts of fix this slides, I get some teleports, but in moment, no one occour. If you get it, please, tell me)
Attachments
bombmaniacs.love
(50.19 KiB) Downloaded 92 times
Chances of 1 in one million occurs all the time.

User avatar
Imaculata
Party member
Posts: 102
Joined: Mon Aug 10, 2015 2:51 pm

Re: Help in bomberman like game with bump.lua (slide in blocks edges)

Post by Imaculata » Sat Mar 25, 2017 10:52 am

I'm not seeing the trembling, but I do notice another problem:

You made the hitbox of the player the exact size of the player-sprite, which is also the exact same size of the gaps it has to fit through. This makes it nearly impossible to enter any of the lanes, because the player has to line up perfectly.

Image

To get the game to a some what playable state, you should first make sure that the hitbox of the player is much smaller than the gaps he has to fit through. I recommend making his hitbox a small rectangle around his feet (no collision on his head or chest, because its a fake perspective), and I also recommend making the hitbox less wide than his actual sprite size.

By doing this, you will of course run into issues with the sprite of the player now being partially overlapped by the blocks, but that is a draw order problem, and just another issue to tackle later on. First make sure it plays well, then worry about how it looks.

Another way to solve this issue, is to have the player automatically align with a nearby row of tiles. The original Legend of Zelda did this (Link snaps to half-tiles), and I think maybe Bomberman did this too.

User avatar
Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Help in bomberman like game with bump.lua (slide in blocks edges)

Post by Jasoco » Sat Mar 25, 2017 3:37 pm

Draw order is exactly why I write my own library for drawing things to the screen in the correct order.

User avatar
bahamut
Prole
Posts: 13
Joined: Thu Mar 23, 2017 4:36 pm
Location: Brazil

Re: Help in bomberman like game with bump.lua (slide in blocks edges)

Post by bahamut » Sat Mar 25, 2017 5:04 pm

In my code, I put for if the player collide with the edge of the block (< 15 pixels, each tile have 32p), they move my char for top (negative Y). In a correction, if the player move above the Y coordinate to enter in the vein (ex: need Y = 128, and I moved to 127), it put my Y in the exact value to enter (Y = 128), and for force the enter, give me X + 1 (or - 1, depending of the direction). This work "nice" if I press Up and left or Right. But doing from top to bottom, the character start to trembling/shake in the middle-botton of the block, next to a vein. I think he detect the point to start to move to Up, but I need block this trigger, and have no success in this. (
In this image, is one example of the point where he start to trembling/shake (it dont occur every time, but if you try for a short time, you will see):
trembling point.png
trembling point.png (64.11 KiB) Viewed 3153 times
He ocasionally enter after trembling/shaking in the point, but the ideal is dont occur it. I thinked in this idea before, of reduce the sprite size, but in the original bomberman games, they slide too (like in Zelda games), I will need search a mode to the player dont mode Up and Down in the middle of horizontal corridors (with a small size, we can do it). Is a good idea, but dont looks like the right solution:
possible move in corridors.png
possible move in corridors.png (65.24 KiB) Viewed 3153 times
In future, I will do it, but because the vertical size of the character (the bomberman head drawin top of the blocks, but dont have colision), only for stetic.
And now, the game isnt playable, have a lots of work to do =] (set more players, create a menu, enemies, create the death event, special things of the stages, etc, etc, etc)
I want create a cool bomberman engine, and have an idea of game to play online with my friends (PvP or PvE). Good times of 2d bomberman games, I really miss this style.
Chances of 1 in one million occurs all the time.

User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: Help in bomberman like game with bump.lua (slide in blocks edges)

Post by airstruck » Sat Mar 25, 2017 5:16 pm

I think Imaculata's suggestion for grid-snapping is a good one.

Instead of doing what you described in the first paragraph, try moving the player in the same direction after the key is released until the player is exactly on a tile. In other words, don't allow the player to stop between tiles, just keep going until you get to the next tile.

User avatar
bahamut
Prole
Posts: 13
Joined: Thu Mar 23, 2017 4:36 pm
Location: Brazil

Re: Help in bomberman like game with bump.lua (slide in blocks edges)

Post by bahamut » Sat Mar 25, 2017 5:37 pm

airstruck wrote:
Sat Mar 25, 2017 5:16 pm
I think Imaculata's suggestion for grid-snapping is a good one.

Instead of doing what you described in the first paragraph, try moving the player in the same direction after the key is released until the player is exactly on a tile. In other words, don't allow the player to stop between tiles, just keep going until you get to the next tile.
But this isnt the same in bomberman snes games, you can move without be aligned in the tiles. I try align just when the char try enter in corridors. If you move to top and try enter in any corridor, you can without problem. But when you try Down, sometimes occur the trembling problem =/
Chances of 1 in one million occurs all the time.

User avatar
Imaculata
Party member
Posts: 102
Joined: Mon Aug 10, 2015 2:51 pm

Re: Help in bomberman like game with bump.lua (slide in blocks edges)

Post by Imaculata » Sat Mar 25, 2017 6:58 pm

I'm playing this on a laptop, but I presume the behavior is the same for all.

When I am right above a lane and press down, nothing happens most of the time, unless my pixels are lined up perfectly. The same happens when I try to enter a lane sideways. As shown in the top picture.

Image

What I would expect, is the bottom picture. As long as the player is close enough to a lane, pressing down should cause the player to slide into the lane automatically. This means that you can still walk into wall blocks, but you don't have to perfectly line up the player any more. The game should do that for you.

MrFariator
Party member
Posts: 153
Joined: Wed Oct 05, 2016 11:53 am

Re: Help in bomberman like game with bump.lua (slide in blocks edges)

Post by MrFariator » Sat Mar 25, 2017 7:30 pm

Yes, Imacaluta's second image is how Bomberman games have worked since the days of old. However, one thing to note is that Bomberman games (almost) never have lanes that are wider than one tile, so you can essentially make "soft-locking tiles": player slides from tile to tile, but can stop between tiles at any time. Thus in practice player is always standing on either one or two tiles. In addition to this, player is usually either walking vertically or horizontally on a given lane; not simultaneously as diagonals don't exist in classic Bomberman game modes.

The problem with the corners then comes from when player is standing between two tiles, which basically happens every time when you try to turn because lining up perfectly can be a bit difficult. To avoid this, you can do:

1) Check if player is trying to turn from a horizontal lane to a vertical lane or vice versa (could just check player inputs for these)
2) Find the two tiles the player is standing on (if player is standing perfectly only on one tile and there are no solid blocks on the path, then jump to step 5)
3) Find the closest eligible lane based on the tile(s) the player is standing on. If a solid block is blocking that lane, then stop here an do nothing in regards to turning.
4) Check if the threshold for turning the corner has been reached (perhaps check if 50% or more of player's collision box is already on the desired lane); this could be done with simple rectangle queries using bump
5) Move the player towards the lane if all the required conditions are met; if the player is standing on the lane then move along that lane

There are other ways to approach this, of course, as these are just some thoughts from the top of my head.
Last edited by MrFariator on Sat Mar 25, 2017 8:13 pm, edited 2 times in total.

User avatar
Imaculata
Party member
Posts: 102
Joined: Mon Aug 10, 2015 2:51 pm

Re: Help in bomberman like game with bump.lua (slide in blocks edges)

Post by Imaculata » Sat Mar 25, 2017 7:58 pm

MrFariator wrote:
Sat Mar 25, 2017 7:30 pm
4) Check if the threshold for turning the corner has been reached (perhaps check if 50% or more of player's collision box is already on the desired lane); this could be done with simple rectangle queries using bump
5) Move the player onto the lane if all the required conditions are met
This is pretty much how my own game snaps the player to ladders. It checks if the player is close to a ladder, and if it is beyond a certain threshold (50% onto the ladder tile), it moves the player to the x location of the ladder tile, so the player lines up perfectly.

User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: Help in bomberman like game with bump.lua (slide in blocks edges)

Post by airstruck » Sat Mar 25, 2017 8:30 pm

Given that you can't move diagonally and you can't push anything around, it looks like there's no need for complex collision response. I suspect Bump may not be necessary at all.

Working off of MrFariator's suggestion, I imagine the steps going something like this:

1) Find the tile that the majority of the player's hitbox is on; we'll call it tile T.
2) If the player is moving towards or away from T (on the same axis), or is exactly on T, let him move as normal, else continue to step 3.
3) If there's an empty tile next to T in the direction the player is trying to move, move him towards T instead, else don't move.

By "let him move as normal" in step 2, I mean move him in the direction he's pressing if there's nothing in the way, otherwise don't move him.

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests