Would A Classic Doom Inspired Game Work In LOVE2D?

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: Would A Classic Doom Inspired Game Work In LOVE2D?

Post by Robin »

I do not. However, I noticed it happens at well with Artificial Immunity. So only for invisible/captured mouse? I'll investigate.

EDIT: so, interestingly, roughly 10% of the time I set the cursor to a random position, it's position is reported one pixel to the left or one pixel to the top (rarely, both at the same time). I have not yet identified a pattern in these positions.

EDIT: x positions affected (for 800x600 window): 2, 7. and every number divisible by five from 240 up to and including 415.
y positions affected for same window: 3, 6, 150, 157, 163, 164, 170, 177, 183, 184, 190, 478, 479, 491, 492, 493, 504, 505, 506, 517, 518, 519, 531, 532, 544, 545, 546, 557, 558 and 559.

What the hell is going on? Why from 150 to 190 and then from 478 to 559? Why +7, +6, +1, +6, ...? Why +1, +12, +1, +11, +1, +1, +11, +1, +1, +12, +1, +12, +1, +1, +1, +1, +1?
Help us help you: attach a .love.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Would A Classic Doom Inspired Game Work In LOVE2D?

Post by Davidobot »

Robin wrote:So is the constant spinning to the left intentional or is it just what happens on my computer?
It's just you, as you already pointed out.
zorg wrote:
Robin wrote:So is the constant spinning to the left intentional or is it just what happens on my computer?
It doesn't spin for me, but the floor does glitch occasionally when i turn.
Happens sometimes, I need to redo the floor using shaders.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Would A Classic Doom Inspired Game Work In LOVE2D?

Post by Jasoco »

Looking good. Cant wait for you to redo the floors. That's one thing I never got around to doing. One day I'd like to start a Wolf 3D project again and would love to see this one advanced more.

You need to fix collision though. The player gets way too close to the wall.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Would A Classic Doom Inspired Game Work In LOVE2D?

Post by Davidobot »

Jasoco wrote:Looking good. Cant wait for you to redo the floors. That's one thing I never got around to doing. One day I'd like to start a Wolf 3D project again and would love to see this one advanced more.
I wrote out the pseudo code for floors, will try to implement soon.

I can also bet you that I will be able to make a pseudo 3D character in-game, which can be viewed from any angle, without having a ton of sprites, just 4 - front, back, left and right side. A bit like a Minecraft flower. (Not sure if this even counts as raycasting)
Jasoco wrote: You need to fix collision though. The player gets way too close to the wall.
Will do. Should be a simple matter of extending the player's hit box.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Would A Classic Doom Inspired Game Work In LOVE2D?

Post by Jasoco »

Davidobot wrote:I can also bet you that I will be able to make a pseudo 3D character in-game, which can be viewed from any angle, without having a ton of sprites, just 4 - front, back, left and right side. A bit like a Minecraft flower. (Not sure if this even counts as raycasting)
I don't know if it would look right though. But do it and we'll see what it looks like. Personally I'd say just doing the sprites the traditional way would be best.

Or you could go the way of many indie games do now (GunGodz) and how I think Wolfenstein originally did it and just have a front view since levels will probably be small and linear enough that enemies will always be aware of you and attacking instead of like DOOM where they could be left alone and eventually go back into idle mode and start walking around and you could sneak up on them.

Or go the Paper Mario route and have a front and back and have them be like sheets of paper. Experiment.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Would A Classic Doom Inspired Game Work In LOVE2D?

Post by Davidobot »

I re-did the floor. It looks beautiful, except for weird glitching that occurs when I turn the camera sometimes. (Bottom left and right corners)
Image
Btw, that was incredibly easy.
It's something like this:

Code: Select all

Cast rays, add any tiles they pass to a table.
Parse through table calculating the corners and draw the tiles.
Last edited by Davidobot on Thu Jan 15, 2015 3:32 pm, edited 1 time in total.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Would A Classic Doom Inspired Game Work In LOVE2D?

Post by Jasoco »

What method exactly are you using to do the floor? It would determine when you have that weird glitch. Are you drawing each tile one at a time? If so it'll be because of the 4 points of each floor tile, when the camera is at a certain angle, one of those points might not be calculated which causes the 4 sided textured polygon to suddenly become 3 sided which would cause that problem. It's an issue with doing 3D without using a real 3D engine with raytracing and pixel shading.

You'd either have to tweak the camera or make each polygon for each floor tile broken into smaller pieces so none of them lose a point at any point.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Would A Classic Doom Inspired Game Work In LOVE2D?

Post by Davidobot »

