Jump to content


Photo
* * * * * 4 votes

Responsive Parallax Scrolling Example


  • Please log in to reply
46 replies to this topic

#1 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 15 February 2012 - 08:50 PM

  • Title: Responsive Parallax Scrolling Example
  • Description: Example on how to make an almost flawless parallax scrolling universe.
  • GM Version: :GM8:
  • Registered: Yes
  • File Type: .gmk
  • File Size: 674.6 KB
  • File Link: .gmk only (YoYo games link)
  • Required Extensions: None
  • Required DLLs: None
Summary
First of all I would say thanks to Nocturne for his old parallax example, I've learned a lot from it. Well, Parallax scrolling is a special scrolling technique in computer graphics, wherein background images move by the camera slower than foreground images, creating an illusion of depth in a 2D video game and adding to the immersion. That was what Wikipedia said. In this example I'll show you how to make responsive parallax scrolling world (with moveable view), as opposed to commonly less responsive backgrounds method in which when the view moves the background will follow the view but with slight delay.

The key to achieve this "responsive parallax" is to NEVER EVER use the built-in backgrounds in the room editor (you know, the background[x]). In this simple example I've included two important script to replace those built-in background. They're;
draw_background_tiled_horizontal(back,x,y)
draw_background_tiled_vertical(back,x,y)

You can freely use them for your games if you want, no credit required.

In this example I've also drawn a foreground image that appears in front of the player's object thus they're scrolling faster than any images behind it. And finally... I've also added one building image example, this means you can also draw parallax scrolling images individually rather than tiling it.

The Awesome Parallax Universe!
Posted Image

NOTE: JUST DELETE THE obj_hud IF YOU USE GAME MAKER LITE

:medieval: :medieval: I hope you find it useful, and Happy Game Making !! :medieval: :medieval:
  • 9
Thumb_Jilbab.png96un.pngsssignature.png

#2 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 17074 posts
  • Version:GM:Studio

Posted 16 February 2012 - 08:24 PM

Very smooth and pretty
  • 1

#3 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 16 February 2012 - 11:52 PM

Very smooth and pretty


Thank you very much icuurd12b42! It's really an honor for me to get a Staff Choice :D :D
  • 0
Thumb_Jilbab.png96un.pngsssignature.png

#4 greyzebra

greyzebra

    GMC Member

  • GMC Member
  • 119 posts
  • Version:GM:Studio

Posted 27 February 2012 - 03:59 AM

Would be surprised if you don't get Staff Choice! This is very good. Thanks for sharing this.
  • 0

#5 Benxamix2

Benxamix2

    GMC Member

  • New Member
  • 278 posts
  • Version:GM8

Posted 28 February 2012 - 01:37 PM

Excellent example. I may use it for some projects. Thank you very much ;)
  • 0

#6 thatshelby

thatshelby

    GMC Member

  • GMC Member
  • 3823 posts
  • Version:GM8

Posted 12 March 2012 - 10:28 PM

It looks nice.. but is there any rhyme or reason to why you chose those numbers? It's really confusing me... Some detailed, and i mean detailed commenting would be in order.
  • 0

#7 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 21 March 2012 - 10:39 AM

Thanks all for your support!

It looks nice.. but is there any rhyme or reason to why you chose those numbers? It's really confusing me... Some detailed, and i mean detailed commenting would be in order.


/***************************************************
  This piece of code draw the background with
  different illusion of depth, by using position
  relative to the current view's position.
  The larger the division number the faster
  the background will move.
 ***************************************************/
