Thursday, May 25, 2023

Hex Life Editor update

 I forgot how much work creating a GUI from scratch was. This is why libraries are nice but I am doing this from scratch. I now have an editor but still need to add a way of taking the edited levels and playing them as well as set goals for a level and a partial editor that lets the player place their color of cells on the board. 

Early build of editor mode for my HexLife game

My thoughts are that the goal will be to give the player an existing layout sans their color, and they need to strategically place their color in such a way that their color will end up taking over the entire board. I am not sure I will have much time at all tomorrow to work on this, but should be able to release a version of the editor and player Saturday. This would leave Sunday and Monday to create a set of levels and fine tune things.

Tuesday, May 23, 2023

Let there be Life

 When I said I was going to program the game from scratch, I wasn’t kidding. As I am trying to move back to test driven development, as I believe the AI world of programming will become more natural language programming with the responsibility of the programmers to make sure that what the natural language produces actually works properly so creating and testing programs will become a vital skill for the future of programming. I don’t think programmers will be going away, but their roles will be more focused on design, testing, security, and optimization. Still, using a testing framework would be third party, so I wrote my own simple testing framework (when I post the final version the tests will be included).

Writing automated tests seems to be slow, but I notice that I find bugs much quicker and am a bit more confident that my code does what it is supposed to. My tests are not as thorough as they should be but good enough for the scope of the project I am working on.

When creating the game, I realized my idea of moving cells was very problematic, so opted for a growing effect with the eating of cells being a predominant feature. Text versions seemed to work so I bit the bullet and created a graphical version (manually tested as graphics/GUIs are way too painful to automate, and if the underlying code it calls is tested there shouldn’t be a problem).

The simulation was automated and just generating random grids results in really cool results. The first phase has been posted so Thursday I will be focusing on creating an editor and the weekend on putting together a short campaign where you will be given a map and need to place your cells in such a way that they will take over the map. Something has come up for Wednesday, so while I might get an hour or two in, it is likely not going to be very much. Hopefully I will have something Thursday night to show, as Friday is busy. Why everything comes up when I want to do a Game Jam is annoying, but it is what it is.

The first build is available at https://spelchan.com/games/y2023/HexLife/index.php

See you Thursday???

Friday, May 19, 2023

GameDevTV Jam 2023 Planning

 It has been a while since I have posted something here, but now that I have a tiny bit of time, I can finally work on my own things, so am entering the GameDevTV jam for this year. Why? Everyone who enters gets a free course so why not? I am going to be focusing my free time on writing some books on creating a game engine from scratch, so in preparation for the game jam I will spend the days I am able to work on it creating a game from scratch. Unfortunately, I still do have other obligations so will only be able to get in 30-50 hours during the 10 days so will have to take that into account. I am losing this first weekend and next Friday for sure and suspect there will be interruptions on other days so we will see how much I am able to do.

What do I mean by from scratch? There will be no libraries or frameworks other than the standard libraries and what DOM provides. I will write all the code. Ideally,I will extend this restriction to artwork and sound effects but that will depend on how much time I have at the end for polishing the game.

The theme of the game is Life in 2 Dimensions. The thoughtI immediately came up with is some variation on Conway’s Game of Life (CGL). Doing a straight CGL would not be much of a challenge, but if I did this more like a strategy game then there could be something interesting.

My idea is to use a hex grid where there would be 3 distinct types of cells which are either food or enemies. Red Cells eat Green cells which eat Blue cells which eat Red cells. Each round is broken into phases. Phase 1 would be the absorption phase where the cells around each cell is counted. If there are more enemy cells touching a cell then allies, the cell will be absorbed becoming an enemy cell otherwise it stays the same. The next phase is the movement phase.  

The rules for movement are easy. Head towards the nearest food cell (or, fake food cell when I add that later) though only using empty cells, so will stay still if cells closer to food are currently blocked.  Not sure what order the cells will move in, will be playing around with that aspect. 

The game will be an attempt to convert the entire board to your color. With the ability to place fake food on the board to guide the activity. I am hoping to have a crude version of the game by Tuesday or Wednesday as due to other obligations I am not going to be able to start until Monday. 

Friday, October 14, 2022

The future comes from the past

 It has been a long time since I took a break from working on my 2600 emulator. Next month I am going to return to that project. Things have changed a lot since I worked on that project so have a lot of decisions to make. Web Assembly has become a real thing and there are several good paths to using it. Kotlin is not one of them. I am trying to decide if I should port to C, or Assembly Script. I am also thinking of going with an IDE instead of just an emulator. 

The next few months will be looking at tools and technology available followed by porting my existing emulator code. From there will be a matter of finishing the emulator then possibly building an IDE around things.


Thursday, September 15, 2022

An Awful Month and a Postponed Decision

 Last month was rough and I am just getting caught up to where I should be this weekend. I am now working as a full-time college professor, which is a surprising amount of work. Making matters tricky was that just after finalizing the contract a major event happened.

My father passed away on August 20th. He had been taken to the hospital a few days earlier for pneumonia. He had recovered from it and had been moved up to the rehabilitation floor. I was assuming he would only be there a couple of weeks before my caretaking duties would start again. Instead, as I was packing up the stuff he wanted me to bring him for my morning visit I got a phone call from the hospital with the bad news.

It is really strange when something like this happens as part of my mind knew he was gone but another part insisted that this was some type of prank or a mistake. I knew I was not in a proper mental state so asked my neighbor to drive me to the hospital. I simply had to verify that this was real with my own eyes. Stupid, perhaps, but at least I got to say goodbye to him.

