I admire bump.lua, simple and super.
I have a little width and height trouble with my character. He is a box of 54x54 pixels, however there is a border in front of him and he can move into tiles, is there an easy way to correct this?
I have attached the character and main.lua. I know the character is not centered, I tried that yesterday and it didn't make any difference. Does it have anything with pseudo borders to do?
Edit: I think from looking at love.draw at the bottom of the code it has do to with offsetting half the width and height, but using full width and height to the item player in bump.
How to use bump.lua
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: How to use bump.lua
- Attachments
-
- main.lua
- (29.85 KiB) Downloaded 161 times
Re: How to use bump.lua
A bit more specific:
If I have offset when drawing my player character, do I have to take this into account when adding the tile to a world in bump.lua?
My character bumps nicely into positive x- and y-axis but when I go into the negative x- and y-axis the tile overlaps with the map-tiles. That's the issue.
Bindie
If I have offset when drawing my player character, do I have to take this into account when adding the tile to a world in bump.lua?
My character bumps nicely into positive x- and y-axis but when I go into the negative x- and y-axis the tile overlaps with the map-tiles. That's the issue.
Bindie
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: How to use bump.lua
I am sorry, I can't help you with what you gave me. I don't understand what you are trying to do and the code you gave me does not work on its own (it depends on lots of stuff that is missing, like missing tiles, fonts and sounds).
Please make a .love file with the missing assets, or at least give me a clean main.lua file, so that I can see what the problem is.
Please make a .love file with the missing assets, or at least give me a clean main.lua file, so that I can see what the problem is.
When I write def I mean function.
Re: How to use bump.lua
Sure, It seems my character tile overlaps with all other tiles in the positive y axis and x axis.
- Attachments
-
- Room collision.love
- (1.7 MiB) Downloaded 163 times
Re: How to use bump.lua
Just judging from what I understand you wrote in the posts: bump.lua x/y values are the top-left corner of the object, so you need to account for width/height when drawing something centered.Bindie wrote:Sure, It seems my character tile overlaps with all other tiles in the positive y axis and x axis.
Re: How to use bump.lua
So how do I account for width and height?
Say I draw with an offset to make character centered, how does this translate into bump and where should I put the new x and y values with offset?
Say I draw with an offset to make character centered, how does this translate into bump and where should I put the new x and y values with offset?
Re: How to use bump.lua
That depends on how you draw your character. With a rectangle you don't have to do anything for drawing:Bindie wrote:So how do I account for width and height?
Say I draw with an offset to make character centered, how does this translate into bump and where should I put the new x and y values with offset?
Code: Select all
player = {
x = 100,
y = 100,
hw = 20,
hh = 15
}
function love.draw()
love.graphics.rectangle ("fill", player.y, player.y, player.hw*2, player.hh*2)
-- image with rotation:
love.graphics.draw(player.image, player.x+player.hw, player.y+player.hh, player.rot, 1, 1, player.wh, player.hh)
-- (image, center x, center y, rotation, scale x, scale y, center offset x, center offset y)
end
If you measure a distance, shoot or spawn something else you always need to consider the player center (p.x+p.hw,p.y+p.hh).
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: How to use bump.lua
I have added the following lines to the end of your love.draw function:
They show the rectangle which the player is being represented by in bump. It is not aligned with the picture you show of him:
(I would have sent you a .love file, but you have named your folders and files with uppercase (assets/Player/Laser.png) while your code uses lowercase (assets/player/laser.png) so the .love can't be done without renaming, which I don't want to do myself).
I don't know how to fix this in your code because ... frankly, it is quite difficult to understand. I can give you some pointers though:
Code: Select all
love.graphics.setColor(255,0,0)
love.graphics.rectangle('line', world:getRect(player))
They show the rectangle which the player is being represented by in bump. It is not aligned with the picture you show of him:
(I would have sent you a .love file, but you have named your folders and files with uppercase (assets/Player/Laser.png) while your code uses lowercase (assets/player/laser.png) so the .love can't be done without renaming, which I don't want to do myself).
I don't know how to fix this in your code because ... frankly, it is quite difficult to understand. I can give you some pointers though:
- Intent it properly. It can look like a hassle, but it will save you some bugs later on.
- Your code is mixing very different concerns in the same place. Variables which control the animation are mixed up with others related with scrolling. This makes it very difficult to understand for someone not familiar with it.
- I recommend that you put your player's "head" centered in the image. Otherwise when he "turns around" he "moves in a weird way around the center of the image". Accounting for this will be difficult when you want to align the drawing with the physical rectangle.
When I write def I mean function.
Re: How to use bump.lua
Awesome, thanks.
Re: How to use bump.lua
Hey, my player.x and player.y are in the middle of the player. So when I add the rectangle to bump.lua, it draws it from the middle instead from the top left corner of the image. Here comes the concrete question: Is it possible to use bump.lua and have a rectangle around the player while still rotating it from the center and moving the rectangle?
Do I have to offset every x and y value for the player so I can still have player.x and player.y in the center of the image and everything working properly or should I just add an extra player.x and player.y which already is offset?
Do I have to offset every x and y value for the player so I can still have player.x and player.y in the center of the image and everything working properly or should I just add an extra player.x and player.y which already is offset?
Who is online
Users browsing this forum: No registered users and 4 guests