04/1/20

Automatic Cold Frame Hinge

The goal of this project is to create a powered hinge for a cold frame or green house that automatically opens and closes based on temperature. An arduino was used for the control board to read the temperature sensor and instruct the servo motors when to operate.

Parts Used:

  • Arduino Uno or Nano
  • Servo Motor
  • 100 uF capacitor
  • 4.7k Ohm Resister
  • DS18B20 Temperature Sensor
  • I2C OLED Screen
  • 10K Potentiometer

Arduino Wiring Diagram

First prototype

3D Model of version 2

08/1/19

2D Top Down Action RPG

2D level creation with Cellular Automata and Connected Component Labeling

Worlds are generated with multiple zones and levels inside. Each level is created using Cellular Automata techniques to generate the solid parts of the terrain. Levels are currently only rectangular in size, and each level has multiple paths/doors to other levels. These paths are created randomly within a tree like structure.

Level Creation Steps:

  1. Run Cellular Automata Logic
  2. Create Border Walls
  3. Find all Open Spaces via Connected Component Labeling
  4. Create Border Doors
  5. Ensure all open spaces are accessible by the player
  6. Ensure all border doors are also accessible.

To ensure that all doors on the levels are accessible to the player, A Star path finding techniques are used after level boundaries are created and cellular automata logic is run. A Star is run between each pair of doors within a level, with weights on solid cells of the grid being very large, causing the path finding to travel through already opened areas created via the cellular automata. If a door is not accessible the path finding will remove solid cells to ensure accessibility.

Connected Component Labeling was used to ensure that all open/non solid areas of the level are accessible. Each connected open space is checked against its neighbors to ensure it is accessible by the player, path finding is then used to create a path if needed.

Goal-Driven Agent Behavior for Enemy Control

Enemy Behavior was created with a design pattern found in the book Programming Game AI by Example . This allowed each enemy to have emergent behavior based on various goals and conditions of the game world. Goals and actions included keeping rooms cleared of enemies, avoiding attacks, seeking out health, etc.

References:

06/1/19

Spaceship Building and Command RTS Game

Game concept: Starting with a base mothership that allows the player to create collector ships to collect resources. With these resources, ship attachments can be made including defensive systems, weapons, armor, fuel, batteries, etc. Ships are limited by the power generation, create a challenge to manage building out the ship, traveling to collect resources, firing weapons, and high speed assault maneuvers.

Techniques Used:

  • Goal-Driven Agent Behavior for enemy movement and ship construction
  • Messaging to support disparate game actor communication with Goal-Driven Agents
  • Object Pooling for projectiles
  • Unity’s Physics and collision detection to support movement, collisions, and ship building.

References:

03/1/19

Side Scroller Action Shooter

Techniques Used:

  • Object Pooling for projectiles and short lived objects.
  • Different camera logic for levels to provide a different feel.
    Locked camera for boss fights and puzzle areas.
    Moving camera for long exploratory areas.
    Camera on “rails” that ensures camera moves with player but stays within level bounds to give a more predictable camera location, and prevent excessive dead areas on screen.
  • Custom built character controller to get very precise 2D movement.
  • Parallax Image techniques to show movement on 2D landscape.

02/22/18

Electric Bike Build

Built battery pack with 18650 cells in 14 serial 8 parallel configuration driving a Bafang mid drive kit.

07/8/16

Retrieve parameterized triggered build display name with groovy script

Using the groovy plugin and Jenkins Parameterized Trigger plugin, we can create a groovy script that retrieves the previous triggered build number from the environment variables set by the Parameterized Trigger plugin, then use the groovy plugin to lookup the displayName for the build (assuming the display name is different using Build Name Setter Plugin).

The display name in my case will be the git hash/revision that was built in the previous step.

import hudson.model.*
  def previous_build_number = build.getEnvironment(listener).get("TRIGGERED_BUILD_NUMBER_Build_byGitHash")
  out.println(previous_build_number)
  def previous_git_hash = jenkins.model.Jenkins.instance.getItem("Build-byGitHash").getBuildByNumber(previous_build_number.toInteger()).displayName

