Help with melee attacks

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
slavian
Prole
Posts: 6
Joined: Tue Apr 07, 2015 3:42 pm

Help with melee attacks

Post by slavian »

Hi all, is there any example of the melee attack from a mathematical point, without using of Physics engine, etc.
Thank you.

Upd added the project.
At the moment, that's such nonsense. Prompt how to better implement the melee attack.
Ps, a lot of code collected from various sources something himself already did. I'm just starting to learn Lua.
Last edited by slavian on Sat Apr 18, 2015 6:44 pm, edited 1 time in total.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Help with melee attacks

Post by Nixola »

We'll need a bit more of your code to help you with that
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
slavian
Prole
Posts: 6
Joined: Tue Apr 07, 2015 3:42 pm

Re: Help with melee attacks

Post by slavian »

Use AdvTiled to create the world

Code: Select all

function game.load()
	tileSize = 32  -
	loadMap(1, 15, 8)
end

function loadMap(level, ox, oy)
	map = loader.load("map_"..level..".tmx")  
	mapw = map.width*tileSize-800
        maph = map.height*tileSize-600	
	createPlayer(ox,oy)  

end

function exec( s )
    return loadstring( 'return ' .. s )()
end

function Actors.new(name, x, y, w, h)
	local a = objLayer:newObject(name, actor, x, y, w, h)
	a.dir = 1
	a.hv = 0
	a.vv = 0
	a.coll = {left=false, top=false, right=false, down=false, player=false}
	return a
end

function checkObj(a,b)
	if a.x+a.width>b.x and a.x<b.x+b.width and a.y+a.height>b.y and a.y<b.y+b.height then return true end
end
function Actors.update(dt)
	for i,v in ipairs(objLayer.objects) do if not v.properties.static then
		v.coll.top, v.coll.down, v.coll.right, v.coll.left = false, false, false, false
end
  function createPlayer(ox,oy)
	                player = Actors.new("player", ox*tileSize, oy*tileSize, 31, 55)
   end
function game.update(dt)
Actors.update(dt)
   end
function game.draw()
       gr.push()
       map:autoDrawRange(cx, cy, 0, 0)
       map:draw()
       gr.pop()
 end
Showed pieces of code responsible for creating the character and check on touch
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: Help with melee attacks

Post by Jeeper »

I would really recommend you dropping ATL, it is very outdated and no longer maintained. Use STI instead: viewtopic.php?f=5&t=76983
slavian
Prole
Posts: 6
Joined: Tue Apr 07, 2015 3:42 pm

Re: Help with melee attacks

Post by slavian »

well, you're most likely right. I hope not to have to redo everything)
slavian
Prole
Posts: 6
Joined: Tue Apr 07, 2015 3:42 pm

Re: Help with melee attacks

Post by slavian »

A little digging in the STI. I realized that while arranges ATL.
slavian
Prole
Posts: 6
Joined: Tue Apr 07, 2015 3:42 pm

Re: Help with melee attacks

Post by slavian »

okay, though Papuan code, but it works. Made the attack, the creation of an actor in pleer.x and player.y + 1 to the size of a 1-tile and life of 0.5 seconds. And also delay before the attack 0.5 seconds.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests