What's everyone working on? (tigsource inspired)

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: What's everyone working on? (tigsource inspired)

Post by Lafolie »

Jasoco wrote:...stuff...
If you ever want to implement multiplayer, I think sending keypresses might be pretty handy there too. I mean networked multiplayer, of course. I don't really understand the 30/60 fps thing though. Say you were to implement a Hammer Bros. type enemy, that wouldn't be too hard to implement either. Assuming you'd store keypresses along a timeline (using some sort of meta data like timestamps?) you can reproduce the same system for enemies that have 'randomness'. Although there are various levels of efficiency to consider. Do you want multiple timelines running at the same time, even if the enemy is off-screen? Or do you want to create and attach/manage/update/run/whatever a new timeline when its parent element becomes active?

That raycasting looks fancy.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Rukiri
Citizen
Posts: 68
Joined: Mon Jun 27, 2011 5:52 am

Re: What's everyone working on? (tigsource inspired)

Post by Rukiri »

I'm pretty much working on RPG Basics, camera, movement, rpg parties, tile collisions, tile-maps, the whole 9 yards.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: What's everyone working on? (tigsource inspired)

Post by Jasoco »

I'm going to have to see the Raycasting example in person. I've seen way too many that look like crap and none that have ever looked as smooth as Wolfenstein. (Not talking about the textures. I'm talking about the wall lines.)
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: What's everyone working on? (tigsource inspired)

Post by Roland_Yonaba »

Jasoco wrote:I'm going to have to see the Raycasting example in person. I've seen way too many that look like crap and none that have ever looked as smooth as Wolfenstein. (Not talking about the textures. I'm talking about the wall lines.)
Well, my example was directly based on this one.
I just re-wrote this using Lua...And it worked fine, even if there are actually some glitches.
I've planned later on to rewrite it after reading entirely F.Permadi's tutorial on the topic.

Here's the actual source. Maybe you'll have useful comments / critics.

Code: Select all

-------------------------------------------------------------------
--Raycasting sample code (written by Roland Yonaba)
-- Credits to :http://lodev.org/cgtutor/raycasting.html
-------------------------------------------------------------------
local map = {
  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,2,2,2,2,2,0,0,0,0,3,0,3,0,3,0,0,0,1},
  {1,0,0,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,2,0,0,0,2,0,0,0,0,3,0,0,0,3,0,0,0,1},
  {1,0,0,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,2,2,0,2,2,0,0,0,0,3,0,3,0,3,0,0,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,4,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,4,0,0,0,0,5,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,4,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,4,0,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
}

local map_height,map_width = #map,#map[1]

local posX,posY = 22,12
local dirX,dirY = -1,0
local planeX,planeY = 0,0.66
local time,oldtime = 0,0
local w = love.graphics.getWidth()
local h = love.graphics.getHeight()

local moveSpeed, rotSpeed = 0,0

function love.update(dt)
	moveSpeed = dt*3
	rotSpeed = dt
	
	if love.keyboard.isDown('up') then
		if map[math.floor(posX+dirX*moveSpeed)][math.floor(posY)] == 0 then
		posX = posX + dirX*moveSpeed
		end
		if map[math.floor(posX)][math.floor(posY+dirY*moveSpeed)] == 0 then
		posY = posY + dirY*moveSpeed
		end
	end
	
	if love.keyboard.isDown('down') then
		if map[math.floor(posX-dirX*moveSpeed)][math.floor(posY)] == 0 then
		posX = posX - dirX*moveSpeed
		end
		if map[math.floor(posX)][math.floor(posY-dirY*moveSpeed)] == 0 then
		posY = posY - dirY*moveSpeed
		end
	end	
	
	if love.keyboard.isDown('left') then
	local oldDirX = dirX
	dirX = dirX * math.cos(rotSpeed)- dirY*math.sin(rotSpeed)
	dirY = oldDirX * math.sin(rotSpeed)+ dirY*math.cos(rotSpeed)
	local oldPlaneX = planeX
	planeX = planeX * math.cos(rotSpeed) - planeY*math.sin(rotSpeed)
	planeY = oldPlaneX * math.sin(rotSpeed) + planeY*math.cos(rotSpeed)
	end
	
	if love.keyboard.isDown('right') then
	local oldDirX = dirX
	dirX = dirX * math.cos(-rotSpeed)- dirY*math.sin(-rotSpeed)
	dirY = oldDirX * math.sin(-rotSpeed)+ dirY*math.cos(-rotSpeed)
	local oldPlaneX = planeX
	planeX = planeX * math.cos(-rotSpeed) - planeY*math.sin(-rotSpeed)
	planeY = oldPlaneX * math.sin(-rotSpeed) + planeY*math.cos(-rotSpeed)
	end	
	
end


function love.draw()
	love.graphics.clear({0,0,0})	
	for x = 0,w do
	local camX = 2*(x/w)-1
	local rayPosX = posX
	local rayPosY = posY
	local rayDirX = dirX + planeX*camX
	local rayDirY = dirY + planeY*camX
	local mapX = math.floor(rayPosX)
	local mapY = math.floor(rayPosY)
	local sideDistX,sideDistY
	
	local deltaDistX = math.sqrt(1+(rayDirY^2)/(rayDirX^2))
	local deltaDistY = math.sqrt(1+(rayDirX^2)/(rayDirY^2))
	local perpWallDist
	
	local stepX,stepY
	
	local hit = 0
	local side
	
		if rayDirX<0 then
		stepX = -1
		sideDistX = (rayPosX - mapX)*deltaDistX
		else
		stepX = 1
		sideDistX = (mapX+1-rayPosX)*deltaDistX
		end
		
		if rayDirY <0 then
		stepY = -1
		sideDistY = (rayPosY - mapY) * deltaDistY
		else
		stepY =  1
		sideDistY = (rayPosY +1-rayPosY)*deltaDistY
		end
		
		while (hit==0) do
			if (sideDistX < sideDistY) then
			sideDistX = sideDistX + deltaDistX
			mapX = mapX+stepX
			side = 0
			else
			sideDistY = sideDistY + deltaDistY
			mapY = mapY + stepY
			side = 1
			end
			
			if map[mapX][mapY] > 0 then hit = 1 end
		end
		
		if side==0 then
		perpWallDist = math.abs((mapX - rayPosX+(1-stepX)/2)/rayDirX)
		else
		perpWallDist = math.abs((mapY - rayPosY+(1-stepY)/2)/rayDirY)
		end
		
		local lineHeight = math.abs(math.floor(h/perpWallDist))
		local drawStart = -lineHeight/2 + h/2
			if drawStart < 0 then drawStart = 0 end
		local drawEnd = lineHeight/2 + h/2
			if drawEnd >= h then drawEnd = h-1 end
			
		local color = {}
		local square = map[mapX][mapY]
			if square == 1 then color = {255,0,0} 
			elseif square == 2 then color = {0,255,0}
			elseif square == 3 then color = {0,0,255}
			elseif square == 4 then color = {255,255,255}
			else color = {255,255,0}
			end
			
		if side == 1 then 
			for k,v in ipairs(color) do v = v/2 end 
		end
		love.graphics.setColor(color)
		love.graphics.line(x,drawStart,x,drawEnd)
	end

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

Re: What's everyone working on? (tigsource inspired)

Post by Jasoco »

It seems to have some graphic glitches, but it's a great start. If you could figure out a way to use textures on the walls, and place sprites around the level, it'd be amazing.
vpdp_pc
Prole
Posts: 15
Joined: Fri Jul 29, 2011 5:39 am

Re: What's everyone working on? (tigsource inspired)

Post by vpdp_pc »

First, sorry for my English

I'm working on a simple engine (maybe a framework) that make Love2D more easy to use with scenes, component-based architect, support easy-to-perform effect with Lua's coroutine.
The important part of my engine is Thing, it's can be an entity or a board of tetris, because it can be draw to anything you like (it's different from others engine that just support single image or animation for one entity)

Here are some line of my project:

Code: Select all

function gmain()
    --a simple game: player follow the mouse try to avoid monster
    --if monster collide monster -> both of them die
    --if monster collide player -> game over

    --create player
    local player = Thing.new({'player'})

    player.coms:add(coms.Transform.new(0, 0, 0, 1, 1)) --(x, y, rotation, x scale, y scale)

    --a complex shape for player
    local shape = coms.Shape.new('circle', 0, 0, 20)
    shape:add('rectangle', -20, 0, 40, 100) --(x, y, w, h)
    player.coms:add(shape)

    player.coms:add(coms.FollowMouse.new(300)) --speed to follow mouse is 300 pixel/second

    player.draw = function ()
        shape:draw('line') --just simple draw the shape
    end

    --create a lot of monters
    for i = 1, 20, 1 do
        local monster = Thing.new({'monster'}) --a tag for that thing

        --add components
        --add transform, shape (for collision detect), autodraw for monster
        monster.coms:add(coms.Transform.new(math.random(100, 500), math.random(100, 500), math.random()*math.pi, 1, 1))
        monster.coms:add(coms.Shape.new('polygon', -100, -100, 0, 100, 100, -100)) --a triangle shape
        monster.coms:add(coms.AutoDraw.new(img_monster))

        monster.coms:add(coms.Chase.new('player')) --chase nearest thing (has tag 'player')
    end

    --handle collision
    listener.add('begincollide', function (shapeA, shapeB) --the component shape above
        local monster
        local other

        if shapeA.owner.tags:contains('monster') then
            monster = shapeA.owner
            other = shapeB.owner
        elseif shapeB.owner.tags:contains('monster') then
            monster = shapeB.owner
            other = shapeA.owner
        else
            return
        end

        if other.tags:contains('monster') then
            --perform some simple effect
            monster:seq(function ()
                monster:markAsDestroyed() --so it just draw and update, not affect to other alive thing

                --(table to tween, amount of time, end values, start values, type of tween)
                tweener.tween(monster.transform.scale, 2, {x = 0, y = 0}, nil, 'bounce')

                --the interesting part of thing:seq it is a coroutine
                --so this line (monster:destroy()) just be do after the scale go to 0 (in this case 2 second)
                monster:destroy()
            end)
            other:seq(function ()
                other:markAsDestroyed()
                tweener.tween(other.transform.scale, {x = 0, y = 0}, nil, 'bounce')
                other:destroy()
            end)
        elseif other.tags:contains('player') then
            love.event.push('q') --game over :D
        end
    end)
end
User avatar
ncarlson
Prole
Posts: 35
Joined: Wed Jul 20, 2011 4:00 pm

Re: What's everyone working on? (tigsource inspired)

Post by ncarlson »

Last night I got a hankerin' for some puzzle fighter. To be honest, I've never actually written a tetris/block-drop clone before, so this was a learning experience.

Here's what I have so far:



And this is what I'm aiming for:



The collision handling code is absolutely atrocious. Handling all the edge cases is harder than I thought it would be. Have a look if you like, but don't say I didn't warn you. If you have any ideas on how to clean this up, besides the obvious, I'd love to hear.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: What's everyone working on? (tigsource inspired)

Post by Jasoco »

Why do your video titles sound like episode titles for Conan episodes?
User avatar
kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

Re: What's everyone working on? (tigsource inspired)

Post by kraftman »

Jasoco wrote:Why do your video titles sound like episode titles for Conan episodes?
When in Rome
User avatar
nonesuchplace
Prole
Posts: 9
Joined: Wed Feb 10, 2010 12:29 am
Location: Northeastern US

Re: What's everyone working on? (tigsource inspired)

Post by nonesuchplace »

I am (now that I am back after a long hiatus where I learned a lot about programming and project management) teaching a kid how to make games in Löve. A kid who before last week knew next to nothing about computers and absolutely nothing about programming was able to make a Löve app where a rudimentary Abraham Lincoln head moved around the screen, and he figured out most of that on his own.

On my own, I am working on trying to decide what I want to make next, besides monsters.
--
Shane
Post Reply

Who is online

Users browsing this forum: No registered users and 88 guests