löve newbie has some questions

General discussion about LÖVE, Lua, game development, puns, and unicorns.
OUT
Prole
Posts: 6
Joined: Sat Oct 17, 2009 9:28 pm

löve newbie has some questions

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: löve newbie has some questions

Post 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.
Help us help you: attach a .love.
OUT
Prole
Posts: 6
Joined: Sat Oct 17, 2009 9:28 pm

Re: löve newbie has some questions

Post by OUT »

thanks
wow it is really great that basically if you download a game you can inspect the source
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: löve newbie has some questions

Post by Robin »

OUT wrote:wow it is really great that basically if you download a game you can inspect the source
It certainly is. ^^
Help us help you: attach a .love.
OUT
Prole
Posts: 6
Joined: Sat Oct 17, 2009 9:28 pm

Re: löve newbie has some questions

Post by OUT »

teehee!
I found the orgasmic CAMERA class!

p.s. the wiki is awesome as well
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: löve newbie has some questions

Post 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.
OUT
Prole
Posts: 6
Joined: Sat Oct 17, 2009 9:28 pm

Re: löve newbie has some questions

Post 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?
Attachments
pingpong.love
Here is the pong game
(5.9 KiB) Downloaded 311 times
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: löve newbie has some questions

Post 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.
Help us help you: attach a .love.
OUT
Prole
Posts: 6
Joined: Sat Oct 17, 2009 9:28 pm

Re: löve newbie has some questions

Post by OUT »

wow thanks for the fast answer ! this forum is cool.
now i can go to sleep with this stuff being solved :)
User avatar
hey5000
Prole
Posts: 4
Joined: Tue Jan 13, 2009 7:21 am
Location: Georgia

Re: löve newbie has some questions

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests