Scrolling horizontal background

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
benbooth493
Prole
Posts: 5
Joined: Sun Aug 21, 2016 11:16 am

Scrolling horizontal background

Post by benbooth493 »

Hello all!

I'm new to Love2D and I'm already making great progress, but I am stuck trying to implement a horizontal scrolling background.

What is the best way to do this?

Thanks in advance!

Ben
User avatar
CanadianGamer
Party member
Posts: 132
Joined: Tue Jun 30, 2015 1:23 pm
Location: Canada
Contact:

Re: Scrolling horizontal background

Post by CanadianGamer »

Welcome to the forums.
All you need to do is change the x coordinate of where the background is being drawn.
For example if you are currently drawing the background at 0, 0 try drawing it at progressively
smaller or larger x coordinates to make it 'move'.
My serious itch.io page:
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
Skeletonxf
Citizen
Posts: 87
Joined: Tue Dec 30, 2014 6:07 pm

Re: Scrolling horizontal background

Post by Skeletonxf »

You've got two options. Either you have a fixed camera and move everything each frame to move around the viewpoint or you have fixed things on the screen and move the screen/camera around to move the view.

While the former method may be a little easier than if you opt for moving the screen instead then when you change the x and y coords of something you really know it moved from its prior position relative to the viewpoint.

There's libraries for the moving camera such as hump.camera or you can use the Love2d features with love.graphics.translate and do it yourself.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 1 guest