Page 1 of 1

How to use collisions?

Posted: Sat Mar 09, 2013 5:26 pm
by nikneym
Hi guys. I wanna using collisions but I don't know. Can your help me?

Re: How to use collisions?

Posted: Sat Mar 09, 2013 5:54 pm
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.

Re: How to use collisions?

Posted: Sat Mar 09, 2013 7:16 pm
by Davidobot
Please also remember that you can use different methods to detect collisions. (love.physics or just a if statement check)

Re: How to use collisions?

Posted: Sun Mar 10, 2013 2:00 pm
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?

Re: How to use collisions?

Posted: Sun Mar 10, 2013 3:39 pm
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. :)