How to use collisions?
Posted: Sat Mar 09, 2013 5:26 pm
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".nikneym wrote:Hi guys. I wanna using collisions but I don't know. Can your help me?
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