Drowning in a sea of code Plz Help!

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.
Post Reply
RikkySharkz
Prole
Posts: 2
Joined: Mon Nov 10, 2014 2:02 pm

Drowning in a sea of code Plz Help!

Post 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
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Drowning in a sea of code Plz Help!

Post by undef »

The wiki might be of help as well:

https://www.love2d.org/wiki/Category:Tutorials
twitter | steam | indieDB

Check out quadrant on Steam!
RikkySharkz
Prole
Posts: 2
Joined: Mon Nov 10, 2014 2:02 pm

Re: Drowning in a sea of code Plz Help!

Post by RikkySharkz »

User avatar
IceQB
Citizen
Posts: 67
Joined: Sat Nov 03, 2012 1:11 pm

Re: Drowning in a sea of code Plz Help!

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests