Horizontal Parallax Scrolling Starfield

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
drvoke
Newbie
Posts: 14
Joined: Mon Apr 15, 2013 2:13 am
Contact:

Horizontal Parallax Scrolling Starfield

#1 Post by drvoke » Fri Mar 20, 2015 1:49 am

Nothing too crazy. I haven't put any exception handling into the code, so be gentle or it will behave in unexpected ways.

The grint() function takes three positionals: starting values in a list, ending values in a list, and the number of items to return. It does a linear interpolation between the starting values and ending values and returns them in a list. I'm using it to get a gradient of RGBA values in a list.

The displayable itself takes two positionals, the width and height to cover, and a keyword, how many parallax layers to render. Make sure you pass these arguments when you add the displayable to your screen.

I'm providing this code as is, with no promise or guarantee of support. You can use it or modify it in any way for any reason. If you improve it, you wouldn't go far wrong if you posted your improvements back to this thread. The code itself is simple and thoroughly commented, so there shouldn't be anything mysterious going on if you want to improve it or modify it to suit your needs.

It could use some improvement, as changing the number of parallax layers has (predictable) effects on the speed of the lines since speed is a function of the layer number. There's plenty of other stuff as well. Have at it!

I've only tested this with v6.18.. other versions of RenPy may or may not be compatible for whatever reason.

Image
Attachments
parallax_starfield.rpy
(5.7 KiB) Downloaded 296 times

User avatar
stwkun
Regular
Posts: 77
Joined: Wed Jan 02, 2013 7:57 pm
Organization: Stw Projects
Contact:

Re: Horizontal Parallax Scrolling Starfield

#2 Post by stwkun » Thu Apr 16, 2015 1:53 pm

Wow ,It's great . Thank you :D

Post Reply

Who is online

Users browsing this forum: No registered users