def pa = new ParametersAction([
  new StringParameterValue("PREVIOUS_GIT_HASH", previous_git_hash)
])

// add variable to current job
Thread.currentThread().executable.addAction(pa)

 

05/21/13

Shaded Jar with Maven

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <version>1.5</version>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
        <goal>shade</goal>
      </goals>
      <configuration>
        <transformers>
          <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
            <manifestEntries>
              <Main-Class>Fully Qualified main class here</Main-Class>
            </manifestEntries>
          </transformer>
          <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
            <resource>META-INF/spring.handlers</resource>
          </transformer>
          <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
            <resource>META-INF/spring.schemas</resource>
          </transformer>
        </transformers>
      </configuration>
    </execution>
  </executions>
</plugin>

01/18/13

Insert SVN Revision Number into MANIFEST.MF

<project>
  <scm>
    <connection>scm:svn:http://svn/folder</connection>
    <developerConnection>scm:svn:http://svn/folder</developerConnection>
    <url>http://svn/folder</url>
  </scm>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>buildnumber-maven-plugin</artifactId>
      <executions>
        <execution>
          <phase>validate</phase>
          <goals>
            <goal>create</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <doCheck>false</doCheck>
        <doUpdate>false</doUpdate>
      </configuration>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
          </manifest>
          <manifestEntries>
            <SCM-Revision>$&;{buildNumber}</SCM-Revision>
          </manifestEntries>
        </archive>
      </configuration>
    </plugin>
  </plugins>
</project>

10/31/12

jConsole with Java 1.5

Start java application with the following arguments
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=<port>
-Dcom.sun.management.jmxremote.authenticate=false

Run jconsole from the command line pointing the to PID of the java process

jconsole <PID>

for example
jconsole 1234

10/5/12

jMeter – Regular Expression Extractor – Submit Form with Token

Problem:
Create a load test that submits a web form containing a unique token to prevent multiple form submissions.

Solution:
jMeter 2.6
Use jMeter Regular Expression Extractor ( Found in Right Click Menu >> Add >> Post Processors >> Regular Expression Extractor)

How To:
On http request 1 there will be a hidden input field that contains the token to be submited.
On http request 2 we will need to place this token value.

On http request 1, add a regular expression extractor with the following values.

Reference Name:TOKEN
Regular Expression:name=”TOKEN” value=”(.+?)”>
Template:$1$
Match No:1
Default Value: NOT FOUND

On http request 2 insert the token value into the paremeters section with the variable ${TOKEN}

08/7/12

Java – Byte Array to Hex String

Another Quick Reference Code Snippet


