How to use collisions?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
nikneym
Citizen
Posts: 56
Joined: Sat Mar 09, 2013 1:22 pm
Contact:

How to use collisions?

Post by nikneym »

Hi guys. I wanna using collisions but I don't know. Can your help me?
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: How to use collisions?

Post by micha »

Yes, we can help you, but you have to specify your question.

If you have, please upload a .love-file and tell us, what exactly you want to implement.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: How to use collisions?

Post by Davidobot »

Please also remember that you can use different methods to detect collisions. (love.physics or just a if statement check)
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
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: How to use collisions?

Post by kikito »

nikneym wrote:Hi guys. I wanna using collisions but I don't know. Can your help me?
Collisions is kind of a big field. What you are asking is similar to asking "I wanna use math but I don't know".

What exactly are you trying to achieve? I.e. what kind of game?
When I write def I mean function.
User avatar
nikneym
Citizen
Posts: 56
Joined: Sat Mar 09, 2013 1:22 pm
Contact:

Re: How to use collisions?

Post by nikneym »

I'm solve. Here is my code:

Code: Select all

function love.load()

	yazfont=love.graphics.newImageFont("font/yazi.png"," abcdefghijklmnopqrstuvwxyz1234567890!?");
	love.graphics.setFont(yazfont);
	
	fare=love.graphics.newImage("images/fare.png");
	love.mouse.setVisible(false);
	love.mouse.setGrab(false);
	
	--Fizik !
	
		dunya=love.physics.newWorld(0,9,64*81,true);
	
		obje={};
		
			obje.karakter={};
				
				obje.karakter.body=love.physics.newBody(dunya, love.graphics.getWidth()/2,love.graphics.getHeight()/2,"dynamic");
				obje.karakter.shape=love.physics.newCircleShape(20);
				obje.karakter.fixture=love.physics.newFixture(obje.karakter.body,obje.karakter.shape,1);
				obje.karakter.fixture:setRestitution(0.2);
				obje.karakter.x=love.graphics.getHeight()/2;
				obje.karakter.y=love.graphics.getWidth()/2;
	
			obje.zemin={};
				
				obje.zemin.body=love.physics.newBody(dunya,love.graphics.getWidth()/2,love.graphics.getHeight());
				obje.zemin.shape=love.physics.newRectangleShape(love.graphics.getWidth(),32);
				obje.zemin.fixture=love.physics.newFixture(obje.zemin.body,obje.zemin.shape,1);
	
end

function love.update(dt)
	
	dunya:update(dt);
	
	if love.keyboard.isDown("escape") then
	
		love.event.quit("quit");
	
	end
	
	--Fare
	fareX, fareY=love.mouse.getPosition();
	
end

function love.draw()

	--Arkaplanı Çiz
	love.graphics.setBackgroundColor(255,255,255);
	
	--Fare
	love.graphics.draw(fare, love.mouse.getX() - fare:getWidth() / 2, love.mouse.getY() - fare:getHeight() / 2);
	
	--Zemin
	love.graphics.polygon("fill",obje.zemin.body:getWorldPoints(obje.zemin.shape:getPoints()));
	
	--Karakter
	love.graphics.setColor(30,30,30);
	love.graphics.circle("fill",obje.karakter.body:getX(),obje.karakter.body:getY(),obje.karakter.shape:getRadius());
	
end
Thanks. :)
Post Reply

Who is online

Users browsing this forum: No registered users and 253 guests