draw_background(background0,view_xview[view_current],view_yview[view_current]) // Draw furthest static background
draw_background_tiled_horizontal(background5,view_xview[view_current]/1.1+100,view_yview[view_current]/1.1+300) // Draw background that move slowest
draw_background(background6,view_xview[view_current]/1.1+300,view_yview[view_current]/1.1+232)// Draw single big building
draw_background_tiled_horizontal(background1,view_xview[view_current]/1.25+100,view_yview[view_current]/1.25+340) // Draw background that move slowest
draw_background_tiled_horizontal(background2,view_xview[view_current]/1.5,view_yview[view_current]/1.5+386) // Draw background that move slower
draw_background_tiled_horizontal(background4,0,720) // Draw the ground
If you want to draw something that looks further just divide view_xview[view_current] and or view_yview[view_current]
with numbers according to your desired position.
view_xview[view_current] means it's not moving at all, thus it will always on view_current's x.
view_xview[view_current]/2 means it's will move slightly.
the "+" just meant to place backgrounds position to a correct position.
and so on... Sorry I'm not good at explaining things :P Try to edit those values and I'm sure you'll understand.

You should add a lock to prevent the layers from separating too far if the rooms really big. Like prevent them from going further than 50 pixels vertically or something.


That would be easy I think just add some code like this:
draw_background_tiled_horizontal(background1,view_xview[view_current]/1.25+100,median(MINIMUM Y,view_yview[view_current]/1.25+340),MAXIMUM Y))
I think that should work.
  • 0
Thumb_Jilbab.png96un.pngsssignature.png

#8 windtalks

windtalks

    GMC Member

  • New Member
  • 2 posts
  • Version:GM8

Posted 23 March 2012 - 02:17 PM

excellent!thank you !
  • 0

#9 Harmonex

Harmonex

    GMC Member

  • GMC Member
  • 56 posts
  • Version:GM:HTML5

Posted 24 March 2012 - 02:20 AM

Wow. I had been trying to get parallax to work without the lag, but I had thought it was a bug in my code. Thanks for this, it has really helped me out. Is there any way to use it to tile horizontally and vertically? I tried the script as-is and realized I couldn't combine them.

P.S. Is it intentional irony that you called the file "Perferct"?

[EDIT]: I modified your code with a little trial and error and this seems to work.

/***************************************************
  Usage :   draw_background_tiled_both(back,x,y)
  Arguments :   argument0   ==  background
                argument1   ==  x
                argument2   ==  y
  Event :   draw event
 ***************************************************/
 
 var back,height,width,xx,yy,up,down,left,right,i,a;
 
 back=argument0;
 height=background_get_height(back);
 width=background_get_width(back);
 xx=argument1;
 yy=argument2;
 up=-1;
 left=-1;
 down=view_yview[view_current]/height+view_hview[view_current]/height+1;
 right=view_xview[view_current]/width+view_wview[view_current]/width+1;
 if (view_enabled)
 {
    for (i=up; i<down; i+=1)
    {
        for (a=left; a<right; a+=1)
        {
            draw_background(back,xx mod width+width*a,yy mod height+height*i);
        };
    };
 }
 else
 {
    for (i=-1; i<room_height/height+1; i+=1)
    {
        for (a=-1; a<room_width/width+1; a+=1)
        {
            draw_background(back,xx mod width+width*a,yy mod height+height*i);
        };
    };
 };

Edited by Harmonex, 24 March 2012 - 02:55 AM.

  • 0

#10 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 24 March 2012 - 07:24 PM

Wow. I had been trying to get parallax to work without the lag, but I had thought it was a bug in my code. Thanks for this, it has really helped me out. Is there any way to use it to tile horizontally and vertically? I tried the script as-is and realized I couldn't combine them.

P.S. Is it intentional irony that you called the file "Perferct"?

[EDIT]: I modified your code with a little trial and error and this seems to work.

