Scrolling in KNP
|
I've made an engine about it but here goes an article.
As every Klik N Play user here ( if there's remaining any ) know that Knp dont have any scrolling functions so most of the knp games i've played where scrolling is required they've simply used multiple frames for a single level. This seems just OK!, for few of the games but not for others. There are no extensions to add a scrolling feature in K&P and as far as i know there are'nt any working engines as well ( besides mine ) .
So here i'll tell you how you that how simply you can make scrolling games with K&P with complete control over the level environment and besides that your A.I. will also support it perfectly. I've wrote a engine with a complete tutorial about it but for those who can't understand through that or hav'nt checked it out yet heres an article for you all!!
Basis:
What were the basis for the development of this engine?
This may seem little strange that iam writing an article about something which took me less than few seconds to think about. I was a good old 12yrs KNP newbie when i came to knew that K&p is lacking scrolling function. I had a TGF demo at that time and i remember seeing a scrolling function in it but i was'nt going to develop any game on TGF because i never had the full version at that time. So first i decided that i will simply use those multiple frames for every level but then i thought for a second if there is some way to get my game levels scrolling because changing frames for one level specially when there is only one kind of area will be annoying for the players as well as for me to develop. I came up with the simpliest idea of all. 'If i cant focus the screen at my player when he go further in the level , why dont i simply bring the level to focus itself in the screen'. I tried that with only 1 or 2 level objects and i found out that its not a very bad idea. I was just thinking that why someone hav'nt used it yet. Lets Guess! maybe no one cared. But i did!
Basic Engine:
If you already hav'nt guessed that how that would be done in KNP then here goes..
1)In your Level Editor playfield area , bring your Player's ( hero ) object at a position which will face screen centre as soon as the level starts.
2)Now setup your level objects , as normally you do just make sure they are within the playfield , even if it exceeds the screen range.
3)Now KNP dont have the scrolling feature , to make the situation worse it also don't have the group assigning feature so you'll have to work separately for each and every level object unless there are clones with the same name.
4)In your Events Editor:
*Repeat while pressing right arrow key :
+Set X Position of LevelObject1 to X(LevelObject1)+1
*Repeat while pressing left arrow key :
+Set X Position of LevelObject1 to X(LevelObject1)-1
Like this if you assign the above instructions for all the level objects you can simply make a scrolling effect for your game. But this wont work all the time. If you have any enemy A.I. which keeps on changing his position and you assign it these instructions then it will simply disappear from the playfield the next time you see them. So if you are planning to add some good old enemy A.I. in your game ( besides the stationary ones ) jump to the next part.
Additional Points:
1)Take an ActiveObject1 as an example. If it is changing his position & direction of movement then moving like a level environment will simply through it out of the playfield ( atleast in most conditions ). So the best way to avoid that is to activate A.I. only when it is within the screen range. But how will we detect that?
2)For that we will make a Counter object to record our player's object ( imaginary ) position in the playfield. The position which our human player is currently viewing on his screen. The simplest way to do this is to keep on adding 1 till our player is pressing his right arrow key (going forward) and keep on substracting 1 when he/she is pressing the backarrow key (going backward). This way we will know when a particular enemy is within the screen range and we'll simply activate all his A.I. ( this can be done by adding a Counter Range condition for every A.I. event. ) .. Besides you can use the counter to detect if the level environment is about to end and stop the level environment from keep on going. Just add a Counter Range condition for right/left arrow key presses.
3)For obstacles you can again either use the Counter Range idea because through this you know where is which object in the level or simply set a value when the player collides against it and unset the value when the player presses a key opposite to the direction of the obstacle. Add a condition for the movement of the level environment that the value you assigned should be 0.
And Thats It!
If you have understood how this trick works completly , then you can easily modify it to make even more advanced scrolling games. For further reference check out the K&P Scrolling Engine and the tutorial provided in it.
Maybe little confusing but Hope it helps!
Enjoy!
|
|
|