I’ve posted in the past about my mental health issues, depression mostly. This past weekend was Labor Day weekend. I was looking forward to getting some coding done, but didn’t have the motivation. It wasn’t for a lack of energy or even depression itself. For some reason I was avoiding it. To the point that I was about to get started and my mind said “Hey! Look, your room sure could use some picking up!”
Seriously. That tells you I had a serious avoidance issue when cleaning my room happened in order to avoid programming.
At the start of the weekend I had gone to get refills of my prescriptions and they weren’t able to fill them. I can do a day or so without, but then after that long, I get adverse effects (an increase in anxiety, generally). This happened. It put a damper on my ability to concentrate and focus. I like the energy involved, but it was diffuse through the body so it wasn’t like I could take the energy and focus it towards production it was just all over nervous energy and the slightest thing could set me off. So yay I’m crazy and need meds to function. I did sit down and attempt to code, but I just stared at the screen blankly, feeling utterly stupid and unable to comprehend.
I played a lot of Hearthstone. That was easy. Early in the weekend I had attained a rank of 15, my highest ever. Mid-range hunter which I had just discovered on my own then read about while trying to say “hey, what’s up with the strength of this deck” then I started hitting my skill limit, even with a deck that’s claimed to be good. Anyways, I dropped over time (I think due to my lack of focus), and by the end of the season was down to 20 (I usually hover between 20-17)…
Anyways, the last two nights (you’ll notice those are the nights before I have to go back to work!) I started coding at like midnight or so. I had received my meds and they were kicking in finally… Frustrating that the pharmacy couldn’t do a temporary refill, because you know, 3 day weekend is a GREAT time for programing if you’re not crazy in the head from lack of meds!
So I started to create my “levels” for Automute. I can’t recall if I posted about it or not, but in Unity there’s this thing called an “inspector” it’s nice. You can drag and drop things to and from it. So I can create a blank array of gameobjects, and then, instead of having to code up something like:
vehicleList = file.load(“copcar.prefab”);
I just create a vehicleList array in code, then head over to the Unity interface and drag the copcar frefab directly into slot 1 and there it is. No need to code a whole bunch of unique statements to load.
The problem here is that each level is a prefab, which means, in Unity, you can’t work with multidimensional arrays when working with the inspector. You can only work directly on a single array. So this means, with my “levelManager” script, I can’t then say something like:
Level = copcar (by dragging the car into it). That means the simplicity is somewhat reduced because i can only access that first index which is really the level number.
In my ideal world it’d be “Level[levelnumber][vehicleListIndex]
Instead I have to create a “level prefab” which contains the vehicleList array. Then I load the LevelManager with the level prefab. Then I access the prefab and can drag the objects I want into the vehicleList array there. Then to access it I have to use the specialized “getcomponent” code to access the prefab and then the array elements. It’s a lot of unnecessary complexity, IMO. But at the same time, there are so many other things that make complexity reduced that I guess I can’t complain too much.
Since it had been a while since I coded, I had kind of forgotten how to use getComponent. The fact that my brain was dead meant I kinda sucked at first. Then after the next day my meds really kicked in and I was back to thinking a bit more clearly and able to focus, so I worked on it more. I sort of have it working. There’s some logical condition in the loops that I need to correct. Basically I check to see if a vehicle exists where I’m going to place a new one, and if it does, then get a new location to spawn the new vehicle at, but I think I’m not doing the loop properly, so I’m also generating a new vehicle, and thus the old one that should be placed int he new position is discarded, which means I am generating fewer vehicles per level than I am designing the level for (i.e. the number of vehicles in the vehicleList array). I tried a while loop last night, but the logic was wrong and locked the program. I think I had placed it outside a for loop and used the wrong conditional. Tonight I’m going to try to place it inside the for loop and then negate the conditional and I believe it should then seek a proper position and once a free spot is found, spawn a vehicle there and go to the next vehicle and run the loop again.
Once I get that running and see my cars are spawning correctly, I think the code is actually not done well, and is a good time to refactor now.
The next question I am debating is whether or not to create a “generator” function in the level prefab (not the best term, as I don’t think it’s a real generator function in the technical sense), that would, upon loading the level, take the array for that level, shuffle it; then the levelmanager will request a new vehicle from the level prefab when it’s time to do so. The level will then call it’s generator which will basically pop the vehicle off the array/stack and hand it over to the level manager, which will then place it onto the screen at a random coordinate.
Once that’s done, I believe I’ll work on implementing a timer element so I can vary the spawn rates/times, similar to how I do with my asteroids in Killing Horizon. Right now it just spawns as fast as it loops and if it hits a random threshold (right now I have a “if random value is less than 2 (out of 4), spawn a car) so you have a 50% chance at spawn each time the loop is run. I think adding a timer to this and then I have to factors to play with regarding vehicle spawns: time and chance to spawn.
Then I have to create the level-loading code. When all the vehicles in that level are no longer active, time to load the next level.
Once that’s done, I’ll have to add a point system and score display. Then I have a functioning prototype without the load screens or much else, but it’d be something to play with and test.
The next part will be altering my current vehicles. I think I’ve decided to go with photos of cars, not bitmap art or whatever. I’ve got more vehicles lined up to play with, not just the same like 6-9 vehicles I currently have. Once I get those made and ready, I’ll work on balancing the basic levels in terms of overall levelspeed, points, spawn rates, and vehicle speed.
Once those are done, the “special” levels will be made (frogger style, police raid, frog raid and more), and then interstitial story screen stills to give the basic plot, title screen and score screen test test test and then release. LOL.
“48 hour game jam” my ass!