Question about Mari0 programming

General Mar0 discussion has been moved to this subforum!
Post Reply
MissingNo98
Posts: 7
Joined: 06 Mar 2012, 15:06

Post » 07 Dec 2012, 15:51

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 : )

Maurice
Stabyourself.net
Posts: 2145
Joined: 01 Feb 2012, 20:19

Post » 07 Dec 2012, 15:56

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.

MissingNo98
Posts: 7
Joined: 06 Mar 2012, 15:06

Post » 07 Dec 2012, 16:12

thx

MissingNo98
Posts: 7
Joined: 06 Mar 2012, 15:06

Post » 07 Dec 2012, 16:13

thx. And how did u make the collision?

MissingNo98
Posts: 7
Joined: 06 Mar 2012, 15:06

Post » 07 Dec 2012, 16:18

Pehaps with just coordinates but i'm not sure if it can be made easier.

User avatar
Qcode
Posts: 1479
Joined: 05 Feb 2012, 18:00
Contact:

Post » 07 Dec 2012, 16:27

...
Last edited by Qcode on 21 Oct 2021, 08:52, edited 1 time in total.

MissingNo98
Posts: 7
Joined: 06 Mar 2012, 15:06

Post » 19 Dec 2012, 17:53

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

User avatar
Automatik
Posts: 1073
Joined: 20 Jul 2012, 17:54
Contact:

Post » 21 Dec 2012, 20:26

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
Or even just

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

MissingNo98
Posts: 7
Joined: 06 Mar 2012, 15:06

Post » 22 Dec 2012, 19:53

Thx but the circle should come after the mouse not BE the mouse.

Maurice
Stabyourself.net
Posts: 2145
Joined: 01 Feb 2012, 20:19

Post » 22 Dec 2012, 20:30

Then look into smoothing.

User avatar
rokit
Posts: 2095
Joined: 03 Feb 2012, 00:47

Post » 22 Dec 2012, 21:22

MissingNo98 wrote:Thx but the circle should come after the mouse not BE the mouse.
you can use simple trigonometry to make it move towards the mouse. but you don't really want to do that as a beginner

Maurice
Stabyourself.net
Posts: 2145
Joined: 01 Feb 2012, 20:19

Post » 22 Dec 2012, 22:55

rokit boy wrote:
MissingNo98 wrote:Thx but the circle should come after the mouse not BE the mouse.
you can use simple trigonometry to make it move towards the mouse. but you don't really want to do that as a beginner
No, this is the perfect thing to do as a beginner.

MissingNo98
Posts: 7
Joined: 06 Mar 2012, 15:06

Post » 26 Dec 2012, 13:23

Thank you guys.

Post Reply