Page 1 of 2

löve newbie has some questions

Posted: Sat Oct 17, 2009 10:56 pm
by OUT
Hi all!
I explored löve 1 week ago and I'm very happy with it ^^
I will ask my questions here, in this thread. Now I just have one:

SCROLLING

I am a newbie at game dev, but I did some simple stuff in C++ with SDL. Basically you can copy surfaces, or part of them on top of other surfaces. I had a big "game world" surface and I cut out screensized pieces of it and basically scrolling was done.
But you can't copy surfaces (images) on top of each other in Löve, so I can't make the big "world surface".
How should I make scrolling here? Please help me.

Re: löve newbie has some questions

Posted: Sun Oct 18, 2009 12:14 am
by Robin
The easiest way of doing that is using an offset:

Code: Select all

love.graphics.draw(image1, image1_x - offset_x, image1_y - offset_y)
love.graphics.draw(image2, image2_x - offset_x, image2_y - offset_y)
Further, there are a lot of games on this forum you can look at, to see how they did something.

Good luck and welcome.

Re: löve newbie has some questions

Posted: Sun Oct 18, 2009 6:28 am
by OUT
thanks
wow it is really great that basically if you download a game you can inspect the source

Re: löve newbie has some questions

Posted: Sun Oct 18, 2009 10:23 am
by Robin
OUT wrote:wow it is really great that basically if you download a game you can inspect the source
It certainly is. ^^

Re: löve newbie has some questions

Posted: Sun Oct 18, 2009 3:03 pm
by OUT
teehee!
I found the orgasmic CAMERA class!

p.s. the wiki is awesome as well

Re: löve newbie has some questions

Posted: Sun Oct 18, 2009 5:15 pm
by bartbes
I must tell you that with the coming release of 0.6.0 CAMERA is becoming near-obsolete, for my own game I've decided on dropping it when I get around to it.

Re: löve newbie has some questions

Posted: Sun Oct 18, 2009 7:34 pm
by OUT
I see, thanks for the tip

anyway I have a new problem:

as a first project, today I made PONG. Good learning experience.
The top and the bottom of the screen are shapes of a static body in the physics world.
The player walls are also shapes of static bodies, if the players push their buttons, I modify their positions with body:setPosition().

There is only 1 dynamic object, the ball itself.
The problem is when there is the serving phase, I randomize the starting velocities of the ball, I set these with body:setvelocity().
The ball won't move at all UNLESS I set gravity in the physics world, which obviously is just PLAIN BAD in this game. I dont want any gravity!

I got to set the gravity at least ~ (0, 1) or the ball won't move at all. I made the program print out the randomized and current velocity values of the ball. If there is no gravity, it will print that the ball has for example a velocity = -120, 70 but it won't move at all.

Could someone explain this to me?

Re: löve newbie has some questions

Posted: Sun Oct 18, 2009 8:10 pm
by Robin
This is not directly related to gravity. You see, what I think has happened is that the ball "fell asleep". You need to call :setSleep(false) on the body at the start of every update. In LÖVE 0.6.0 you will be able to just call :setAllowSleep(false) on the body once after it is created.

Re: löve newbie has some questions

Posted: Sun Oct 18, 2009 8:24 pm
by OUT
wow thanks for the fast answer ! this forum is cool.
now i can go to sleep with this stuff being solved :)

Re: löve newbie has some questions

Posted: Mon Oct 19, 2009 1:06 am
by hey5000
I'll just consider this thread to be a reason for me not to post a new thread asking a newbie question. :D

Does anyone have a simple example of basic collision? I just need something to give me an idea of how it works, so I kind implement it into my own code.