Menu background fake scrolling - one active object
Submitted:|| 6th May, 2009
There are quite alot of ways of doing this i guess, but i don't like clutter on my playfeild, when im editing things and stuff, also... actualy no its just anoying!!!11
This is basicaly a way to make a menu style background (like diamonds scrolling along) but without having to either actualy scroll, or put loads of actives (the diamonds or whatever) on your playfeild that get in the way!
There is a link at the end which has a link to the one i done for ya.
FIRST THINGS FIRST
Ok first open a new application.
It only needs to be small make it 220*220 (for the sake of this tutorial)
and make the background color a light green (thats what i used)
now go into the play area & make a 32*32 active object.
Fill it with a different shade of green than you used for the playfeild background color (i suggest haveing them both quite light shades)
Now cut out an even diamond shape with the line tool and fill it with transparent. call it "background"
Ok now just before we go to the event editor make another active object, it doesnt matter what it looks like, because its only going to hold 2 values.
If you like call alt val A "x" and alt val B "y". call this "value holder"
SECOND THINGS SECOND
now head off to the event editor, this is where it gets interesting.
might aswell make a group called background or somthing so it doesnt clutter up the actual menu events!
Right.. now what we are gonna do is build the background from scratch with a loop. so what its gonna do is go from top left to top right, then go to the next row and repeat until it gets to the bottem, then when its created it we can start our fake scrolling thing.
Now first off we are just gona start a loop and trigger the proccess:
+Run this event once
- start loop "bg" 80 times
- set alterable value A of "value holder" to 1
Right the loop goes 80 times because thats all we are gonna need for this size screen.. actualy you need less, but i gave myself some room to play with and it doesnt realy matter.
And you'll find out why i set the Alterable value A to 1 in a second.
+On loop "bg"
+Alterable value A of "value holder" > 0
+Alterable value A of "value holder" <= 10
+Alterable value B of "value holder" < 8
- create object "background" at x-32 y-32
- set "background" x pos to (Alterable Value A( "value holder" )*32)-32
- set "background" y pos to Alterable Value B( "value holder" )*32
- Add 1 to alterable value A of "value holder"
Not as complicated as it looks!
on loop "bg... you understand that right!
Ok now treat alterable value A the x positions
and B as the y positions.
Remember in the last condition we set alterable value A to 1. This basicaly has started the proccess because as you can see in this condition it has alt val A > 0
Now this will only continue for 10 rows because of the third condition alt val A <= 10
and it wont do this more than 7 rows because of the last condition alt val B is lower than 8
Ok now the events.. We create the object... it doesnt matter where because we are going to position it now.
Now we set the background tile's x position to the alterable value A of the value holder *32, this is because thats the size of the tile. now we minus 32 otherwise it would start 32 pixels infront otherwise and youd get a gap.
The next one is the same but with y pos, and useing alterable value B, except this time we dont have to minus 32 because alt val B is starting at zero anyway.
now the last one we just add 1 to alt val A to tell it to go to the next tile on the x axis.
Ok now the next condition we put in will make it go to the next line:
+on loop "bg"
+alt val A of "value holder" =10
+alt val B of "value holder" < 8
- Add 1 to alt val B
- Set alt val A to 1
Whats happening here is when it gets to the end of a line it will tell B to go to the next one, and A to start from the left again (1)
So whats happening here is:
A A A A A A A A A A
1 2 3 4 5 6 7 8 9 10 0 B
1 2 3 4 5 6 7 8 9 10 1 B
1 2 3 4 5 6 7 8 9 10 2 B
1 2 3 4 5 6 7 8 9 10 3 B
1 2 3 4 5 6 7 8 9 10 4 B
1 2 3 4 5 6 7 8 9 10 5 B
1 2 3 4 5 6 7 8 9 10 6 B
1 2 3 4 5 6 7 8 9 10 7 B
And because of the first condition which had "if B is < 8" it wont carry on any more.
ok so its built the screen, now we need to start moving them across the screen to make it look like its scrolling.
So we need to use the values that we are left with after the background we just made.
which would be:
alt val A = 1
alt val B = 8
+if alt val A = 1
+if alt val B = 8
- stop loop "bg"
- set "background" Xpos to Xpos-1
- set "background" Ypos to Ypos-1
This is pretty obvius.. if the preccess has finished always move the background tiles 1 pixel left and 1 pixel up. (diagonal)
Right if you played it now you would get a fat off box going from the screen of the top left... so we need to get it to loop.. (the scrolling part)
+X position of "background" = -32
- set position to 32*8
+Yposition of "background" = -32
- set position to 32*7
Now basicaly when each one is a pixel off the screen it will wrap around the play area.
Umm.. i just realised this is quite a long way of going around it... But i like it so shup.
This is the example...
Lol im actualy gonna use this for some game, so please dont steal, but take the concept thats fine.
The example screen is the third level, and you can find the events under the comment "Background scroller"
The Link: http://www.box.net/shared/ixfpvydats
My other cars a BalrogRegistered