Three Sixty and No More
Okie dokie then.
Wait, no, let’s think of something less lame than “Okie dokie” to start on of these things. Almost anything really will work. Let’s try this instead.
So I got more thing to work today. On tap for today was getting the Bomb type finished off. I ran into a kind of weird problem along the way. Every time I would fire, the bomb would stop working. For the life of me I couldn’t figure it out. Turns out that I was doing the math wrong. Having a bomb in the system is tracked in a weird way. Since I only have a single misc field, and it happens to also control the firing timing for players, I would up instead using some simple division and using the 1000’s place instead. I can do this because C# has a cute was to do Modulo Division. I may have explained this before, but long story short is that it divides a number and gives you the remainder. This allows me to do different things based on where a digit happens to appear in it’s own line.
The trick is though that I was resetting the player’s machine gun incorrectly. So every time I shot it changed the Misc value back to the default “I just done getting shootin'” mode and it promptly forgot that it ever had a bomb. It was pretty dumb, but now it works.
In the back end of the system here’s what is happening. The game will load up an icon for with a bomb on it. Eventually this will be something else, but for now it works. When a player hits it, it disappears, adds a new bomb object that is set to follow the player around. Then when the player hits the trigger on their controller, it erases the bomb following them around and creates a Bomb Crasher type that falls and makes with the killing. It’s awesome because it works.
Also, after having some play testing done, it was found that shooting in just the 8 cardinal seemed off. She would mash the stick in a direction and the bullets would round themselves off, making it seem as if it was fighting her to shoot correctly. Originally I thought this was a good idea. Since I couldn’t (at the time) make true 360 degree shooting happen it also seemed okay. Now though, I co-opted that sweet trig code from the other things that are able to shoot in all directions and, blamo, now the players can too.
I began to realize something while coding stuff up today. I have come to the conclusion that I am using large parts of the C# language incorrectly. The true power of the language lies in the robot code that all of the different objects that I create can follow. Each of them having all of their own code self contained within, making the other bits of code, the structural bits, more easy to use and understand.
Instead I’ve managed to build myself another monolith of code like I was still using Blitz Basic. Oh, yeah, it works. The modular functions that I write pretty much guarantee that to some extent, but it’s not working cleanly. To wit, I have a function that handles all of the Fighter Plane Enemy AI. As far as it knows, the Update Robot code for the Fighter Planes doesn’t even exist. Instead, right before I update all of the enemies, I pull a little “if” statement that checks what kind of enemy it is and runs the AI function that I wrote. Does it work? Of course it does. Is it in the right place though? Well, not really. I should live inside the Fighter Plane Robot Code inside the class. Not in the main chunk of code that draws and checks collision and things. Basically, the structure is a little crap and I don’t think I’m happy with it.
So, as I continue I’m going to start to modify the code as I fiddle with it. Further new things that I create are going to be done correctly from a structure standpoint.
The issue then becomes, or rather has always been, how the fuck do I make things talk to each other? You see, when things live in different parts of the code, that section more or less owns them. So trying to get, say a Player’s Position from inside the robot code is almost impossible. Usually it’s because I don’t have permission. To access my own bloody code.
I foresee a lot of swearing.