Jasoco wrote:What method exactly are you using to do the floor? It would determine when you have that weird glitch. Are you drawing each tile one at a time? If so it'll be because of the 4 points of each floor tile, when the camera is at a certain angle, one of those points might not be calculated which causes the 4 sided textured polygon to suddenly become 3 sided which would cause that problem. It's an issue with doing 3D without using a real 3D engine with raytracing and pixel shading.

You'd either have to tweak the camera or make each polygon for each floor tile broken into smaller pieces so none of them lose a point at any point.
It is caused by the one of the corners being behind the camera. To fix this, you can do a check, but that results in this:
Image

EDIT:
I nearly got it, will probably get it done tomorrow.
Last edited by Davidobot on Thu Jan 15, 2015 3:33 pm, edited 1 time in total.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Would A Classic Doom Inspired Game Work In LOVE2D?

Post by Jasoco »

I've been trying to figure out how to do that for years. That point is always behind the camera. So it gets calculated as being inverted and on the screen in a weird location, which causes the polygon it belongs to to become a "backface" which then results in it being excluded from rendering (Which is what is being seen here.) The only way I've found to bypass it is as I mentioned, by either adjusting the camera location or making the tiles smaller. Either way is going to screw things up a bit. I wish there was a way to somehow figure out where that point should be for reals. Possibly using super amazing maths. Maybe someone on this forum can figure it out.

What we need is a shader that does this for us using a reference image. (Which would be a canvas with all the floor textures on it or something.) It'd probably be more efficient too. No idea how though.
Wojak
Party member
Posts: 134
Joined: Tue Jan 24, 2012 7:15 pm

Re: Would A Classic Doom Inspired Game Work In LOVE2D?

Post by Wojak »

I don't know if this helps, but this is 100% different method than You are using:
viewtopic.php?p=173100#p173100
the shader code is:

Code: Select all

local myShader = love.graphics.newShader[[
	extern number camdist;
	extern number h;
	extern number w;
	extern Image tile;
	extern number tw;
	extern number th;
	extern number plax;
	extern number play;
	extern number plaz;
	extern number plar;
	extern number plary;
	extern Image map;
	//extern number mapc[20*20];
	vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
		number invert1 = 0- 2*plary;
		number invert2 = 32;
		number invert3 = 0;
		number tiletexture = 5;
		bool invert4 = false;
		if (screen_coords.y < h/2-plary) {
			screen_coords.y = h-screen_coords.y;
			invert1 = 0;
			invert2 = 0;
			invert3 = 180;
			invert4 = true;
		}
		number pr2 = (screen_coords.x - w/2)*(60/w);
		number pr = (plar+180-invert3) + pr2;
		if (pr>=360) {
			pr = pr - 360;
		}
		if (pr<=0) {
			pr = 360+pr;
		}
		if (pr2>=360) {
			pr = pr - 360;
		}
		if (pr2<=0) {
			pr = 360+pr;
		}
		number y = play+cos(plar*3.14159265/180);
		number x = plax+sin(plar*3.14159265/180);
		
		number d = h/2;
		number sc = camdist*(invert2 - plaz)/(d-(screen_coords.y)+plary+invert1);
		number sc2 = sc/cos(pr2*3.14159265/180);
		number olddist = 1/cos(pr2*3.14159265/180);
		number newx = x-(olddist-sc2)*cos(pr*3.14159265/180);
		number newy = y-(olddist-sc2)*sin(pr*3.14159265/180);
		if (floor(newx/32) >=1 && floor(newx/32) <= 20 && floor(newy/32) >= 1 && floor(newy/32) <= 20) {
			number index = Texel(map,vec2(floor(newx/32-1)/20,floor(newy/32-1)/20)).g;
			if (invert4) {
				index = Texel(map,vec2(floor(newx/32-1)/20,floor(newy/32-1)/20)).r;
			}
			tiletexture = 256*index;
		}
		number d2 = floor((floor(newy/32)+1-newy/32)*tw)+tw*tiletexture;
		number d3 = floor((floor(newx/32)+1-newx/32)*th);
		vec4 pixel2 = Texel(tile,vec2(d2/(tw*6),d3/th));
		return pixel2;	
	}
]]
and it is a translation to this:
http://www.permadi.com/tutorial/raycast/rayc12.html

extern Image tile – the tileset
extern Image map; - two encoded maps in r and g:
map ={
{1,2,2}
{1,2,3}
{1,1,1}
}
where the integers are the ids of the specific images (the real map size is 20x20)
the only things that change every frame are:
extern number plax;
extern number play;
extern number plaz;
extern number plar;
extern number plary;
and this ate the player position and 2 rotations

You need to apply this shader to a white rectangle that has the size of the display (or half of the display if you want just the floor)

screen_coords.y < h/2-plary is the horizon (separates floor from ceiling)
h,w - the size of the display
th, tw – the size of the tile
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 4 guests