First of all, thanks to all those who helped with my previous question. I'm starting to understand Lua now, and currently working on creating a top down action RPG game. At the moment I have a test version for collision detection, but there is a problem with the player's bounding box. It seems the player bounding box is very much out of alignment with the player.
For a better description of the problem, I have attached the game.
Tiles with number 4 are walkable, while all other tiles block the player.
The collision detection is working fine, but the player's alignment with the blocks are off by 20 pixels in all directions.
Also in LOVE, when you create a new image and draw it, are the starting X and Y axis located in the top-left area of the box?
Another question: How do I create an array of a tileset.png file?
Help with collision detection bug
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Help with collision detection bug
- Attachments
-
- runyonave_tile_engine.love
- (55.23 KiB) Downloaded 179 times
Re: Help with collision detection bug
at first glance your math is off .. when I add
into the
block
the minimum value I get in the terminal is 2, though I have not looked enough to pinpoint why
I dont know how your doing it but I find it extremely helpful to run code under test from the command line, therefore you can dump debuging print statements to the standard-io without cluttering up the love window
Code: Select all
print(math.floor((topLeftX - 1)/20))
Code: Select all
if direction == "left" then
--check LEFTtop
the minimum value I get in the terminal is 2, though I have not looked enough to pinpoint why
I dont know how your doing it but I find it extremely helpful to run code under test from the command line, therefore you can dump debuging print statements to the standard-io without cluttering up the love window
yes, at one time it was in the center of the image, which makes more noobie since but it was a bit of a pain in the arse as you had to offset all 4 sides appropriately when writing and it was voted to be changed quite a few versions agoAlso in LOVE, when you create a new image and draw it, are the starting X and Y axis located in the top-left area of the box?
Re: Help with collision detection bug
Yeah I'll have to look into that. Probably a problem with the array.
I'm currently using notepad++ so no debug window for me. I'm just going to download Scite and use that.
Didn't know the center point was used as the x,y axis before, that would have been really annoying.
I'm currently using notepad++ so no debug window for me. I'm just going to download Scite and use that.
Didn't know the center point was used as the x,y axis before, that would have been really annoying.
Re: Help with collision detection bug
where is love installed on your system? cause it does not really matter what editor your using (heck for core lua functions its not strange to me to use nano for linux or edit for ms-dos), the basic lua system is some form of text editor and a command line ... you could get complicated but I just install love at c:\love then set or make a cmd file where it points the path to that directory
path =c:\love
cd project_folder\project_name
love main.lua
on nix systems like I normally use its a bit different
love (folder_to_love_project)
path =c:\love
cd project_folder\project_name
love main.lua
on nix systems like I normally use its a bit different
love (folder_to_love_project)
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Help with collision detection bug
Filthy lies, this won't work.osgeld wrote: path =c:\love
cd project_folder\project_name
love main.lua
You run it on the folder as well, and, you probably want to pass --console to the binary, so it opens up a debug window for you.
Re: Help with collision detection bug
Love isn't really installed anywhere on my system. When I have a project, I just copy all the love files to the project folder. Then make a zip file. Then When I want to test the game, I just copy main.lua to the zip file, then drag the zip file to love .exe file.osgeld wrote:where is love installed on your system? cause it does not really matter what editor your using (heck for core lua functions its not strange to me to use nano for linux or edit for ms-dos), the basic lua system is some form of text editor and a command line ... you could get complicated but I just install love at c:\love then set or make a cmd file where it points the path to that directory
path =c:\love
cd project_folder\project_name
love main.lua
on nix systems like I normally use its a bit different
love (folder_to_love_project)
I do need a debug console window though, that would make things much easier than using love.graphics.print all the time. Does Scite or another Lua IDE have this funtionality?
How do I edit the binary?bartbes wrote:Filthy lies, this won't work.
You run it on the folder as well, and, you probably want to pass --console to the binary, so it opens up a debug window for you.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Help with collision detection bug
Hoo, complicated. If you're using Notepad++, did you know that running your game can be as easy as hitting a keyboard combination? On my system I have it set up to ctrl+enter. All you have to do is put Love somewhere on your hard drive, set up a run command in Notepad++, and choose a key combo.runyonave wrote: Love isn't really installed anywhere on my system. When I have a project, I just copy all the love files to the project folder. Then make a zip file. Then When I want to test the game, I just copy main.lua to the zip file, then drag the zip file to love .exe file.
The run command should look something like this:
Code: Select all
"c:\your\path\to\love.exe" "$(CURRENT_DIRECTORY)"
Kurosuke needs beta testers
Re: Help with collision detection bug
^ Is there any way to get a debug window on notepad++?
Edit: I set up Scite with Lua, set the lua.prperties in scite. Now it works fine, but the console in Scite is really slow.
For example if I press left and I want to know what the X position is, the console will only show this data after a few seconds, not instantly. That kind of makes it useless. Is there any other way I can see debugging data in a console?
Edit: I set up Scite with Lua, set the lua.prperties in scite. Now it works fine, but the console in Scite is really slow.
For example if I press left and I want to know what the X position is, the console will only show this data after a few seconds, not instantly. That kind of makes it useless. Is there any other way I can see debugging data in a console?
Re: Help with collision detection bug
Yess, I got the collision detection to finally work. There was a problem with one of my arrays.
I am not used to arrays starting at index 1, so I was ignoring it til I realised, 'oh wait, this is Lua! Indexes always start at 1'.
Ugh! Lua, why you no start at 0?
Anyway I attached the bug fixed version. Next, organize my code and add graphics.
Arrow keys to move, all tiles are blocked except for tiles with number 4.
Edit: I added some tiles to test it out.
I am not used to arrays starting at index 1, so I was ignoring it til I realised, 'oh wait, this is Lua! Indexes always start at 1'.
Ugh! Lua, why you no start at 0?
Anyway I attached the bug fixed version. Next, organize my code and add graphics.
Arrow keys to move, all tiles are blocked except for tiles with number 4.
Edit: I added some tiles to test it out.
- Attachments
-
- runyonave_tile.love
- (56.49 KiB) Downloaded 208 times
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Help with collision detection bug
For a debug window (as I mentioned), turn it into:
Code: Select all
"c:\your\path\to\love.exe" --console "$(CURRENT_DIRECTORY)"
Who is online
Users browsing this forum: Google [Bot] and 8 guests