Mid, Left & Right functions for Strings in Cerberus X

It’s beginning to be late night, but I want share these with you.

Many of you probably remember Mid, Left and Right functions for strings in basic programming languages.

  • Mid returns from given position x amount of chars
  • Left returns from left x amount of chars
  • Right returns from right x amount of chars

These are easy to implement in Cerberus X, since it has nice string slicing methods.

Implementation for Mid:

Implementation for Left:

Implementation for Right:

You can test these for example with print Mid(“This is String”,5,2).

That’s it for tonight..

Font Class for my Font 2 PNG’s fonts in Cerberus X

My studies keep me really busy and tired… Still, I’m working on Cerberus X version of Easy Math Challenge, because there seems to be problem with sound in Monkey2 with 64-bit compilations for Android.

Anyway, here’s direct implementation (earlier I did this for Monkey X) of font class to use with fonts made in my Font 2 PNG for Cerberus X.

The source (the code is directly from my Cerberus X editor, but highlighting isn’t quite right):

I’m a bit lost for words, but if you find my “poor man’s Font 2 PNG” useful, feel free to use this code.

AmiKIT – Compiling a C program to Play a MED module

I recently downloaded from the official AmiKIT site the free version of AmiKIT. It’s great! I love it! I love the Amiga!

While testing the AmiKIT in an environment, that reminds me of the environment I had with the good old Amiga 4000, I got a spark to learn Amiga things again.

It would be nice finish my old classic 2D Ultima style RPG game. But where to find the needed documentation?

Below is a little video of my AmiKIT early adventure:

In the video an old C program to play MED music modules is compiled and tested. The C compiler that is used is VBCC.

Below is that program in full:

 

Time will tell if my RPG made on Amiga will be ever finished…

How to get timestamp in Monkey 2 with libc and in C

This morning I got implemented a little code, that can be used to get timestamp based on ANSI C code using Monkey 2 programming language’s libc.

Let’s take first look at the Monkey 2 code:

At the moment the output of the program is as follows: 40-31-8-26-10-2018

Year 2018, month 10, day 26, hour 8, min 31, sec 40.

Reversed order might be more useful in practice…

Let’s take a look at the C version:

To the year is again added 1900. This gives following output: 26.10.2018

The tm_mon is between 0..11, tm_year between 1900 + 0..n.

That’s it for now, lots of things to do…

 

 

On Signing a Windows App

First I would like to tell you, that I have purchased an OV code signing certificate for one year. I found out from a blog, that K Software has at the moment the cheapest OV code signing certificate, $84 for one year.

As MicroSoft says in their documents, you must have a certificate, if you want to distribute or sell Windows apps.

There are three main categories of certificates on Windows platform: Open Source code signing, OV code signing and EV code signing.

The first is the cheapest — in the best case free — the last is the most expensive.

Open source code signing suits you if you do open source projects. You can check the definition of open source development here.

In the other cases the other two mentioned certificates are for you.

The OV certificate doesn’t prevent at first the smart screen to appear. In time, when you get enough downloads the smart screen won’t appear anymore. The EV certificate that is the most expensive, gives you immediate trust and no more smart screen to your apps.

The main benefit of OV certificate is, that none of the AV software programs considers your precious application a harmful file.

Once you have the certificate, signing the exe is as easy as follows:

The signtool.exe can be found at c:\program files (x86)\Windows Kits\… The appropriate path should be added to your system’s %path% environment variable. If you don’t have …\Windows Kits\ search the internet for Windows SDK version 8.1 or 10.

I have today signed most of my Windows apps. Smart screen will at first still warn you, but the file is no more considered a harmful file.

Unlimited Objects Source Code

In my old blog post I gave some idea how to implement “unlimited objects” program. In the original video I used 16 canvases with 16 images + the actual visible canvas. Two canvases only is sufficient.

In the source (Cerberus X) below, no external graphics files are needed:

The program gives different output, if the calculations are in OnUpdate() on HTML5 target.




Below is the old video I’ve made previously:

Source code license: MIT.

3D Stars As Lines

I must have been really tired when I coded & posted the old 3D stars codes… Anyway, here’s code for 3D stars as lines.

Below the video:

To get the stars drawn as lines is really simple. In the 2D world to draw a line we need x1, y1, x2 and y2. In the projection from 3D space, we simple add for example 4 to the z-coordinate of a point so that, the other point is further away and we get two points to the 2D world.

Below is the main part of the Monkey X source code:

For the end the source code in full:

Feel free to use this code.

 

Sine Wave Scroller in Monkey2

Today’s little code, sine scroller in Monkey2. In the previous post you can download the code and data files for plain scroller. In this project same data files are used. Let’s take a look at the video:

The scrolling isn’t very smooth in the video, but try the code:

The idea is to build a string (“scrollString”) which characters are drawn one by one to the screen in order to achieve the sine wave effect.

Feel free to use this code.

Simple text scrollers in Monkey X and Monkey2

I coded today simple text scrollers in Monkey X and Monkey2. When the old school bug had bitten me I coded among other things the following:

This night it’s time to just simple text scrollers code.

Let’s take a look at the result of the Monkey X code:

The source code:

For the font I’ve used my Font 2 PNG and its data file. Notice, that the update rate is only 15, change that to 60.

 

For the first time I made a text scroller in Monkey2 too. The result is in video below:

As you can see, the code is a little different:

In order the get coding going, you may download both the projects with all the data files. Password to download: scroller


Later it’s time to again for sine wave scrollers… 🙂

Have fun!

Tile Scrolling with Maps Made with my Map Editor

Little tutorial on scrolling a map/world made with my Map Editor.

First, the source code in full:

Quite straight forward, but some words about the code.

In the Map Editor dat-file, the first 4 byte integer declares the width of the map, the second the height of the map in tiles. The size of the map is read first, then the map itself.

The scrolling is made with touch screen in mind.

The meaning of the Abs(…)-sentence is, that in which direction in the touch screen the finger is being moved most and then the map is scrolled into that direction.

The 256 color shapes of the world are from an Ultima IV remake and are free to be used. The original project is “xu4”, if my memory servers me right.

The source above is places to public domain as license for it.

Please, if you make a game (in any programming language) utilizing my code, show me, what you have achieved. I’m big fan of games of this kind of genre.

 

For the end a video regarding this post. At the beginning of the video there’s some scrolling: