Kren Devlog #1 – Upgrade System and Level Specific Items

Player now has data (like energy, starting_x and starting_y positions, starting direction and so on) and a nice inventory of permanent upgrades. I’ve called it inventory for the sake of it. It’s just an array (it really is) of stuff you can get through the whole game. Permanent stuff. Stuff you can get only once per whole game.

In every room (level) there are a number of different objects (like enemies and items). Most of these items will simply respawn once the Player gets back into the same room. Again and again.

This way it doesn’t matter how many times you killed the enemies in the room. As soon as you exit and re-enter the same room, all those enemies are just there. Again.

This is fine. Almost essential in some situation (believe me, there will be times when you’ll need more enemies to refill your energy or ammo levels).

The green stuff will not respawn once you pick it up. The enemy will, as soon as you re-enter the room.
The green stuff will not respawn once you pick it up. The enemy will, as soon as you re-enter the room.

So what’s with the level specific items? If you already acquired the high-jump ability, you won’t find it again in the level. This is where the inventory comes into play. And this is what I’ve coded today.

By the way I’m not using maps. I’m using simple arrays. I just defined a couple of macros so I can use my global array like it’s a key/value map. I get the added benefit of speed and code autocompletion in GameMaker. The only thing I made sure of, was to initialize the size of the whole array.

//Arrays
global.player[MAXARRAY]     = 0
global.inventory[MAXARRAY]  = 0

Obviously MAXARRAY is a macro (value is 255).

Then let’s say that I have another macro like PLAYER_DATA which is an expression referring to global.player. And I happen to have just the right macro for the 0th position of such array; ENERGY.

If I write PLAYER_DATA[ENERGY] = 99, it’d be like writing global.player[0] = 99. But now I have autocompletion in GameMaker and a list of defined, clear, meaningful, macros.

How I positioned the tileset in my tech demo

In the earlier tech demo, I had positioned a truckload of similar tilesets. Those bluish/greyish square blocks are not hand picked. I did not make that work in the level editor. I got inspired by the Smart Tile Objects tutorial by HeartBeast.

I simply downloaded the Square Blocks Textures from OpenGameArt.org, cut and pasted a bit in Paint.net to adapt it to my needs, and imported the end result as a background in GameMaker Studio.

My background version. Easier to import in GameMaker Studio.
My background version. Easier to import in GameMaker Studio.

I made so that when the floor/wall object (which is invisible) is created, it places random tile from that background into the level. Covering the same surface the object covers.

This makes for a pretty quick and dirty way to test a level with low object counts. Also gives me a little “randomized” effect every time I start the level.

What if I don’t want all that randomness? It’s as easy as using random_set_seed(1)

So, here is the create event of the smart object.

tile_fill_object(id, bg_blocks_16, 16, false)

And here is the tile_fill_object script

///tile_fill_obj(obj, tile, tile_size, randomize_tiles)

var obj         = argument[0]
var tile        = argument[1]
var tile_size   = argument[2]
var rand        = argument[3]

var col_num = background_get_width(tile) div tile_size
var row_num = background_get_height(tile) div tile_size

if !rand
{
    random_set_seed(1)
}

for (var row = 0; row < obj.image_yscale; row += 1)
{
    for (var col = 0; col < obj.image_xscale; col += 1)
    {
        var col_index = irandom(col_num - 1)
        var row_index = irandom(row_num - 1)

        tile_add(tile, col_index * tile_size, row_index * tile_size, tile_size, tile_size, obj.x + (col * tile_size), obj.y + (row * tile_size), obj.depth)
    }
}

This is how it looks in the level editor

Level editor with few big Smart Tile Objects
Level editor with few big Smart Tile Objects

While this is how it looks in the game

Same few big smart tiles objects. But with randomized tiles.
Same few big smart tiles objects. But with randomized tiles.

My Game Development setup

I’ll keep this short and sweet.

Whenever I tell people that I have a notebook, they usually reply with something like “and what about your main computer?”.

I do not have a “main computer”. I have just this notebook. Which is running Linux and has no accelerated graphic card available (to tell the truth it’s an integrated Intel HD Graphics 4000).

Yet I’m using GameMaker Studio. How is that even possible? VirtualBox made it possible. I’m running Windows 7 inside Linux via VirtualBox.

Testing my GameMaker platformer engine.
Testing my GameMaker platformer engine.

Even though I cannot take advantage of all the graphic acceleration stuff (e.g. the awesome graphics in Hyper Light Drifter looks like shit on my notebook; Shovel Knight is unplayable and so on…) I’m able to run my platformer engine with a decent 400 FPS (real). A consistent 60 FPS.

I’m quite happy about it but I just hope I can keep developing with this machine. Fingers crossed.

Testing the platformer engine I’ve been working on

Still in early planning stages. Yet testing the platformer engine made in GameMaker.
Still in early planning stages. Yet testing the platformer engine I made in GameMaker.

I’ll write a longer post soon. You can watch the video on youtube with some audio effects as well.

I’m still early into the planning stages of the game. I just needed a platformer engine I can work with to build the game. It’s going to be a Metroidvania type of game.

More on that later.

Xubuntu 16.04 Xenial Xerus out now. RAM usage Minimal vs Desktop

Before downloading the Desktop image of Xubuntu 16.04 take a look at these pictures.