Next was the funeral. Dad wanted just a small gathering of his closest friends and family. Thankfully my sisters were there to help prepare this as I had so much preparation to do in a short time. I did write the eulogy which took multiple attempts. I was warned that when giving a eulogy that you should do several dry runs so you can get through it without breaking down. I am glad I followed this advice. Even then, there were a few moments where I could hear my voice breaking and had to pause for a few seconds. What is interesting is that it was at the strangest moments. How hard of a worker he was. How much he cared for my mother. Even writing this I am struggling.

If this wasn’t bad enough to deal with, on the day of the funeral the air conditioner wasn’t clicking on and we had a plumbing issue. The plumbing was easily resolved, thankfully. The air conditioner, was also easy but had a warm house all that day as we simply didn’t have the time to look into the problem. It turns out that there is a switch to the furnace outside the furnace room that magically turned itself off. My nieces and nephews swear they never played with the switch and it is high enough on the wall  (above head height) to prevent accidentally turning it off.

Even after the funeral, I have lots of work to do, but spread out over a few months until probate is finished. Slowly packing things up is not hard work, but often results in surprising memories. Which finally leads to the point of this posting. I still have no idea what I am going to be doing with the site and blog so will be delaying my decision until next month.

Sunday, August 14, 2022

Future of blog

 Changes are coming. I have recently accepted a new full-time job. This is the ideal job for me as it is near home so I will still be able to be my dad’s caretaker. This means that the amount of time I have to work on my own projects will be exceedingly limited. This leads to the question about what I am going to be doing with my site and blog. Right now, I am still deciding which course that I want to take.

Option 1 close them down. This would be the easiest course but not really a satisfying solution.

Option 2 quarterly updates. This would keep the site active and I could use the blog to write making of articles outlining what I have done to create the games. 

Option 3 focus on the making game aspect. I would slowly build a game with videos on each step of the process with the blog being a transcript of the videos.

Option 4 focus on teaching how to make games. This would be more focused on the technologies used to make games and would have tutorials on how to program.

Option 5 Classic Machine Architecture. The course I wish would exist. A look at a classic machine (Atari 2600, NES, SNES or PS1) and how you would create a game with that machine. This would result in learning how machines work with machines simple enough for a more holistic approach.

Any suggestions on which direction I should take would be appreciated. I will post my decision on Spelchan.com on September 1st.


Thursday, July 14, 2022

The fullscreen API

With my masters degree finally complete, I should have a bit more time to focus on my site. Unfortunately, my Dad is now disabled so I am taking care of him and being a care-taker has been taking far more time than anticipated. As he slowly improves, the amount of time I have available to work on my own things is slowly increasing but this may change shortly depending on upcoming events which I will talk about if they come to pass.  Reworking my site is certainly something that needs to be done. One of the big issues that I have is the size to make my games.

The problem is that there is no way of knowing what resolution that the user of a web application is using. The image below shows the different common resolutions that have been used in the past to the present. Making this problem more awkward is that windows don’t need to be full screen and different browsers have different amounts of stuff surrounding the page contents.

 


My plan was to use a 16x9 aspect resolution for future games as that has become the standard screen size. With most modern machines having at least 1280x720 resolution so 1024x576 seemed like an okay resolution to use for future games and I have been playing around with this. On my desktop machine, which was HD, this looked okay but when my monitor was upgraded to a 4k monitor, the locked resolution problem became exceedingly apparent. 

Two viable solutions came to my mind. The first is full screen mode that I have seen other sites take advantage of for videos. Looking into this, I discovered the fullscreen API and decided to explore this with my Canada Day game that I released on Canada Day (July 1st for the non-Canadian’s reading this). The API is easy to use once you have figured out how to use it, but as is often the case it does have a few weird aspects to it.

The API is invoked on a HTML display element which becomes full screen if the browser supports this. This is simply done by calling the element’s requestFullscreen method. This is simple enough but exiting full screen is not done by calling the element’s exitFullscreen method as any reasonable person would expect. Instead, you need to tell the document that you wish to exit full screen mode. While I can sort of see the logic behind this, as the element is becoming full screen and the document is returning from full screen, but couldn’t elements have an exitFullscreen method that calls the document version? API design really needs to be improved in this industry.

Once you are full screen, the next issue crops up. The canvas is the wrong resolution so it needs to be adjusted. This is assuming that you were even successful at switching to full screen. There is a “fullscreenchange” event that is triggered by switching between full and regular modes so writing a handler for the switch is easy enough. Finding the resolution for the full screen can then be done by using the screen.width and screen.height read-only variables.

function toggleFullscreen() {
let canvas = document.getElementById("game");
if (document.fullscreenElement == null) {
canvas.requestFullscreen();
} else {
document.exitFullscreen();
}
draw();
}
function fullscreenChangedHandler(event) {
let canvas = document.getElementById("game");
if (document.fullscreenElement != null) {
canvas.width = screen.width;
canvas.height = screen.height;
} else {
canvas.width = 1024;
canvas.height = 576;
}
canvasRect.w = canvas.width;
canvasRect.h = canvas.height;
}

The game can then be developed in 4K and scaled to the resolution of the display. My thoughts are 4K will be good for a while so will use that as a baseline resolution for my future development. Scaling to lower resolutions may not be the best approach but works good enough for now. Ideally having different images for different resolutions would be the better solution but it may be quite a while before I bother working on my LOD system and I will likely switch from canvas 2d to webGLx before doing so.

Locking the canvas size in the non-fullscreen mode is the next challenge. I am thinking that the canvas should scale based on the canvas size so next month’s game will be experimenting with that.