Posts Tagged ‘source code’

Space Shooter 2D Flash Game

Friday, November 14th, 2008

Space Shooter 2D Flash GameAs preparation to take on my new job role, I wrote a small flash game using ActionScript 3 and OOP (object oriented programming) to brush up on my flash scripting skillz.

So far, so good.  It is still a work in progress, and there are many known issues:

  • the enemy you shoot isn’t always the one that is removed from the game
  • player may leave the screen (need to add screen limits)
  • placeholder art asset for explosion & torpedoes
  • no enemy AI beyond basic movement
  • enemies pop into view rather ugly sometimes
  • ship heading is suffers from rounding errors
  • torpedo heading suffers from the same rounding errors
  • …and lots more

Features to add:

  • radar
  • lasers
  • shields
  • enemy combat AI
  • pick-ups
  • scrolling background
  • …and whatever else I find time to add

The game is composed of several class files which can easily be reused for other 2D space shooters:

  • Main.as (main game loop)
  • PlayerShip.as
  • EnemyShip.as
  • Torpedo.as
  • Explosion.as
  • UserInterface.as
  • Collision.as (code thanks to gSkinner)

You may download a full source code zip file, or play the game from here (World Building).

Rating: 0.0/5 (0 votes cast)

Tic-Tac-Toe & Prime Number Generator

Sunday, November 4th, 2007

I have written two more console apps using C++. The first is a simple prime number generator, which allows the user to choose how high to calculate to and stores them in a dynamically created array using pointers.

Prime Number Generator Executable & Source Code:
Prime Number Generator Source Code

(FINAL update (1.3) - corrected prime list generation error that wasn’t eliminating all non-primes; faster algorithm (on my dual core 64 bit Athlon 3 ghz, it calculates the first 283,146 primes (out of 4,000,000 possibles) in about 10 seconds, but it takes over a minute to display them all); ability to do 32 bit or 64 bit primality tests for extremely large numbers; menu interface added)

The second is a game of Tic-Tac-Toe against the computer. I’m fairly proud of this little program. It is about 500 lines of code, separated into an AI file, an interface file, a game logic file, and the main file. The computer opponent will test for a way to win first, and if that fails he will test for a way to block the player, finally he will perform a random move if no other strategy presents itself. Sometimes, he gets stuck on the random move selection, so I need to optimize that algorithm for a more speedy decision on where to place his O. I also need to add a decision that allows the computer to methodically place an O next to another O in preparation for a win. Right now, the only time he does that is either at random, or as a blocking move.

Tic-Tac-Toe Executable:
Tic-Tac-Toe Executable

Tic-Tac-Toe Source Code Files:
Tic-Tac-Toe Source Code

Rating: 0.0/5 (0 votes cast)