Question about Mari0 programming
-
- Posts: 7
- Joined: 06 Mar 2012, 15:06
Hi. I now have lua(löve) in school and i wanted to make a sidescoller game. But i don't know how to make it actually sidescolling. Perhaps i could put a camera to an objekt or sth. like this but i don't know how to do this. Would be cool if someone answers.
PS.: I hope Mari0 SE will come out soon : )
PS.: I hope Mari0 SE will come out soon : )
You simply offset all drawing operations by the amount of pixels that you want the screen to be scrolled.
If you're lazy, you could use love.graphics.translate.
If you're lazy, you could use love.graphics.translate.
-
- Posts: 7
- Joined: 06 Mar 2012, 15:06
Pehaps with just coordinates but i'm not sure if it can be made easier.
...
Last edited by Qcode on 21 Oct 2021, 08:52, edited 1 time in total.
-
- Posts: 7
- Joined: 06 Mar 2012, 15:06
And another question: How is the best method of making a circle following my mouse? I tried it but it isn't very pretty.
function love.load()
kreisX = love.mouse.getX()
kreisY = love.mouse.getY()
end
function love.draw()
love.graphics.setColor(255,255,0)
love.graphics.circle("fill",kreisX,kreisY,15,15)
end
function love.update(dt)
if kreisX < love.mouse.getX() then
kreisX = kreisX + speed
else
if kreisX > love.mouse.getX() then
kreisX = kreisX - speed
end
end
if kreisY < love.mouse.getY() then
kreisY = kreisY + speed
else
if kreisY > love.mouse.getY() then
kreisY = kreisY - speed
end
end
end
function love.load()
kreisX = love.mouse.getX()
kreisY = love.mouse.getY()
end
function love.draw()
love.graphics.setColor(255,255,0)
love.graphics.circle("fill",kreisX,kreisY,15,15)
end
function love.update(dt)
if kreisX < love.mouse.getX() then
kreisX = kreisX + speed
else
if kreisX > love.mouse.getX() then
kreisX = kreisX - speed
end
end
if kreisY < love.mouse.getY() then
kreisY = kreisY + speed
else
if kreisY > love.mouse.getY() then
kreisY = kreisY - speed
end
end
end
Code: Select all
function love.load()
kreisX = love.mouse.getX()
kreisY = love.mouse.getY()
end
function love.draw()
love.graphics.setColor(255,255,0)
love.graphics.circle("fill",kreisX,kreisY,15,15)
end
function love.update(dt)
kreisX = love.mouse.getX()
kreisY = love.mouse.getY()
end
Code: Select all
function love.draw()
love.graphics.setColor(255,255,0)
love.graphics.circle("fill",love.mouse.getX(),love.mouse.getY(),15,15)
end
-
- Posts: 7
- Joined: 06 Mar 2012, 15:06
Thx but the circle should come after the mouse not BE the mouse.
No, this is the perfect thing to do as a beginner.rokit boy wrote:you can use simple trigonometry to make it move towards the mouse. but you don't really want to do that as a beginnerMissingNo98 wrote:Thx but the circle should come after the mouse not BE the mouse.