Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, August 22, 2022

A game jam

I recently (the last weekend) developed a game for a "game jam" hosted on ItchIO. For those new to this term, the "game jam" is actually a competition where you develop a game within a certain timeframe (2 days) on a certain theme ("Final boss" for this one) and with a certain limitation ("stuck in a loop" it was this time). There are no rules as to how you develop it, other than the above. The competition page is here: https://itch.io/jam/mini-jam-113-final-boss

I was intrigued by the idea of creating a game in such a short time. I was also wondering about using AI generated graphics for this. The resulting game is available here: https://fairyhataka.itch.io/escape-from-mars

It's called Escape from Mars. You play as an astronaut who has a limited time to escape from Mars before an alien boss will trigger a powerful weapon. The effect of triggering the weapon is that you get stuck in a time loop and you have to repeat the day. In order to escape, you must repair the rocket and make sure it has enough fuel. You must also make sure you don't run out of oxygen and you don't starve.

The game was developed using the game engine that I wrote for Jenna's Virtual Life and graphics were created using Craiyon and Wombo

I also managed to create a rather successful discussion on Reddit about AI image creators. You can read it here: https://www.reddit.com/r/gamedev/comments/wtpgqo/anyone_using_aigenerated_images_for_games/

Here are some screenshots from the game "Escape from Mars":








Friday, August 12, 2022

Ray Tracing

 I am doing lots of renders for my 3D adult game Jenna's Virtual Life. I always wondered how these are actually being done and why it takes so much time to render. I found a very nice explanation of the ray tracing process here: https://www.scratchapixel.com/lessons/3d-basic-rendering/introduction-to-ray-tracing/how-does-it-work

There is also a basic implementation of the algorithm. Seems like a fun thing to try at some point :)


Tuesday, August 2, 2022

Linux text editors

 Today I had a discussion with a colleague about text editors in Linux and which one is the best editor. I realized people don't know lots of text editors (I guess I also don't know about all of them). But here are a few (the ones installed on the machine I was working on):

1. VI



2. NANO


3. MCEDIT


Personally I prefer mcedit . It's part of the Midnight Commander package. It's very intuitive and you see on the bottom bar all the shortcuts in case you forgot one of them. 




Saturday, July 16, 2022

Turning a JFrame into a JDialog

 I recently had to turn a JFrame into a JDialog. This means transforming a regular window into a dialog. In turn, this means blocking the main application window until the user does something in the newly created dialog (also known as "modal dialog"). It's actually quite easy to do. Even though at first I was tempted to start creating a new dialog from scratch, it turns out it's just a simple change in a few lines of code.

Here is an extract from my JFrame code:

JFrame mainFrame = new JFrame("Settings");

buildContent();

mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

mainFrame.pack();

mainFrame.setSize(1200, 900);

mainFrame.setLocationRelativeTo(null);

mainFrame.setVisible(true);


And how it looks like after conversion to JDialog (I only changed 2 lines of code, those in red):

JDialog mainFrame = new JDialog(this.appFrame,"Settings",true);

buildContent();


//mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

mainFrame.pack();

mainFrame.setSize(1200, 900);

mainFrame.setLocationRelativeTo(null);

mainFrame.setVisible(true);


You probably want to avoid JFrame.EXIT_ON_CLOSE but this is how it was implemented. You may also want to do some other checks, like making sure appFrame is indeed set to the main application frame. And maybe you don't want the dialog to be that large on the screen. But for a quick JFrame to JDialog conversion, this should work ok.

 

Tuesday, June 21, 2022

Quickly run log4j2 without properties files

Sometimes I just want to use log4j without a properties file and log everything to console. It seems that especially for this reason there exists the DefaultConfiguration class. This applies to log4j2.


import org.apache.logging.log4j.Level;

import org.apache.logging.log4j.LogManager;

import org.apache.logging.log4j.Logger;

import org.apache.logging.log4j.core.config.Configurator;

import org.apache.logging.log4j.core.config.DefaultConfiguration;

public static void main(String... aArgs)  {
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.DEBUG);
 

 

Friday, June 17, 2022

Online format convertors

Sometimes I have to convert a file from one type to another.

Today I had to convert a WMV file to an MP4 file. As I Googled for a tool to do just this, I discovered there are sites offering free online conversion services. 

I ended up using this one: https://www.freeconvert.com/wmv-to-mp4/

I just uploaded the file, waiting about a minute and then downloaded the converted file. It worked flawlessly.

Monday, June 13, 2022

Docker stuff I use

 In this post I will describe a few of the Docker stuff I currently use. May not work for everyone but it may help you get started.

First, if you have a dockerfile you need to build it. I often use intermediate images during the build process (for installing compiling tools). I also call these images stage=intermediate. A simple build script looks like this:

docker build --tag IMAGENAME .

docker rmi -f $(docker images -q --filter label=stage=intermediate)

After successfully building the image, you need to start it. Depending on the image you may need to map ports or data volumes. However, one thing I find useful is to also run docker ps after starting the Docker image. This helps me to check if it really started and didn't exit immediately for some reason. I also start the image with a -RUNNING added to the name. This helps me to better identify the existing images. A simple startup script looks like this:

docker run --name "IMAGENAME-running" -d -p 80:80 IMAGENAME

docker ps

Finally, at some point you may wish to stop the running image. When I stop it, I also remove the -RUNNING image, like this:

docker stop IMAGENAME-running

docker rm IMAGENAME-running

In the unfortunate case of an unscheduled system reboot, you should first run the stop script. This will take care of removing the -RUNNING image and will enable you to start it again using the start script above.


A game jam

I recently (the last weekend) developed a game for a "game jam" hosted on ItchIO. For those new to this term, the "game jam...