It’s 4.57am and I think I am going to sleep soon. Today, I was quite tired and slept my evening away. When I woke up though, I continued to add levels 22, 23 and am now trying to revamp level 9.
Level 9 is a level where the player witnesses an Enemy and a Friend in the same level for the first time. I wanted to portray how one’s enemies can turn your friends into your enemies. I called the function backstab() where it checks whether the enemy has touched any friend on the map, and if it has, kill the friend, and spawn an enemy on the exact spot. Sounds kind of cruel, but anyway this is an important level that I thought I should give it greater emphasis. I’m designing the level again and probably move the old level 9 somewhere else or delete it because it is too easy and pointless for now.
Hopefully tomorrow when I wake up, I will be able to at least finish some more levels. And after that it will be an exciting moment of adding Portals 31 to 45 on the third flight of steps! Currently there are only 30 portals, and I can’t wait to open up all the portals haha!
This is the level selection screen. The character is represented by a red box. I initially wanted a plain “click to enter level” style of level selection. But I sort of screwed up with the coordinates of the Buttons, and accidentally made each button a little lower with each new level button unlocked. This made every new button appear lower on the screen than the previous button, forming a flight of steps, made of buttons! It was then that I thought it would be cool to have the level selection screen be represented by a player moving to doors that get increasingly higher.
I thought it would be applicable to use a flight of steps, since it means climbing higher, which is what it should feel like when advancing the levels. I also then added the player, and I also wanted to make the steps go down when it came to the later levels because life isn’t always going up. However, I think I have some space constraints and sadly I can’t make steps going back down unless I use a camera system, which I think is lots more hard work because it involves some side-scrolling! I don’t intend to implement a side-scrolling feature in this game.
The portals can animate (they currently animate by glowing). But even the animating of portals were not planned too. Before animating my player, I wanted to animate something REALLY simple, something that does not walk, does not jump, does not fall, so I chose the portals. I wanted to make them spiral, make the outer rings disappear, but among the sprites I made, I think none of them looked good. I settled for glowing portals in the end, which till now I still find they don’t look good but at least they are less boring than plain old portals.
The flow from level to level is still incomplete though, as some levels are simply blank – without platforms or enemies or the like yet. I also have to remind myself to remove the 3 cheat buttons at the top once the game is complete.
I think the thing I am most proud of in this screen is the AI. Being able to click on the portals and have the character automatically move to them. This was the most challenging part. At first, I was okkayyyyyy…how do I do that? How do I make the character automatically know WHERE to go based on WHERE the player clicks? I had to really figure out what would be the best way to tackle this.
It was really tough for me. I think it took me an entire night to get the basic AI working, with bugs, and it took me another night to fix all the problems with the AI.
I started by making an invisible number called “floors” which increases every time the player ascends, and goes down when the player goes down. This was more effective than checking how high or low the player is on the screen, accurately keeping track of which floor my player is at.
Then I would check for user input and get the on screen X and Y values. Based on where the player clicks, I check if the click falls within the boundaries of any portal. If it is, I trace the coordinates to get the portal number.
Now the AI has a goal. But it does not know how to get there! It also does not know whether it needs to climb up, down, or whether it’s on the same floor.
That’s when the “floor” number I created became really useful. If my goal is level 1 to 15, my target Floor is 1. If my level is 16 to 30, my target floor is 2 and if I am not at my target floor, I move LEFT until I reach the elevator (indicated by grey doors), where I go up or down by comparing my currentFloor and targetFloor.
Once at my target floor, I move right and constantly check if I have passed my target portal. I will jump whenever the platform I am standing on is lower than the platform that my target portal sits on. Finally, the character reaches the target portal and enters! YAY!
This is the first time I attempted AI pretty much on my own without any help, so I am greatly impressed with the results. It may seem as though the coding is easy, but I had so many problems! For example, I could not get the character to move left or right at first, and I could not make it automatically jump too! There were also problems where after it jumped, it would jump even when I just want the character to move to an adjacent portal that isn’t a step higher.
After completing the AI, I felt really happy that while it took much more effort than a point and click screen, I think it is far more interesting and way worth the effort.
The last thing I added was the ‘automatically enter level when AI moves to door’, because I just wanted to play around with clicking the portals and watching my character jump here and there without entering any level. It was really fun, somehow, watching the red box jump around. It was really rewarding.
I guess it’s time for me to sleep now =(. Hopefully I can at least get the last of the levels to work and move on to creating and designing the pink-theme portals! The levels I will not do for now are 18, 19, 20 because I have something planned for those levels in the late-game.
Thinking back on the work I have done makes this so much more exciting.