/***************************************************
  Usage :   draw_background_tiled_both(back,x,y)
  Arguments :   argument0   ==  background
                argument1   ==  x
                argument2   ==  y
  Event :   draw event
 ***************************************************/
 
 var back,height,width,xx,yy,up,down,left,right,i,a;
 
 back=argument0;
 height=background_get_height(back);
 width=background_get_width(back);
 xx=argument1;
 yy=argument2;
 up=-1;
 left=-1;
 down=view_yview[view_current]/height+view_hview[view_current]/height+1;
 right=view_xview[view_current]/width+view_wview[view_current]/width+1;
 if (view_enabled)
 {
    for (i=up; i<down; i+=1)
    {
        for (a=left; a<right; a+=1)
        {
            draw_background(back,xx mod width+width*a,yy mod height+height*i);
        };
    };
 }
 else
 {
    for (i=-1; i<room_height/height+1; i+=1)
    {
        for (a=-1; a<room_width/width+1; a+=1)
        {
            draw_background(back,xx mod width+width*a,yy mod height+height*i);
        };
    };
 };


I'm sure game maker already have that built in function, it's called draw_background_tiled(back,x,y) (that's why I'm trying to make the horizontal, and vertical, only counterpart). So you seriously don't need to make that code above.
I named this perfect, because it's literally perfect, as far as I'm tested :P , so please tell me what bug exactly do you find? :/

Edited by Fihrilkamal, 24 March 2012 - 07:30 PM.

  • 0
Thumb_Jilbab.png96un.pngsssignature.png

#11 Harmonex

Harmonex

    GMC Member

  • GMC Member
  • 56 posts
  • Version:GM:HTML5

Posted 25 March 2012 - 03:04 PM

Ah, my apologies. I'm still a little new to GML, so I'm not aware of every single function just yet.

Nothing to see here, move along. :P

P.S. I assumed "Perferct" to be an intentional typo.

[EDIT]: I think I found a use for the code I provided that I couldn't use the built-in function for. If I wanted to tile a bunch of similar backgrounds randomly (think stars twinkling), I could add a second or third background variable into the script, and then possibly use alarms to change the backgrounds every few seconds. Granted, I could just change which background I'm tiling in the draw_background_tiled() function, but then I would have the same change spread across the whole screen (which would become noticeable after a while). I think I'll hold on to the script to test out my theory to see if it's worth using.

Edited by Harmonex, 25 March 2012 - 04:34 PM.

  • 0

#12 ncadc2004

ncadc2004

    GMC Member

  • New Member
  • 1 posts

Posted 25 March 2012 - 08:46 PM

Greetings folks - long-time lurker, even longer-time GM user (well, since 5 anyway), first-time poster. So apologies if I'm making any newbie-ish errors in this reply.

Felt the need to finally crawl out of the shadows in response to this topic, because...

In this example I'll show you how to make responsive parallax scrolling world (with moveable view), as opposed to commonly less responsive backgrounds method in which when the view moves the background will follow the view but with slight delay.


...YES. ::lmao::

I've had a platformer on the go for a long time and this specific problem has been irritating me for YEARS. I've been using a step event code in my player object - the horizontal parallax scrolling was never generally a problem, but when my character jumped and landed, the vertical parallax effect had a slight delay that gave the whole thing a peculiar 'bouncy' look. I've never been able to fix it... until trying this.

Kudos to you, sir - and any others that have had a hand in the development of this code - for answering a problem that I have been scouring these forums (and their predecessors) for a long time to find a solution to.

:thumbsup:

