smooth scrolling 2D game: possible?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
scrolly
Prole
Posts: 5
Joined: Thu Feb 27, 2014 6:10 am

smooth scrolling 2D game: possible?

Post by scrolly »

Hello!
Would LOVE be appropriate (fast enough) for writing a high resolution (1920x1080), smooth scrolling 2D game?

By scrolling, I am talking about Castlevania / Super Metriod / Mario style, where the game is always scrolling in some direction as the player moves. Being able to do Parallax scrolling would be even better.

I tried doing something like this with Python + Pyglet a few years ago, and it seemed very choppy and jittery. Not smooth at all. Someone on their fourms had the same issue, he solved it by writing a C extension, but that's way over my head.

When I look for examples of side scrolling games written in Love, Python, etc, they always seem to be written for a 800x600 window or something small, and are never "video game smooth" scrolling.

Can anyone point me to examples if they exist? Or is LOVE too high-level and I'm doomed to having to learn OpenGL & C++?

Thanks!
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: smooth scrolling 2D game: possible?

Post by micha »

Yes, this is possible in LÖVE.

LÖVE uses OpenGL, which makes the graphics fast. Programming in C++ would only make the game logic faster, but not the graphics.
scrolly
Prole
Posts: 5
Joined: Thu Feb 27, 2014 6:10 am

Re: smooth scrolling 2D game: possible?

Post by scrolly »

micha wrote:Yes, this is possible in LÖVE.

LÖVE uses OpenGL, which makes the graphics fast. Programming in C++ would only make the game logic faster, but not the graphics.
Pyglet uses OpenGL too, and it could not do smooth scrolling. It would jitter randomly.

I didn't fully understand the explanation as to why this was - one reason was Pyglet used "ctypes" which is I guess a slower way to interface with OpenGL, the other reason was that the main loop is Python, which is going to be too slow for doing 1000's of OpenGL calls per second.

I would think LUA would also be a slow, but I've read the latest LOVE uses LuaJIT, so maybe not anymore?
Wojak
Party member
Posts: 134
Joined: Tue Jan 24, 2012 7:15 pm

Re: smooth scrolling 2D game: possible?

Post by Wojak »

LÖVE has ways to limit the number of OpenGL calls by merging multiple images into one so you can have the whole background as 1 image, indestructible world objects as 2 leaving you witch entities that you should not draw if off screen...
-canvas: a very easy way, but not supported on all systems
-spritebunch: maybe even easier, but only for tile based maps
-per pixel operations on image data: in theory the same possibilities as canvas (good math skills required) but it may take a long time to generate something large...
scrolly
Prole
Posts: 5
Joined: Thu Feb 27, 2014 6:10 am

Re: smooth scrolling 2D game: possible?

Post by scrolly »

Wojak wrote:
-spritebunch: maybe even easier, but only for tile based maps
As I understand it, Pyglet takes this approach, it has a Sprite class that is impressive and uses batching.

But I think the issue was, the main loop being python, you would get these ticks that varied wildly, so movement would seem jittery. The answer was to rewrite the main loop in C? Because a scripting language inherently is going to be like this...

Anyway I may be making a big deal about something that is a non-issue..
does anyone have links to LOVE games, or demos, that show off full-screen scrolling?
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: smooth scrolling 2D game: possible?

Post by Germanunkol »

scrolly wrote: does anyone have links to LOVE games, or demos, that show off full-screen scrolling?
Yes: http://www.youtube.com/watch?v=0ztZc4SMsJ4

The game I'm currently working on with micha also does it, but we don't have any videos (yet). But it works perfectly fine, even with huge maps. When you use a sprite batch, make sure to fiddle around with the "usagehint" (some of them caused it to be slower on some systems, for us, although that seems to have been a driver bug). For starting out, you should probably just leave it at nil.

So, bottom line: Love, when used right, is more than fast enough for side-scrolling games.
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: smooth scrolling 2D game: possible?

Post by slime »

Germanunkol wrote:some of them caused it to be slower on some systems, for us, although that seems to have been a driver bug
Well, that's sort of the point of the usage hint - it lets the video driver make a more informed decision about where to put the SpriteBatch data, which can mean things might go slower if your actual usage doesn't match the hint you used. :)
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: smooth scrolling 2D game: possible?

Post by kikito »

Some time ago I did a library for handling scrolling in stuff. Its demo shows the level of smoothness achievable with LÖVE.

You can find it here:

viewtopic.php?f=5&t=12033
When I write def I mean function.
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: smooth scrolling 2D game: possible?

Post by Germanunkol »

slime wrote:
Germanunkol wrote:some of them caused it to be slower on some systems, for us, although that seems to have been a driver bug
Well, that's sort of the point of the usage hint - it lets the video driver make a more informed decision about where to put the SpriteBatch data, which can mean things might go slower if your actual usage doesn't match the hint you used. :)
Well, I know that's what it's meant for, but micha had some problems that don't seem to be what was intended by the authors of newSpriteBatch.
We used "dynamic" because we changed the batch every now and then, but that became so slow that the game became unplayable.
Bottom line is though, that scrolling a 2D level in Löve works great and very quickly, with quite little effort.
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests