Search found 6 matches

by laurad
Thu Feb 20, 2014 6:04 pm
Forum: Support and Development
Topic: moving a polygon
Replies: 11
Views: 5292

Re: moving a polygon

This is what you want. local function triangleCenter(x1,y1,x2,y2,x3,y3) return (x1+x2+x3)/3,(y1+y2+y3)/3 --averaged point coordinates end local angle,posX,posY --local variables prevent accidental overwriting by other files local function keyboard(dt) local rotationSpeed = math.pi*dt --half of a ci...
by laurad
Thu Feb 20, 2014 3:32 pm
Forum: Support and Development
Topic: moving a polygon
Replies: 11
Views: 5292

Re: moving a polygon

This is what you want. local function triangleCenter(x1,y1,x2,y2,x3,y3) return (x1+x2+x3)/3,(y1+y2+y3)/3 --averaged point coordinates end local angle,posX,posY --local variables prevent accidental overwriting by other files local function keyboard(dt) local rotationSpeed = math.pi*dt --half of a ci...
by laurad
Thu Feb 20, 2014 3:26 pm
Forum: Support and Development
Topic: moving a polygon
Replies: 11
Views: 5292

Re: moving a polygon

You'd need to apply the same modifcation to all the points in the polygon. So first stuff the points in a table, and then update all their x or y coordinates depending on where you are moving. Something like below (warning, untested.) points = { 100, 200, 200, 100, 150, 200 } function love.update( ...
by laurad
Thu Feb 20, 2014 1:58 pm
Forum: Support and Development
Topic: moving a polygon
Replies: 11
Views: 5292

moving a polygon

Hi so right now I have managed to make this triangle rotate but how can i make it so that when you press "up" the triangle will move upwards? Thanks function love.load() angle = 0 end function love.update(dt) keyboard(dt) end function keyboard(dt) if love.keyboard.isDown("left") ...
by laurad
Thu Jan 30, 2014 12:19 pm
Forum: General
Topic: boundingbox collision help
Replies: 3
Views: 1584

Re: boundingbox collision help

Thanks. I am trying to make pong and I am checking whether there is a collision between the ball and player2. So how would I use the if statement then

Code: Select all

if CheckCollision(ball.x,ball.y,ball.width,ball.height,player2.x,
player2.y,player2.width,player2.height) then
  -- code
end
by laurad
Thu Jan 30, 2014 7:34 am
Forum: General
Topic: boundingbox collision help
Replies: 3
Views: 1584

boundingbox collision help

Hi I have copied this function from the wiki but when I run the game I get this error main.lua:107: ')' expected near '.' I don't get what the problem is function CheckCollision(ball.x,ball.y,ball.width,ball.height,player2.x, player2.y,player2.width,player2.height) return ball.x < player2.x+player2....