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.

Newcomers DBPro Corner / scroll Background

Author
Message
Preveter
17
Years of Service
User Offline
Joined: 22nd Aug 2007
Location: Germany
Posted: 1st Jan 2008 17:31
Hi@all!

I´ve got two problems,that makes me crazy!
I want to create a 2D Sidescroll Game like Sonic,Mega Man,Super Mario etc.
Since 3 weeks i try to find a way,to scroll my background.
I founded some Tutorials and examples about scrolling here but they are always about scrolling a Text or scrolling like a spaceshooter(automatically).My problem is:
When the player has reached a certain position x on the screen the background (a textured plain) have to scroll so far like the player has gone from the position x.
I thought the command "scroll object texture" is a good method but it wasn´t.
The second problem is to mirror the player sprite,(The sprite is from a spritesheet)when he goes in the other direction.(From left to right and vice versa)
Can anybody show me a way in the right direction,please?
Here´s my Code so far:




Thanks for your help!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 1st Jan 2008 23:16
Quote: "Since 3 weeks i try to find a way,to scroll my background.
I founded some Tutorials and examples about scrolling here but they are always about scrolling a Text or scrolling like a spaceshooter(automatically)"


You don't seem to have looked that hard - or not used the forum's search facility. I typed 'Scroll' into it and found loads - for every type of scrolling you can imagine.

There's also loads of stuff like this if you look:

http://forum.thegamecreators.com/?m=forum_view&t=99491&b=10

TDK_Man

Preveter
17
Years of Service
User Offline
Joined: 22nd Aug 2007
Location: Germany
Posted: 2nd Jan 2008 01:07
TDK,
thanks,for your quick answer.I used the search function and also looked quite well but in my opinion that wasn´t the stuff I searched for.
Is it the only way to use a tilebased map?
Because i used a textured plain.
Binary Coder
17
Years of Service
User Offline
Joined: 26th Feb 2007
Location: Queensland, Australia
Posted: 2nd Jan 2008 11:53
Hmmm... Im not sure about the scrolling problem, but...

As for the changing of direction.
Create a variable called "Facingright" set this value to one (assuming that your sprite is facing right to begin with). Now, whenever the player presses the left key, set this value to zero. Set it to one when the player presses right. Get the idea? (Hopefully I explained it correctly)

Now, adapt this into both IF...ENDIFs within move_player subroutine.

Example:



That should be correct^ (Sorry if i am wrong!)

But always remember, the search bar is your best friend.

BC

Preveter
17
Years of Service
User Offline
Joined: 22nd Aug 2007
Location: Germany
Posted: 2nd Jan 2008 14:14
Binary Coder,

I had the same idea like you but the result is that the player change the direction once and then nevermore again.
It looks like he does the Moonwalk from Michael Jackson

WindowsKiller,

It´s not a repetitive image.
But when theres no way to get this to work with a plain,
I have to change to a tilebased map.
When I use this,is it possible to hide the grid from the tiles,so that i can cover it with one image?
Or how does this work?
Binary Coder
17
Years of Service
User Offline
Joined: 26th Feb 2007
Location: Queensland, Australia
Posted: 3rd Jan 2008 02:39 Edited at: 4th Jan 2008 01:50
Oh, Im sorry. It worked for me!

Edit: I worked on it some more. Try this:




This time, my sprite started off facing left. This is also so you can learn a bit while altering my code.

I hope it works!

BC

Preveter
17
Years of Service
User Offline
Joined: 22nd Aug 2007
Location: Germany
Posted: 5th Jan 2008 18:21
Thanks Binary!

It works great! Finally i can continue and know I understand this stuff better than before.
Your`re a great help for me.

Login to post a reply

Server time is: 2024-11-26 05:46:27
Your offset time is: 2024-11-26 05:46:27