Page 1 of 1
Drowning in a sea of code Plz Help!
Posted: Tue Dec 02, 2014 3:27 pm
by RikkySharkz
Hello, I'm sure you will have heard all this before but hear me out, I'm new to love2D and could use some help.
After about a week trying to find a good tutorial just to get started, but I'm lost i can't find a path to follow.
If some one could just show me were to start, i would be so grateful.
Best Regards
Rikky
Re: Drowning in a sea of code Plz Help!
Posted: Tue Dec 02, 2014 9:37 pm
by IceQB
Re: Drowning in a sea of code Plz Help!
Posted: Wed Dec 03, 2014 10:40 am
by undef
Re: Drowning in a sea of code Plz Help!
Posted: Wed Dec 03, 2014 3:26 pm
by RikkySharkz
Thanks you
Tile set one was very helpful, Do you know of any good collision tutorials?
Re: Drowning in a sea of code Plz Help!
Posted: Wed Dec 03, 2014 4:56 pm
by IceQB
I do not have any tutorials but this should be helpful for you.
Simple collision:
Code: Select all
function CheckCollision(ax1,ay1,aw,ah, bx1,by1,bw,bh)
local ax2,ay2,bx2,by2 = ax1 + aw, ay1 + ah, bx1 + bw, by1 + bh
return ax1 < bx2 and ax2 > bx1 and ay1 < by2 and ay2 > by1
end
Or this
This is only example, values can be not correct.
collision and table example:
Code: Select all
tileW, tileH = 32,32
-- player.x - player position at X
-- player.y - player position at Y
-- player.speed_y - player speed at Y axis
-- player.speed_x - player speed at X axis
for y = 1, #map do
local xy = map[y]
for x = 1, #xy do
local number = xy[x]
if player.y+32 >= ((y-1)*tileH) and player.y <= ((y-1)*tileH) and player.x > ((x-1)*tileW)-32 and player.x < ((x-1)*tileW)+32 then
player.speed_y = math.min(player.speed_y, 0)
elseif player.y >= ((y-1)*tileH) and player.y-32 <= ((y-1)*tileH) and player.x > ((x-1)*tileW)-32 and player.x < ((x-1)*tileW)+32 then
player.speed_y = math.max(player.speed_y, 0)
end
if player.y >= ((y-1)*32)-32 and player.y <= ((y-1)*tileH)+30 and player.x+32 > ((x-1)*tileW) and player.x < ((x-1)*tileW) then
player.speed_x = math.min(player.speed_x, 0)
elseif player.y >= ((y-1)*tileH)-32 and player.y <= ((y-1)*tileH)+32 and player.x > ((x-1)*tileW) and player.x-32 < ((x-1)*tileW) then
player.speed_x = math.max(player.speed_x, 0)
end
end
end