StringBuilder tempString = new StringBuilder(2 * bytes.length);
    for (byte b : bytes) {
      tempString.append(&#8220;0123456789ABCDEF&#8221;.charAt((b &#038; 0xF0) >> 4));
      tempString.append(&#8220;0123456789ABCDEF&#8221;.charAt((b &#038; 0x0F)));
    }
    return tempString.toString();

Source:
http://stackoverflow.com/questions/5470219/java-get-md5-string-from-message-digest

07/14/12

Added Simple Enemy AI and Zombies

07/6/12

Game Update

Added Working Turrets that shoot.
All entities have health, when they run out of health they are removed from the scene.
Sounds are activated when the player or the turret shoots as well as on projectile impact.

07/3/12

Slick2d Game Engine Animation Example

Using the Slick2d game engine there are multiple ways of creating animations.
The following examples will do the same exact thing, but its two different ways of writing it.

Imports
import org.newdawn.slick.Animation;
import org.newdawn.slick.SpriteSheet;

Example 1
SpriteSheet runningSS = new SpriteSheet("/path/to/sprite.png", 24, 32);
Animation runningAnimation = new Animation();
runningAnimation.setAutoUpdate(true);
runningAnimation.addFrame(runningSS.getSprite(0, 0), 100);
runningAnimation.addFrame(runningSS.getSprite(1, 0), 100);
runningAnimation.addFrame(runningSS.getSprite(2, 0), 100);

runningSS.getSprite(1, 0) is not the pixel value, but the sprite location if the whole image were broken up into cells based on the width and height defined when creating the sprite sheet

Example 2
SpriteSheet runningSS = new SpriteSheet("/path/to/sprite.png", 24, 32);
Animation runningAnimation = new Animation(runningSS, new int[]{0,0,1,0,2,0}, new int[]{100,100,100});

This example is for slick build 274

07/2/12

Run Maven with Ant

Run Maven with Ant

If you have the option to remove Ant from your projects its probably easier to just use maven for most of the build process, but sometimes it requires too much work and time, so this is a quick solution to have your Ant script run maven.

<exec executable="cmd">
<arg value="/c" />
<arg value="mvn package -e -f path/to/pom.xml " />
</exec>

Maven command to skip tests

-Dmaven.test.skip=true

07/2/12

Deploy to Local Maven Repository

Deploy Snapshot or release jar to Local Maven Repository

In Settings.xml

<settings>
<servers>
<server>
<id>releases</id>
<username>username</username>
<password>password</password>
</server>
</servers>
</settings>

In pom.xml


<distributionManagement>
<repository>
<id>releases</id>
<url>http://server/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://server/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

07/1/12

Copy Maven Dependencies to target folder

The following maven xml will retrieve all the maven dependencies and copy them to the target/lib folder.

<plugin><!-- Copy maven dependencies to the lib folder -->
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>copy-dependencies</id>
      <phase>generate-resources</phase>
      <goals>
        <goal>copy-dependencies</goal>
      </goals>
      <configuration>
        <encoding>UTF-8</encoding>
        <outputDirectory>target/lib</outputDirectory>
        <overWriteReleases>false</overWriteReleases>
        <overWriteSnapshots>false</overWriteSnapshots>
        <overWriteIfNewer>true</overWriteIfNewer>
      </configuration>
    </execution>
  </executions>
</plugin>

07/1/12

Add external jars to runnable jar’s manifest file using maven

Add external jars to runnable jar MANIFEST.MF file using maven

Also package project as a runnable jar with the specified main class

<plugin><!-- Set Main class and location of jars to add to the manifest classpath -->
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <archive>
            <manifestEntries><!-- Add manifest Classpath entries that aren't managed by maven -->
              <Class-Path>lib/pojoxml-1.0.jar lib/lwjgl.jar lib/jorbis-0.0.15.jar lib/jogg-0.0.7.jar lib/natives-win32.jar lib/slick.jar</Class-Path>
            </manifestEntries>
            <manifest>
              <addClasspath>true</addClasspath>
              <classpathPrefix>lib</classpathPrefix>
              <mainClass>com.porto.game.game2d.GameMain</mainClass>
            </manifest>
          </archive>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
      </plugin>

07/1/12

Packaging External Jars with Maven

<plugin><!-- Copy Dependencies - NonMaven Jars -->
  <artifactId>maven-resources-plugin</artifactId>
  <version>2.5</version>
  <executions>
    <execution>
      <id>copy-resources</id>
      <phase>generate-resources</phase>
      <goals>
        <goal>copy-resources</goal>
      </goals>
      <configuration>
        <encoding>UTF-8</encoding>
        <outputDirectory>target/lib</outputDirectory>
        <resources>
          <resource>
            <directory>lib</directory>
            <filtering>false</filtering>
          </resource>
        </resources>
      </configuration>
    </execution>
  </executions>
</plugin>

If filtering is set to true, Maven will parse the file using the encoding and rewrite it, I have found that his can cause all sorts of issues including class not found errors.

06/5/12

Collision Map and Render Image

I have updated the level collision detection code to support two images, one image (bottom) that is actually rendered to make up the level, and the second image (top) that tells the collision block creation code what type of collidable object to make.
In this case, anything transparent is non-collidable, anything black is solid and can’t be destroyed and anything red is collidable and can be destroyed.