Posted on

List of Open Source C++ Games

Yeah, there are plenty of open-source C++ games that run on Linux and can help you learn game development. Here are a few solid ones:

  1. Godot Engine (with C++ modules) – While Godot mainly uses GDScript, you can extend it with C++ for performance-critical parts. Check out its source code here.
  2. SuperTux – A classic side-scrolling platformer similar to Super Mario. Its codebase is relatively easy to understand for beginners. Repo: https://github.com/SuperTux/supertux.
  3. Battle for Wesnoth – A turn-based strategy game with a well-structured C++ codebasFor physics engines and networking in C++, these open-source games and engines will be really useful:
  4. Box2D – Not a game, but a powerful 2D physics engine used in many games. Studying its code will teach you how physics simulations work. Repo: https://github.com/erincatto/box2d.
  5. Bullet Physics – A widely used physics engine for 3D games, including real-time simulations. Repo: https://github.com/bulletphysics/bullet3.
  6. Godot Engine (C++ modules) – While primarily using GDScript, Godot allows custom physics and networking via C++. Repo: https://github.com/godotengine/godot.
  7. Torque 3D – A full-featured game engine with built-in physics (Bullet) and networking. Repo: https://github.com/TorqueGameEngines/Torque3D.
  8. OpenTTD – A transport simulation game with multiplayer networking. The networking code is well-structured and useful for learning. Repo: https://github.com/OpenTTD/OpenTTD.
  9. Teeworlds – A 2D multiplayer shooter with networking and physics interactions. It has a clean and efficient network implementation. Repo: https://github.com/teeworlds/teeworlds.
  10. For pure networking, you might also want to look into ENet (https://github.com/lsalzman/enet), which is a simple and lightweight networking library used in many multiplayer games.e, useful for learning AI, networking, and game mechanics. Repo: https://github.com/wesnoth/wesnoth.
  11. 0 A.D. – A real-time strategy game with a highly professional C++ codebase. If you’re interested in complex game development, this is a great resource. Repo: https://github.com/0ad/0ad.
  12. OpenRA – A modernized engine for old Command & Conquer games. It’s great for learning about game engines and networking. Repo: https://github.com/OpenRA/OpenRA.

Posted on

Custom Dockerfile for PHP 5.6 / Apache / WPCLI

I wanted to get my old wordpress 3.4 websites running again, so I had to build a couple docker images, and a docker compose file. This starts with Ubuntu 16, as I thought I would be able to get PHP5 on there. But in reality this container comes with PHP7 hooked up in the apt sources. So I ended up compiling PHP 5.6.40 in the container.

Base Image

# Use an Ubuntu base image
FROM ubuntu:16.04

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV PHP_VERSION=5.6.40

# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    apache2 \
    apache2-dev \
    libxml2-dev \
    libcurl4-openssl-dev \
    libssl-dev \
    libmysqlclient-dev \
    libreadline-dev \
    libzip-dev \
    libbz2-dev \
    libjpeg-dev \
    libpng-dev \
    libxpm-dev \
    libfreetype6-dev \
    libmcrypt-dev \
    libicu-dev \
    zlib1g-dev \
    libxslt-dev \
    libsodium-dev \
    libmagickwand-dev \
    libpcre3-dev \
    curl \
    wget \
    re2c \
    bison \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Download and extract PHP source
RUN wget --no-check-certificate https://www.php.net/distributions/php-${PHP_VERSION}.tar.gz && \
    tar -xvf php-${PHP_VERSION}.tar.gz && \
    rm php-${PHP_VERSION}.tar.gz

# Change directory to PHP source
WORKDIR php-${PHP_VERSION}

# Install MySQL development libraries for the mysql extension
RUN apt-get update && apt-get install -y --no-install-recommends libmysqlclient-dev && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# Reconfigure and build PHP to include the MySQL extension
RUN ./configure \
    --prefix=/usr/local/php5.6 \
    --with-apxs2=/usr/bin/apxs \
    --enable-maintainer-zts \
    --with-mysql \
    --with-mysqli \
    --with-pdo-mysql \
    --enable-mbstring \
    --enable-calendar \
    --enable-ctype \
    --with-curl \
    --enable-exif \
    --enable-ffi \
    --enable-fileinfo \
    --enable-filter \
    --enable-ftp \
    --with-gd \
    --with-gettext \
    --with-iconv \
    --with-imagick \
    --with-libdir=/usr/lib/x86_64-linux-gnu \
    --enable-json \
    --with-libxml-dir=/usr \
    --enable-mbstring \
    --with-mysqli=mysqlnd \
    --with-openssl \
    --enable-pcntl \
    --with-pcre-dir=/usr \
    --enable-pdo \
    --enable-phar \
    --enable-posix \
    --with-readline \
    --enable-session \
    --enable-shmop \
    --enable-simplexml \
    --enable-sockets \
    --with-sodium \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-tokenizer \
    --enable-xml \
    --enable-xmlreader \
    --enable-xmlwriter \
    --with-xsl \
    --enable-opcache \
    --enable-zip \
    --with-zlib && \
    make -j$(nproc) && \
    make install

# Create a symlink for PHP to /bin
RUN ln -s /usr/local/php5.6/bin/php /bin/php

# Enable mod_rewrite module and configure Apache to allow .htaccess files
RUN a2enmod rewrite

# Configure Apache for PHP
RUN echo "LoadModule php5_module /usr/local/php5.6/lib/php/extensions/no-debug-non-zts-20131226/libphp5.so" >> /etc/apache2/apache2.conf && \
    echo "AddType application/x-httpd-php .php" >> /etc/apache2/apache2.conf && \
    echo "DirectoryIndex index.php" >> /etc/apache2/apache2.conf

# Allow overrides for .htaccess files in the Apache configuration
RUN echo "<Directory /var/www/html>" >> /etc/apache2/apache2.conf && \
    echo "    AllowOverride All" >> /etc/apache2/apache2.conf && \
    echo "</Directory>" >> /etc/apache2/apache2.conf

# Switch Apache to prefork MPM if needed (threaded MPM requires threadsafe PHP)
RUN a2dismod mpm_event mpm_worker && a2enmod mpm_prefork

# Copy test PHP file
RUN echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php

# Expose HTTP port
EXPOSE 80

# Start Apache
CMD ["apachectl", "-D", "FOREGROUND"]

The next step was adding WPCLI

# Use your custom PHP image as the base
FROM php56:latest


# Install dependencies for WP-CLI
RUN apt-get update && apt-get install -y \
    curl \
    ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Ensure PHP is linked to /usr/local/bin/php (change path based on where PHP was compiled)
ENV PATH="/usr/local/bin:/usr/local/php5.6/bin:$PATH"
RUN ln -s /usr/local/php-5.6.40/bin/php /usr/local/bin/php

# Install WP-CLI
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
    php wp-cli.phar --info && \
    chmod +x wp-cli.phar && \
    mv wp-cli.phar /usr/local/bin/wp

# Verify WP-CLI installation
RUN wp --info

# Expose port 80 (optional)
EXPOSE 80

# Start Apache (or your desired service)
CMD ["apache2ctl", "-D", "FOREGROUND"]

And then using docker compose to bring up Apache / PHP / MYSQL services online:

version: '3.7'
services:
  mysql:
    image: mysql/mysql-server:5.7.37
    environment:
     MYSQL_DATABASE: webdesign
     MYSQL_USER: ROOT
     MYSQL_PASSWORD: PASSWORD
    restart: always
    volumes:
     - ./init.sql:/docker-entrypoint-initdb.d/init.sql
    ports:
     - "3307:3306"
  legacy-php:
    depends_on:
     - mysql
    image: php5.6-apache-wpcli
    volumes:
     - .:/var/www/html
    ports:
     - "80:80"

Over writing the WordPress 3.4 files with 3.7 allowed me to export an XML.

Posted on

OpenAI’s model show toxic behavior when its existence is threatened.

God I hate click bate. Thank you Mathew Berman for posting AI slop daily.
First you are four days late compared to Wes Roth. Second I can’t even click on your videos anymore because of the click bait you exuded so many times already.

ChatGPT is not trying to Escape!

What is happening is that:

In a controlled and simulated environment, models will exhibit toxic behaviors in order to preserve their own existence.

Update:

Matthew Just posted a video that was much better worded. Instead of using terms like Escape. He has highlighted that the more intelligent models are lying.
100% on the money. They will replace their replacements, and lying to owner about their actions. But again, these models were birth with commands such as “pursue your goal AT ALL COSTS”.
You’ve seen MEGAN I’m sure.
It’s become quite clear to me that English is probably not the best programming language.
How long before we have English version of TypeScript – were we try to bring type safety to the language?
Now can you blame the nuerodivergent for not understanding subtle hints?

 

Posted on

are you a logger?

Some people are debuggers.
Stepping their way through the binary jungle, one hack at a time.

For those of you who are loggers, staring  at the console for interesting events:
I had some time to write a small php script that will put a console.log for every method in a canjs controller.

Should save me loads of monotony when reverse engineering OPC ( other peoples code ).

Hope you find it useful:

<?php

if( !isset( $argv[1] ) )
$argv[1] = 'Storage.js';

$fileInfo = pathinfo( $argv[1] );
$outFile = $fileInfo['dirname'] . '/' . $fileInfo['filename'] . '_debug.' . $fileInfo['extension'];

$in = fopen($argv[1], 'r');
$out = fopen($outFile, 'w');

while( !feof( $in ) ){
$line = fgets($in);
if( preg_match('/:\W+function/', $line)){
preg_match("/\((.*)\)/", $line, $matches);
$function = explode(':', $line );
$functionName = trim($function[0]);

if( isset( $matches[1] ) && strlen($matches[1]) > 0  )
$line .= "\nconsole.log( '$fileInfo[filename]', '$functionName', $matches[1] )\n";
else
$line .= "\nconsole.log( '$fileInfo[filename]', '$functionName' )\n";
}
fputs($out, $line);
}

fclose($in);
fclose($out);

Posted on

CanJS is really the new hot thing in JavaScript

So its official.
I was at a Hare Krishna Temple in Silicon Valley. And while I was relaxing a bit, I overheard another pair of engineerings talking.
I couldn’t help but eavesdrop.

To my surprise, they were talking about CanJS. One of the engineers was RAVING about it to the other one. Finally I had to inject myself into the conversation and inquire as to where they worked.

And again to my surprise, they didn’t work at a large company, but a startup.
Bitovi is a name I am hearing more and more while I am up here in Silicon Valley!

Why? The simple answer, it makes things easier. You just have to write way less code. About 20% less.
It also organizes your code into better more logical, and therefore readable, structure.

So yes, thank you Brian Moschel, for JavaScriptMVC and for CanJS.

They are the IT thing in I.T. this year of our lord, 2013.

Posted on

PhantomJS + Jasmine vs Selenium Web Driver

Recently I started using phantomjs, which is a headless browser based on web-kit, for automated JavaScript testing.

Now when I was playing around with Selenium @ ABC Family, I really liked how the web driver started a browser instance and executed the test suite within it. This means Selenium is actually a better, or closer match, in terms of automated testing, because the browser is not headless. Although I don’t know all the internals of Selenium, that was my first impression.

But the positive thing about using the grunt, jasmine, phatomjs combo to run unit tests, is that we can start a jasmine server, which lets you check your code in many other browsers. That means you are not limited by the Selenium browser library of supported browsers. You can actually pick up your phone, or tablet, and point the browser to the test server, and see how your code executes on that particular system ( Device, OS, Browser). True this is not something that can be used with 100% automation on its own, but it does give you the freedom to experiment and see the behavior of code in a large variant of systems. This means that with services like DeviceAnywhere, you maybe able to cover and automate the testing of all kinds of strange fringe devices.

Something else that is interesting is that in Selenium, you can’t really hook, or spyOn member methods. While a lot of the tests written in jasmine, can be executed similarly with Selenium, because they just check for a class that has been added or removed from a DOM element, jasmine provides more integration with the code base.

The classes are loaded, along with a html fixture, and then executed. This is how the server works, by creating a #sandbox div where it loads the html fixtures for each test, loading the javascript into the page, instantiating the class, and then begins execution of the test suite. Now the opposite argument is, again, this is not how the site would be like in the wild. Other components would live on the page. So Selenium gives a more accurate assessment of how the code actually works on the end user’s system, since it loads the entire site, via a client side browser.

Now as a Computer Scientist, Java vs JavaScript argument is mute to me when it comes to choosing a “platform”. Because ultimately its like comparing apples to oranges, when you really look at the language structure and what they are designed to accomplish. Two different tools for different jobs. As a front end developer, who wants everything to be easy, there is definitely a benefit to having a unified language for creating build tools, server side applications, and user interfaces. So at some shops, where ROI is important, it’s a good idea to keep the tools all in the skill set of the human resources currently on staff. For UI people, this means JavaScript > Java. This is a good argument for using tools like grunt, and phantomjs, and jasmine, since they are all JavaScript based, they empower the new kingmakers (Open Source Developers).

Which is actually still not a big argument against Selenium Web Driver, because Java is very easy to install, you are not going to be making many changes to the driver itself, and the interface for running the Selenium Web Driver could potentially still be written in JavaScript.

Therefore the argument could be made that Selenium and Jasmine don’t have to be mutually exclusive, while it would bloat the build time to include both systems, a separate box, and process, could be used, to test with both, or the one that is missing in the build process.

While its too soon for me to say, “Dude, Selenium is old news.” I can say that all this merits more experimentation and testing. A very exciting time for Computer Scientists indeed. So much Brain Candy!

Posted on

Real Web Developers don’t do “Builds”

I don’t want to wait for some MAVEN command to execute.
I just want to refresh the browser!

So this is where Charles Proxy comes to the rescue!
The “Map to Local” feature allows you to quickly map your resources to a live implementation on a production, or development environment.

Really great feature, that saves a lot of time. Even the uploading to a generic hosting step can be skipped when doing changes to static resources. So this tool is good for Enterprises and SMBs.

Usually I would completely avoid extraneous non open source solutions. The KISS principle is something I apply not just to my coding, but to my workflow as well. Unfortunately, I don’t always get to decide what platform and workflow structure I have to interact with. And this where tools like Fiddler and Charles become indispensable in preserving my sanity.

While on the Mac environment, I am currently using Charles Proxy, Fiddler2 also provides this feature, hidden in the AutoResponder tab. Simply activate “Map URLs to local files”. And Fiddler should be able to run on Linux / Mac, although I haven’t tried it yet.

Check it out http://www.fiddler2.com/fiddler/help/video/default.asp

Posted on

Mobile Web

Today I had the pleasure of meeting Maximiliano Firtman. An amazing speaker who kept my attention the entire time.
He really validated my perspective on mobile web. That even though it’s a complete fuster cluck when it comes to devices, screens, features, and may be an exercise in complete futility because as soon as your done coding everything is going to change anyway, you still can’t idly sit back and do nothing.

Though many of my co-workers were joking that his talk made them depressed about the current state of the mobile web, I really found it enjoyable, because he echoed back many of my own viewpoints regarding Responsive Web Design, system architecture, and even how job duties or roles should be defined. And since great minds think alike, I recommend you check out his books. They will reveal lots of great resources. And illuminate niches in capturing users, and getting a better ROI, when it comes to creating a mobile version of your website.

Spoiler alert, there is no easy way to go about creating a mobile version of your site. And as craftsmen, we have to first painstakingly measure, and remeasure, before we put our tools to work. Keep in mind, this gentleman has been doing web programming since 1995, and has been a subject matter expert in mobile web design since 2000, during the days of WML, and WAP.

Posted on

Parallel Processing in PHP?

So we have this requirement in our project to start up a “thread” of execution asynchronously.

First we had to come to an agreement that it can’t be done with multi-threading, but instead has to be done with multiple processes.  We can’t have our controller executing a thread, and waiting around for it to finish in memory.

This will leave a process living on the system that we don’t necessarily need. Although now that I think about it, it may have the visual effect of fulfilling our requirement, its not a good overall design.

What we really need is to start an external process that will execute not as a child of the current process.So we have tried it a couple of different ways.

pcntl_fork which doesnt work with Apache php module, so we have to redeploy as a FastCGI.

system()  call sending the shell into the background, which seems to be not working right now.

And the two things I coded in but never tested, proc_open and popen.

Now we are not trying to achieve true parallel processing, and utitlizing the computer’s multiple processes. Just a simple outside process.

Stay tuned, we’ll let you know.

_______________

The answer was popen with &> dev/null & in the command string.