Online Multiplayer Snakes & Ladders

I had previously blogged about the Snakes & Ladder Game I had created. That was a multiplayer game but was not an online game – i.e. multiple people could not play the game together remotely. I had planned to make a true online and multi-player version of the game since I created the earlier version. In the last few days, I have made sufficient progress on the online version of the game, that I can share it with you. Please watch the demo of the game below.

Since I am using the same server for the backend of the game as the one hosting my blog, I have limited the number of simultaneous sessions. There is also the session timeout of 10 minutes, if there is no activity in the session.

Creating the online version was certainly more complicated than the standalone version – I had to implement the backend logic to create and manage sessions and implement a broker to facilitate messages/events to and from multiple players. But I have done sufficient server-side programming in the past and was able to implement that part of the game fairly quickly. However, implementing the game client in Unity took some time. Implementing messaging protocol, making sure the UI is updated from multiple event handlers in the UI thread and in general synchronizing parallel event handling took some time. But overall, it was a great learning experience.

You can access the same at http://ramkulkarni.com/Games/Multi-SNL/. Try this on your desktop or laptop computer and not on mobile. It is not optimized for mobile and will not work properly.

-Ram

Snakes & Ladders Game

I have implemented another game using Unity, after my first Unity game, Single Wicket Cricket. The new game is Snakes & Ladders. You can watch demo of the game in the following video.

You can play the game at http://ramkulkarni.com/Games/SNL. Though the game is multi-player, it is not truly online multi-player game. I do intend to work on that in future. Also, the game is not optimized for Mobile. It does not display correctly in portrait mode in the mobile browser and text input field does not trigger virtual keyboard. But it should work fine in non-mobile browsers, so give it a try.

-Ram Kulkarni

My blogs/videos on Adobe Animate

I managed Adobe Animate team for a couple of years and during that time wrote a few blog articles and created feature videos. These articles and and videos were published on Adobe blog and Animate YouTube channels. Here I am just providing links to them –

Blogs:

  1. Adding Interactivity to VR-360 Content in Animate 2019
  2. Creating VR-360 Content with Animate 2019
  3. Exporting glTF from Animate

Download links for FLA files in the above blogs are no longer working. But you can download them from –

Videos:

  1. HTML5 Canvas Game – A playlist of 5 videos
  2. Creating picture puzzles with Animate

-Ram Kulkarni

Single Wicket Cricket – A 3D Game

I tried my hand at a low-poly 3D game development with ‘Single Wicket Cricket’ game. This is not a typical Cricket where two teams play against each other. In this game you are the main player – the batsman, playing against a team.

Video demo of Single Wicket Cricket game

Tap/click Bowl to start bowling action. You will be able to ‘Hit’ the ball once it is released by the bowler. You will be able take a ‘Run’ only if bat touches the bat, so there are no byes or leg-byes.

By moving different sliders you can control position, rotation of the batsman, strength and direction (up/down) of the stroke. Tap/click ‘Help’ button for more details.

The game is available to run in Web Browser or as a standalone application on Android devices.

Click here to play the browser based version of this game. Or type http://ramkulkarni.com/Games/Cricket in the address bar. Make sure to run the game in Landscape mode for the best experience.

Click here to go to Google Play listing of this app. Or search ‘Single Wicket Cricket’ in the Google Play app.

-Ram Kulkarni

Third Edition of My Book ‘Java EE 8 Development with Eclipse’ Published

 

Third edition of my book ‘Java EE 8 Development with Eclipse‘ is now published.

I had completely re-written the previous edition of this book. The third (current) edition has three new chapters –

Chapter 12Microservices, describes how to develop and deploy microservices. It also covers the deployment of microservices in Docker container.

Chapter 13Deploying JEE Applications in the Cloud, describes how to deploy JEE applications in Amazon and Google Cloud platforms. Specifically, it describes the deployment of applications in AWS EC2, Beanstalk, Google Compute Engine, and Google App Engine. It also describes Eclipse tools that can be used for deployment to the Cloud.

Chapter 14Securing JEE Applications, describes how to secure JEE applications using authentication and authorization features of JEE containers. It also covers some of the JEE 8 security enhancements.

You can find more information about outline of each chapter at https://www.packtpub.com/mapt/book/application_development/9781788833776

– Ram Kulkarni

Fixing “:CFBundleIdentifier, Does Not Exist” Error in React Native iOS build

After spending a couple of hours trying to debug this issue, I thought I would write about the solution that worked for me. Here are some of the possible solutions I found on the web –

  1. Make sure 8081 port is free and not taken by any application. On Mac you can check this by running command lsof -i :8081. If any process is running then kill it – kill -9 <pid>
  2. Remove spaces from the folder path of the project
  3. Run react-native upgrade in the project folder

In my case the problem was #1. However simple lsof command did not show any process. But sudo lsof -i :8081did show the process. It turned out that McAfee agent was running on the same port. Killing the agent is not an option for me. So the next thing to do was find a way to change the port of Ract-Native packager.