Notice the RAM usage. Full Xubuntu Desktop is 270 MB while the Minimal Xubuntu setup is 192 MB. I’m not a math genius, but I can see what’s going on here…

This is the full Xubuntu Desktop 16.04 Xenial iso. Just after the first boot.
This is the full Xubuntu Desktop 16.04 Xenial iso. Just after the first boot.

This is the mini.iso with Xubuntu Minimal installed.

Notice the lower RAM usage of the Minimal installation. First boot as well.
Notice the lower RAM usage of the Minimal installation. First boot as well.

My choice

I have a notebook with 8 GB of RAM but this isn’t a good reason to waste it. I think the Minimal Xubuntu 16.04 is a viable alternative, especially if you want to have proper control over the software you want (or don’t want) on your system.

Download Links

How I did the test

  • Fired up a couple of identical Virtualbox  VMs.
  • Installed the systems using their respective ISO images.
  • Installed htop.

How to install the Minimal

To get the Xubuntu Minimal Setup you have to download the mini.iso and run the setup. After a few questions about localization, keyboard, download mirror locations and so on, you’ll be asked to select what software you want to install. Make sure you keep the selected core stuff but also check the Xubuntu Minimal for installation.

If you check the Xubuntu Desktop entry, instead of the Minimal, you might get the “heavier” version regardless of this whole mini.iso procedure.

Note that you need an active internet connection to download the required packages while installing the OS.

Ubuntu 10.04 Lucid – Issues with external monitor and Ati Radeon card

I’m re-posting this because, apparently, there’s still someone who’s looking for this post. So here it is, from the original post I made some years ago.

After an upgrade I had issues with tearing and waves corrupting the desktop on my external monitor (no issues on my laptop screen). I decided to format and reinstall everything. It solved a tons of other small issues but not this one. External monitors (LCD or CRT) won’t work with Ubuntu 10.04 notebooks with Radeon cards (I have a Mobility radeon x1600). You’ll see a distorted image. Waving like the refresh rate is incorrect.

SOLUTION
I just did the following (on a bare install of Ubuntu 10.04)
Fire up the terminal and type

gksudo gedit /etc/modprobe.d/radeon-kms.conf

a blank file will open up. Type in the following.

options radeon modeset=0

Save, exit and reboot.

Beware that this solved my particular issue but it may not solve your own. My issue had to do with waves and refresh problems on an external monitor connected to a Notebook’s Ati Mobility Radeon x1600, running Ubuntu 10.04. That’s it. Your mileage may vary.

How to rename your WordPress database tables prefix after the installation

It’s really easy. You just need a plugin: Change DB Prefix

  • Make a backup of your database (and maybe your wp-config.php)
  • Make sure the webserver owns the whole WordPress directory (i.e. if you’re using Apache Web Server and your WordPress files resides inside /var/www/webdomain.com/public_html/, just make sure to sudo chown -R www-data:www-data /var/www/webdomain.com/public_html/
  • Also issue a sudo chmod -R 755 /var/www/webdomain.com/public_html/ to give the webserver the ability to write to files but only read/execute to others.
  • Go to the plugin screen inside your WordPress admin panel, set the new prefix and run it.
  • Done.

 

Convert your WordPress Database Charset and Collation to utf8

In the wp-config.php file there are two lines that define your MySQL database charset and collation.

define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', 'utf8_general_ci' );

These lines should match those of your database but it’s not always like that; maybe you want to migrate the database content into another one (which is CHARACTER SET utf8 COLLATE utf8_general_ci) or maybe you just want to set reasonable defaults for your blog (avoiding the defaults, which more often than not are unknown).

Enter Utf8ize. It’s a simple WordPress Plugin but it’s a life-saver.

The goal in these conversions is always to decide on what charset/collation combination you want to use (UTF8 being the best choice in almost all scenarios) then to convert all tables/columns in your database to use that charset. At that point you can set DB_COLLATE and DB_CHARSET to the desired charset and collation to match.

It reads your database and generates SQL statements for every table and column. Then you simply copy/paste the statements into phpMyAdmin or Adminer and execute.

Just remember to change your wp-config.php accordingly and pay attention to the generated SQL statements for the specific collation (may be utf8_general_ci or utf8_unicode_ci). Set the correct values in the wp-config.php right after you run the SQL statements and you’re done.

Block direct ip access to your server in Apache 2.4

Let’s say you have:

  • A server with an ip address (like xxx.xxx.xxx.xxx)
  • A domain name (like example.com)

And you want to be able to reach your web server (Apache 2.4 in this case) via your domain name (example.com) but you want to block access via ip address (so that when you type xxx.xxx.xxx.xxx in the address bar, it doesn’t work).

  • Connect via SSH to your server.
  • Create a new config file in the sites-available directory:
    sudo nano /etc/apache2/sites-available/direct.conf

Now type the following lines

<VirtualHost *:80>
    ServerName xxx.xxx.xxx.xxx
    Redirect 403
    DocumentRoot /dev/null
</VirtualHost>
  • Save the file
  • Type sudo a2ensite direct
  • Now restart your server: sudo apache2 restart

Done. You won’t be able to access your website using the IP address of your server.

If you want to disable this particular site configuration, just type sudo a2dissite direct and restart the server (sudo apache2 restart)

EDIT:

You might have to use

Redirect 403 /

As pointed out by Chris (thanks for letting me know).