[SOLVED] How to draw the floor in raycasters - scaling problem

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.
Koxinga
Prole
Posts: 13
Joined: Sun Oct 02, 2022 12:29 am

Re: How to draw the floor in raycasters - scaling problem

Post by Koxinga »

And here are the phone screenshots. Weird, isn't it ?
Attachments
phone1.png
phone1.png (562.28 KiB) Viewed 4159 times
phone2.png
phone2.png (551.97 KiB) Viewed 4159 times
Koxinga
Prole
Posts: 13
Joined: Sun Oct 02, 2022 12:29 am

Re: How to draw the floor in raycasters - scaling problem

Post by Koxinga »

It's indeed a problem with DPI scaling.
I can get it working by adding

Code: Select all

t.window.usedpiscale = false
in conf.lua. But the text is messed up (really tiny) and it's pretty slow (because the screen has a massive number of pixels, I suppose).

Guess I'll have to put it back to "true" and find a way to deal with DPI stuff in the shader. If you have any docs about it, I'd be very glad.

Thank you to everyone.
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

Re: How to draw the floor in raycasters - scaling problem

Post by pgimeno »

There's love.window.toPixels and love.window.fromPixels to convert back and forth, and love.graphics.getDPIScale to get the units-to-pixels ratio. Not sure where that will be necessary. If you're using canvases, you can specify dpiscale = 1 for the canvas; see love.graphics.newCanvas.
Koxinga
Prole
Posts: 13
Joined: Sun Oct 02, 2022 12:29 am

Re: How to draw the floor in raycasters - scaling problem

Post by Koxinga »

Hey guys !

I finally solved the problem. After a lot of debugging, I found that the DPI scaling was not the cause of the problem... My calculations were. I was calculating some lengths in "units" (according to my grid) and some in pixels. For a reason I don't really know, it seemed ok on my computer when it shouldn't have.

Now that it's done, I can focus on game mechanics (the best part)

Thanks again to everyone.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: [SOLVED] How to draw the floor in raycasters - scaling problem

Post by Jasoco »

pgimeno wrote: Fri Oct 07, 2022 10:26 pm Raycasting and real 3D are fundamentally different. Real 3D is hardware accelerated and cheap for the CPU; true raycasting is CPU-expensive. It's possible to simulate raycasting with real 3D.
I'll echo this statement. I was working on a Wolfenstein style ray caster a while ago. A few times actually. I had started the project years ago and gave up for a while before coming back to it. I put a lot of work into it and made it look really really neat with a lot of features, but in the end it was always an issue of the raycasting itself using a lot of CPU time. So if you were looking in a direction where there's a lot of tiles, even ones you really can't actually see, it would use more CPU time and sometimes slow things down even on a small enough map.

Then Groverburger released his g3d engine and I switched over to it. It's much more efficient to just use 3D and pretend it's 2D than to do it in 2D. It's ironic but it's true. I'm still working on getting my new true 3D engine up to par with my old 2D Raycaster though because there were a bunch of things I could do with the raycaster that I can't do as easily with true 3D. But I'll figure it out I'm sure.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 7 guests