Following steps worked for me –

  1. Opne node_modules/react-native/local-cli/server/server.js and change port 8081 to the port you want to run the packager on. In the version of React-Native I am using, it is in the following code –
    module.exports = {
      name: 'start',
      func: server,
      description: 'starts the webserver',
      options: [{
        command: '--port [number]',
        default: 8090,
        parse: (val: string) => Number(val),
      },
    
  2. Change references to port 8081 in following files –
    1. node_modules/react-native/Libraries/Core/Devtools/getDevServer.js
    2. node_modules/react-native/React/React.xcodeproj
    3. node_modules/react-native/React/ReactLegacy.xcodeproj
    4. node_modules/react-native/React/Base/RCTBundleURLProvider.m

If above changes do not fix the problem, you may want to try replacing all references to port 8081 in the files in node_modules/react-native folder.

Wish Facebook makes changing packaging port easier than the above process.

-Ram Kulkarni

Setting up and Debugging PHP7 in Docker

Before developing applications in any new language/platform I make sure that the debugger works in the set up. I had been working on some projects in Python and PHP recently and I have already shared my notes on setting up and debugging Python (Django) application in Docker and how to debug the application.

In this post I will describe how to setup PHP7 in Docker and debug the application. You can checkout the project from this Github repo.

Here is the Docker file for this setup –

FROM php:7.0.17-apache

RUN apt-get update
RUN apt-get install -y apt-utils vim curl sqlite3
RUN pecl install xdebug
# copy test db file
ADD ./db/employee.db /employee.db
# The base image does not have php.ini. 
# Copy our own, with xdebug settings
ADD ./php.ini /usr/local/etc/php/

EXPOSE 80

The container is based on php image from docker hub. The version number is 7.0.17-apache. This example uses Sqlite3 database, so the package is installed.

To debug PHP applications, you need to install xdebug. In the docker file it is installed using pecl. Then employee.db (Sqlite3 DB) is copied from the project folder to the root of docker container.

Continue reading “Setting up and Debugging PHP7 in Docker”

Remote Debugging Django Project in Docker

In the last post I described how to setup Django and Apache in Docker container. In this post I will describe how to remote debug the Django application running in the same setup. If you look at the Dockerfile of the project (in the last post), you would see that it installs ptvsd package – this package helps to debug Django applications running remotely using Visual Studio Code.

Install Visual Studio Code, if you haven’t installed it already. Then install VS Code extension for Python. I have installed this extension by Don Jayamanne, and it supports debugging of Python applications. If you don’t know how to install extensions in VS Code, this video might help you.

To enable remote debugging of Django application, or Python applications in general, you need to run ptvsd server on the machine where Django is configure, which in our case is a Docker container. You need to embed following code snippet in your Django app, and it needs to run only once, because it listens to a port.

import ptvsd

ptvsd.enable_attach("my_secret", address = ('0.0.0.0', 3500))

The above snippet starts ptsvd server, that listens on port 3500. We configured Python to run in Apache2 using mod-wsgi in the Docker container, but I haven’t found a way to embed the above code in a Django application in this setup, where it would run only once (if it is run multiple times, it will try to attach to the same port and that would fail). So far the best way I have found to debug Django application remotely in Docker is to start Django development server on a different port (than one where Apache is listening) and embed the debugger code in manage.py. You run the development server by running manage.py, for example – Continue reading “Remote Debugging Django Project in Docker”

Docker project for Python3, Django and Apache2 setup

I was working on a Django project and it took me some time to make Django work with Apache2. So I thought I would create a Docker project for this setup. You can find the project at https://github.com/ramkulkarni1/django-apache2-docker. It sets up Python3, Django, Apache2 and a sample Django site too.

All configurations for making Django work with Apache2 are created when you create a Docker container using this project. Simply run following command from the project folder.

$ docker-compose up

(See my post Docker Notes on information about setting up Docker and docker commands). One the container is up, browse to http://localhost:8005.

Here is a quick summary of what Dockerfile does – Continue reading “Docker project for Python3, Django and Apache2 setup”

Docker Notes

I recently started using Docker and am very impressed with how easily you can set up environment to develop, test and deploy applications. It provides a virtualization environment, but unlike some of the other virtualization solution, Docker container  (runtime environment for your application)  is a process instead of a complete OS. It runs natively on Linux and uses a single virtual machine on Windows and Mac in which Docker containers run.

Using Docker you can easily create containers required for your application to run, for example containers for database, application server etc and easily deploy them to test or production environment. You can create images of your set-up and re-create the same setup constantly from those images. When you create a Docker image, it has to be based on some variant of Linux base image. You can browse Docker images at Docker Hub.

This post is not meant to be tutorial or detailed information about Docker. You can refer to Docker web site for that. As many of my other posts, this post is meant to be reference for me – about some of the Docker commands I have used so far. Continue reading “Docker Notes”