Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Screen Scrolling in X and Y on AGK and performance

Author
Message
mathacka
11
Years of Service
User Offline
Joined: 19th Apr 2013
Location:
Posted: 19th Apr 2013 21:33
Hi, I understand the idea of screen scrolling, but I'm getting a little confused on the best way to implement it.

I have a starry background that I'm using to create the feel of movement when the player uses a virtual joystick on the screen.

Two things are confusing me, One, It seems like a lot of images on the virtual screen if you're moving left and up to add 3 copy's of a seamless starry background to your screen's virtual screen?

Two, what is best for performance, to delete and reload the sprites, use images instead of sprites, or just copy and hide sprites as the starry background moves?

Could you provide some pseudo-code so I can better make sense of this?
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 20th Apr 2013 09:06
There are a number of ways to approach this and it really depends on what the rest of your game is doing.

In most cases for a starfield, I would tend NOT to scroll the background in the traditional sense, but instead use a background image of a star field and scroll it's texture. That way you only use one sprite and it never needs to be bigger than the screen.

You can use multiple sprites if you want a parallax effect).

I did some samples a while back

http://forum.thegamecreators.com/?m=forum_view&t=194972&b=41

(Though this example is more complex - multiple backgrounds and parallaxing , the actual background is only a few lines and it does use V-Joystick control).
mathacka
11
Years of Service
User Offline
Joined: 19th Apr 2013
Location:
Posted: 21st Apr 2013 04:53 Edited at: 21st Apr 2013 08:05
I was able to do what you said with this code:



The image file is attached.

Thanks for your help!

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-02 06:05:40
Your offset time is: 2024-05-02 06:05:40