(Pesky draw functions. I've never really understood them well enough...!)
  • 0

#13 Ad1

Ad1

    GMC Member

  • GMC Member
  • 208 posts
  • Version:Unknown

Posted 02 April 2012 - 04:08 AM

wow thanks guy this is exactly what im looking for it runs so smooth nice example and thanks again
  • 0

#14 The Rock Abdo

The Rock Abdo

    GMC Member

  • GMC Member
  • 75 posts
  • Version:GM:Studio

Posted 02 April 2012 - 10:22 AM

excellent thanks man :thumbsup:
  • 0

:banana:


#15 Swifty

Swifty

    Shadow

  • GMC Member
  • 516 posts
  • Version:GM:Studio

Posted 03 April 2012 - 03:52 PM

Just like to say I've been looking around/playing with my own code to try and get some smooth parallax and then I found this, great work mate. +1

Swifty
  • 1

Don't be Afraid to Fail.


#16 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 07 April 2012 - 11:50 AM

Thanks for your nice response guys, I'm glad that you think this script is helpful, I'm used to get stuck with the "slight delay" when making parallax backgrounds for a long time too, then I realize that those built-in background[0-8] can't move at the same time with the views, unless I set them to "foreground". That problem is the same when we make HUDs with separate objects and then set their position relative to a view instead of drawing them in draw event.
  • 0
Thumb_Jilbab.png96un.pngsssignature.png

#17 overflo

overflo

    GMC Member

  • New Member
  • 61 posts
  • Version:GM8

Posted 08 April 2012 - 03:27 AM

I'm new to GameMaker and GML and I have been trying to adapt this example to a forest type scene. When I swap the backgrounds for trees they only appear really short, I need them to be quite tall. I have tried changing value in the code and different size images but, if anything, they just seem smaller. Can anyone tell me how I can do it? I would appreciate any help with it.

Cheers



Cancel the above - I worked it out

Edited by overflo, 08 April 2012 - 04:57 AM.

  • 0

#18 metallica3000

metallica3000

    GMC Member

  • GMC Member
  • 38 posts
  • Version:GM8

Posted 02 June 2012 - 01:58 PM

The example is reaaaaaally good! I love it! But im kinda new to gamemaker and don't understand how to implement it in my game... Nothing shows up when I remove the backgrounds from room editor
  • 0

#19 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 04 June 2012 - 03:55 PM

The example is reaaaaaally good! I love it! But im kinda new to gamemaker and don't understand how to implement it in my game... Nothing shows up when I remove the backgrounds from room editor

Thank you! You have to draw your backgrounds with an object that have very large amount of depth, something like 10000000. So, basically we are replacing GM's default background system with our own.
  • 0
Thumb_Jilbab.png96un.pngsssignature.png

#20 creators124

creators124

    awesomeliciousmember

  • GMC Member
  • 866 posts
  • Version:GM8

Posted 04 June 2012 - 05:57 PM

PERFECT! Posted Image
I love it!
the hud could be more beautiful. Posted Image
you have a gift at drawing backgrounds, thanks for sharing it! Posted Image
  • 1
Posted ImageRate this topic:0 | 1 | 2 | 3 | 4 | 5

#21 CharlieMcShane

CharlieMcShane

    GMC Member

  • GMC Member
  • 259 posts
  • Version:GM:Studio

Posted 02 July 2012 - 12:53 PM

EXE:
Posted Image
Here it works perfectly fine.

HTML5:
Posted Image
Here, it is not. And the images shrink in size too!


Any ideas to fix the HTML5 version?

Thanks in advance!
Charlie


EDIT: SOLVED, read below

Edited by CharlieMcShane, 03 July 2012 - 01:02 PM.

  • 0

#22 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 03 July 2012 - 11:17 AM

Thanks creators124!
I'm not sure since I never tried gm html5 before. It's really odd, the game and the scripts are the same isn't it?
  • 0
Thumb_Jilbab.png96un.pngsssignature.png

#23 CharlieMcShane

CharlieMcShane

    GMC Member

  • GMC Member
  • 259 posts
  • Version:GM:Studio

Posted 03 July 2012 - 01:01 PM

Thanks creators124!
I'm not sure since I never tried gm html5 before. It's really odd, the game and the scripts are the same isn't it?


Hey Fihrilkamal!
I must of re-read through your code like, 7 times; and I still didn't draw up an error, so your code is perfectly fine. I hadn't edited them either really!
What I have realised though, is that HTML5 can't use this feature with backgrounds that tile further or higher than the view size itself, for my case; backgrounds couldn't be larger than 700x550 if I wanted to tile them with your code. You'll see in the HTML5 image, that the HTML5 export shrinks the background to size to fit in the screen, causing the image to float upwards on the y axis.

In a result, I had to edit all my backgrounds to fit this dimension; it just appears that HTML5 hates any tiles that exceed the [view_current] field.
For proof of concept that your code works in HTML5 (I know it is a dirty fix, but I seriously can't find another solution)
http://www.learningg...er.com/yogscast

Probably best to let people know in your original post!
Charlie

PS: Let me know if you want me to remove the link above, posting purely for proof of concept, not advertising
  • 1

#24 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 03 July 2012 - 01:54 PM

Really glad to hear that you solved it, please don't remove that link, it's good to see this parralax method implemented in a game :D
  • 0
Thumb_Jilbab.png96un.pngsssignature.png

#25 CharlieMcShane

CharlieMcShane

    GMC Member

  • GMC Member
  • 259 posts
  • Version:GM:Studio

Posted 03 July 2012 - 04:20 PM

Really glad to hear that you solved it, please don't remove that link, it's good to see this parralax method implemented in a game :D


Thanks! Far more optimised than the built in background options on the GM Editor!

Charlie
  • 0

#26 celebraces

celebraces

    GMC Member

  • GMC Member
  • 956 posts

Posted 19 January 2013 - 04:28 AM

I've been playing with 3D vision today and thought it would look great with layered backgrounds. I stumbled upon your example and modified it a little bit to add a 3D capability.

If you have a 3D monitor that supports side by side, check this out:

http://celebraces.co...arallax_3D.gm81

Press enter to switch eyes and space to turn off 3D.
  • 1

#27 Grand_Alchemist

Grand_Alchemist

    GMC Member

  • GMC Member
  • 14 posts
  • Version:GM:Studio

Posted 18 February 2013 - 11:28 PM

This is absolutely awesome!

Although one small issue..


Having a problem importing this into GM:Studio. There are some lines appearing across the border of the background textures.


Has anyone else found this to be true and/or know how to fix this small issue?


Thanks!





Edit: Semi-solved - Turning off Interpolation fixed (at the cost of some graphical quality of course)


Edited by Grand_Alchemist, 23 February 2013 - 02:34 AM.

  • 0

#28 Alphanumerai

Alphanumerai

    GMC Member

  • GMC Member
  • 16 posts
  • Version:GM8.1

Posted 16 March 2013 - 09:16 PM

Ooh delicious! Brilliant example of parallax scrolling and some rather nice demonstration graphics, will be using this for my projects :P
I'm assuming you can limit it to only vertical or only horizontal parallaxing if you were so inclined.
  • 0

#29 Lotias

Lotias

    The Tree

  • GMC Member
  • 1285 posts
  • Version:GM:Studio

Posted 14 April 2013 - 11:05 PM

Works great in Windows and all, but I'm having major problems with it in HTML5 - and I'm definitely sure they're not the same problems as the guy making Yogscast up there.

http://gmc.yoyogames...howtopic=577761


  • 0

LogoStandaloneUncropped.png

in development - http://skygategame.tumblr.com

 

I'm also available for hire - I do sound effects and draw maps


#30 Roflstompz

Roflstompz

    GMC Member

  • GMC Member
  • 114 posts
  • Version:GM:Studio

Posted 10 May 2013 - 10:04 AM

I've tried using this in my platforming game, looks brilliant! Although my fps stays at 50, the game seems a little jumpy. Anyone know why that might be?

EDIT: Nvm. I'm retarded, this is great.


Edited by Roflstompz, 09 June 2013 - 09:59 AM.

  • 0

#31 Toxigames

Toxigames

    GMC Member

  • GMC Member
  • 238 posts
  • Version:GM:Studio

Posted 23 June 2013 - 08:28 PM

This seems like something I could really learn from and use in my current project. I am in the process of making a sidescrolling platformer and have created some very large background images, about 2000 px wide and, like in this example tutorial, the large background images present some jagged edges, which I believe appears because the image used is to large to fit in the texture page?

 

I tested this on both on my desktop gamer computer and on my Samsung Galaxy S2 where the ice hills/mountain backgrounds had some ugly/jagged black spots at the it's edges. More noticeably on my SGS2 than on my computer.

 

Is there an obvious solution to this problem? Anyway to cut up the image in smaller bits and still use this tutorial example?

 

This following screenshot is from my SGS2, http://img32.imagesh...g32/992/kcc.png, and show the glitched edges. It's most noticeable on the foremost ice-hill backgrounds top edges that goes diagonally.


Edited by Toxigames, 23 June 2013 - 08:46 PM.

  • 0

#32 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 17074 posts
  • Version:GM:Studio

Posted 26 June 2013 - 05:06 AM



This seems like something I could really learn from and use in my current project. I am in the process of making a sidescrolling platformer and have created some very large background images, about 2000 px wide and, like in this example tutorial, the large background images present some jagged edges, which I believe appears because the image used is to large to fit in the texture page?

 

I tested this on both on my desktop gamer computer and on my Samsung Galaxy S2 where the ice hills/mountain backgrounds had some ugly/jagged black spots at the it's edges. More noticeably on my SGS2 than on my computer.

 

Is there an obvious solution to this problem? Anyway to cut up the image in smaller bits and still use this tutorial example?

 

This following screenshot is from my SGS2, http://img32.imagesh...g32/992/kcc.png, and show the glitched edges. It's most noticeable on the foremost ice-hill backgrounds top edges that goes diagonally.

 

the artefact may simply be from the device scaling the image. but it may be Studio scaling the image to fit on the texture page itself

 

 

split your image into an multiple image, use the sprite instead of the background, frame 0 being leftmost and the last being the rightmost image. chop them into chunks smaller or equal than your target texture page. but trying to stay in the 2^n motto

 

Use 512 or 1024 width which will fit evenly on the texture page for all devices,

 

Meaning you 2000 pxels image there. that is a bad choice. make is 2048 and split it in 2 1024 wide images (the smallest texture size). Assuming the height is something . 512. you can have 4 bands of images on the same texture.

 

 

NOT TESTED

/***************************************************
  Usage :   draw_sprite_tiled_horizontal(back,x,y)
  Arguments :   argument0   ==  sprite
                argument1   ==  x
                argument2   ==  y
  Event :   draw event
 ***************************************************/
 
 var back,width,xx,yy,left,right,i.frm;
frm = 0;
 spr=argument0;
 width=sprite_get_width(back);
 xx=argument1;
 yy=argument2;
 left=-1;
 right=view_xview[view_current]/width+view_wview[view_current]/width+1;
 if (view_enabled)
 {
    for (i=left; i<right; i+=1)
    {
        draw_sprite(spr,frm,xx mod width+width*i,yy);
frm+=1;
    };
 }
 else
 {
    for (i=-1; i<room_width/width+1; i+=1)
    {
        draw_sprite(spr,frm,xx mod width+width*i,yy);
frm+=1;
    };
 };

  • 3

#33 Toxigames

Toxigames

    GMC Member

  • GMC Member
  • 238 posts
  • Version:GM:Studio

Posted 26 June 2013 - 07:48 AM

Hi icurrd many thanks for your thourough explanation. I'll now definately try and and accomplish your suggestion combining it with OP's example :-)


  • 0

#34 pacerharold

pacerharold

    GMC Member

  • New Member
  • 3 posts
  • Version:Unknown

Posted 24 July 2013 - 05:12 AM

Hey, really cool example! Just a head's up for anyone on 'GM:S free' wanting to try this. Make sure and comment out lines 9 and 10 of the code in the draw event in obj_backgrounds. Since Studio only allows 5 background elements and this example has 7 you'll get a fatal error when you compile. Once you do that though the parallax is smooth butter. Can't wait to play around with the effect!


Edited by pacerharold, 24 July 2013 - 05:13 AM.

  • 0

#35 MKSchmidt

MKSchmidt

    GMC Member

  • New Member
  • 9 posts
  • Version:GM:Studio

Posted 01 August 2013 - 08:35 PM

This looks fantastic.  Just so you know, I imported it into Gamemaker Studio, and it works fine.  I will be attempting to integrate your script into my game, I'll let you know how it works.


  • 0

#36 bkwrm

bkwrm

    GMC Member

  • GMC Member
  • 21 posts
  • Version:GM:Studio

Posted 13 May 2014 - 04:03 AM

Just wanted to say this still works amazing.  Perfectly smooth background scrolling (or if you just want a still background image to follow you around), no lag whatsoever.  Just use the draw_background_tiled_horizontal script, obj_backgrounds to control it, and remember not to use the backgrounds in the room editor.

 

I learned a lot from his script.


  • 0

#37 Coyan

Coyan

    GMC Member

  • New Member
  • 1 posts
  • Version:Unknown

Posted 05 June 2014 - 01:32 PM

This is absolutely awesome!

Although one small issue..


Having a problem importing this into GM:Studio. There are some lines appearing across the border of the background textures.


Has anyone else found this to be true and/or know how to fix this small issue?


Thanks!





Edit: Semi-solved - Turning off Interpolation fixed (at the cost of some graphical quality of course)

 

I was also getting lines across the screen at the border of the backgrounds. Turning off Tile:vertical in the background image options solved it for me.

 

Great tutorial !


  • 0

#38 ScottGraves

ScottGraves

    GMC Member

  • GMC Member
  • 417 posts
  • Version:GM:Studio

Posted 16 July 2014 - 05:32 PM

Just imported this into my studio (platformer) project and it works great, however the foreground image doesnt appear to be infront of all objects.

obj_foreground is still set at -10000 and none of my other objects are anywhere near that

 

Any ideas?


Edited by ScottGraves, 16 July 2014 - 08:06 PM.

  • 0

#39 Tronco

Tronco

    GMC Member

  • New Member
  • 5 posts
  • Version:GM:Studio

Posted 01 August 2014 - 07:01 AM

This method is working great, best parallax method ever, but i've got one strange issue:

 

I'm using it in a side-scrolling shooter with a moving view.

 

The parallaxed background images are a little shakey, like they are going back and forth.

 

Is this normal or is there a way to fix it? It's not a big deal but i'm wondering if there is a way to scroll them more smoothly.


  • 0

#40 Toxigames

Toxigames

    GMC Member

  • GMC Member
  • 238 posts
  • Version:GM:Studio

Posted 01 August 2014 - 09:57 PM

This method is working great, best parallax method ever, but i've got one strange issue:

 

I'm using it in a side-scrolling shooter with a moving view.

 

The parallaxed background images are a little shakey, like they are going back and forth.

 

Is this normal or is there a way to fix it? It's not a big deal but i'm wondering if there is a way to scroll them more smoothly.

 

Hi, what device(s) do you experience this with this parallax engine? I am seeing some 'shakiness', or parallaxed backgrounds going kinda forth and back, but only on my Samsung Galaxy S2, allthough fps is above 100 for my game. Though it's not too bad and probably not something the average user would notice. On my old, slow and damaged iPhone 4 (slower than my SGS2), where I get 50-60 fps in my game, I don't see any shakiness. It's a bit weird. On my Windows 7 64bit high end computer I also don't see any shakiness.


Edited by Toxigames, 01 August 2014 - 11:12 PM.

  • 0

#41 Toxigames

Toxigames

    GMC Member

  • GMC Member
  • 238 posts
  • Version:GM:Studio

Posted 01 August 2014 - 10:16 PM

Just imported this into my studio (platformer) project and it works great, however the foreground image doesnt appear to be infront of all objects.

obj_foreground is still set at -10000 and none of my other objects are anywhere near that

 

Any ideas?

 

Hard to say, perhaps the obj_foreground object is getting it's depth variable set to something else during runtime? Try creating a new object, lets call it obj_draw_text and set it's depth to -999999999 and then placing the following code in the bottom of an execute code in the Draw event of obj_draw_text (I am assuming you are using views):

draw_text(view_xview[0]+view_wview*0.1, view_yview[0]+view_hview*0.5, "obj_foreground.depth: " + string(obj_foreground.depth));

Remember to put one instance of obj_draw_text in your room. This way you'll be able to check what value the depth of obj_foreground will have at all times during runtime.


Edited by Toxigames, 01 August 2014 - 11:02 PM.

  • 1

#42 ScottGraves

ScottGraves

    GMC Member

  • GMC Member
  • 417 posts
  • Version:GM:Studio

Posted 02 August 2014 - 05:55 PM

Sorry, actually figured it out awhile back, had to adjust the Y variable for most of the backgrounds to get everything into view correctly.


  • 0

#43 deaddeni

deaddeni

    GMC Member

  • New Member
  • 10 posts
  • Version:GM:Studio

Posted 22 September 2014 - 06:16 PM

Hello, could You please tell me if I could use this script to achive vertical parallax scrolling but just to background be "moving", I don't need view to follow player or anything cause my view is room's dimensions and it doesn't change.. I tried playing with Your code but I'm to new to GMS to figure that out obviously.. :( I have room 600 x 1000 and I want 3 "layers" of background stars moving.

 

P.S. I'm working on scrolling space shooter and when I use built in background it lags.. -.-

 

EDIT: I solved my problem with variable in Step event of background object so ignore my question :)


Edited by deaddeni, 23 September 2014 - 12:18 PM.

  • 0

#44 Kanashi

Kanashi

    GMC Member

  • New Member
  • 3 posts
  • Version:GM:Studio

Posted 27 January 2015 - 06:26 PM

Hi great scripts!

 

So far the horizontal parallax is working fine but for some reason the vertical is backwards. If I move the player object to towards the top of the screen is scrolls down but if I move to the bottom of the screen it scrolls up. I'm not the best programmer so I'm not really seeing where my Y value is reversed. I'm using Game Maker Studio and imported the scripts from GM8.1(the version you provide).

 

I would love to be able to understand it more so any help is appreciated. 


  • 0

#45 madbad79

madbad79

    GMC Member

  • New Member
  • 4 posts
  • Version:Unknown

Posted 16 February 2015 - 10:14 AM

 How can i put an object (animated sprite) in the layers?

like Rayman Legends .


  • 0

#46 Toxigames

Toxigames

    GMC Member

  • GMC Member
  • 238 posts
  • Version:GM:Studio

Posted 17 February 2015 - 12:20 PM

 How can i put an object (animated sprite) in the layers?

like Rayman Legends .

 

Not trying to be Captain Obvious here, but how about using an animated sprite instead of a non animated sprite? (thus not using an object).

 

EDIT: Okay, I wasnt being very clear there! What I meant was that you could use an animated sprite strip with the draw_sprite_ext function and shifting the image_index manually. Something like this (not tested):

draw_sprite_ext( sprite, subimg, x, y, xscale, yscale, rot, colour, alpha );

ii = 10; // animation speed. higher is slower.

i++;

if(i > ii){
   i = 0;
   n++; // n being the image_index you want to display
   if(n > numOfSubImgs){ 
      n = 0; 
   }
}

draw_sprite_ext(yourAnimatedSprite, n, x, y, 1, 1, 0, c_white, 1);

Edited by Toxigames, 18 February 2015 - 07:22 AM.

  • 0

#47 creativeband124

creativeband124

    GMC Member

  • GMC Member
  • 21 posts
  • Version:GM:Studio

Posted 05 April 2015 - 06:18 PM

Amazing !!!!


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users