Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411656 Posts in 69395 Topics- by 58451 Members - Latest Member: Monkey Nuts

May 15, 2024, 06:23:19 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsParallax in Polycode
Pages: [1]
Print
Author Topic: Parallax in Polycode  (Read 2388 times)
k0tn
Level 0
**


Tucker Wagner


View Profile
« on: December 14, 2011, 07:56:26 PM »

Anyone know if it would be possible to have a parallax background using Polycode? Thank you! Cool
Logged
mcc
Level 10
*****


glitch


View Profile WWW
« Reply #1 on: December 14, 2011, 08:32:23 PM »

There are several ways you could do this. Can you give some information about how you are drawing, currently?

If I wanted to do this, I would probably make all the foreground a child of entity A, the parallax backgrounds children of entities B and C, and then move entities A, B and C at different rates when the "camera" moves. Does that make sense?

Also I think maybe this would be better served either in Technical, or maybe even on the Polycode forum.
Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #2 on: December 14, 2011, 09:24:10 PM »

Personally I would write a small parallax manager class. You pass it images and have it update the positions of the images based on a given z-value when the camera moves.
Logged

k0tn
Level 0
**


Tucker Wagner


View Profile
« Reply #3 on: December 15, 2011, 02:12:32 PM »

Quote
Also I think maybe this would be better served either in Technical, or maybe even on the Polycode forum.

Sorry I thought I did put this in there... but apparently not Tongue
Logged
Rob Lach
Level 10
*****



View Profile WWW
« Reply #4 on: December 20, 2011, 08:14:51 PM »

Personally I would write a small parallax manager class. You pass it images and have it update the positions of the images based on a given z-value when the camera moves.

Wouldn't a manager be overkill? Just tack on a "parralax ratio" and multiply it against your current camera coords.
Logged

BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #5 on: December 21, 2011, 01:12:08 AM »

Overkill? The idea I have for it in my head is pretty simple. I think it'd be simpler and cleaner than writing an entire parallax image class, but that's just me. And aside from those two relatively loose methods I don't really know how you'd implement it.(well, of course you could hardcode them into your game loop or something, but that'd be the same concept just without the OOP abstraction)
Logged

zengeek
Level 0
*


View Profile
« Reply #6 on: January 09, 2012, 05:59:09 AM »

Best way that i know of is using stack based transformations of camera. Pseudo-code:
Code:
for each parallaxLayer in layers
                using camera with translation(-camPos.X * parallax_layer.scrollspeed, -camPos.Y  * parallax_layer.scrollspeed)) {
                    for each sprite in parallax_layer.Sprites) {
                        renderer draw_sprite([somewhere], sprite);
                    }
                }
            }

Where scrollspeed is a value between 0 and 1. And using camera is a method that pushes the current transform prepends a new transform and pops when leaving scope. 
Yeah that's in engine level.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic