Monday, January 30, 2012

Laser Hit Detection

Squashing a lot of bugs this week, nothing new to show off. Instead of showing something new, I am going to explain how a part of the game works, namely the laser hit detection.

Most of the hit detection in the game are basic hit boxes that detect when objects overlap. This method is quick and efficient for small or basic objects, however for large or oddly shaped objects it can be inaccurate. For example, both the laser power up and the gunship's main cannon fire lasers that have an area of effect that is long but thin. Using square hit boxes for these is slow and can create many areas where the detection is off. I had to develop a better method of detection to make these power ups work.

the laser powerup
the gunship's main cannon

I decided to use as simple approach as possible. Since these objects are just straight lines, I used the tried and true y=mx+b formula from early algebra.

collision detection formula explanation (click to view)

The idea behind this is that if a formula for the laser line could be found, it could be used to find the position the ship would need to be if it were hit. If the player is within a tolerance lying on this line, a collision has occurred and the player will be hurt.

The formula is created by creating an axis centered around the point of production of the laser. This makes the "y intercept" of the line zero so it is much more manageable. The slope (m) is just a conversion of the angle the laser it at using trig functions. This leaves just the y and x variables in the equation, which we can use as a function to detect where the hit position is.

The player's x position is put into the formula at the x variable and this outputs the y position on the line where it would be it were hit by the laser. This is just compared to the actual y position with a tolerance to see if the actual ship position is within the laser's line. If it is, a hit signal is sent, otherwise it doesn't need to do anything since it missed.

This will detect a hit on both sides of the projection point, which works great for the laser powerup since it is projected in both directions but for the gunship laser it can trigger false positives. This was altered by determining which direction the gunship is facing, and then ignoring the x positions in the opposite direction. This prevents targets behind the gunship from being hit even if the laser isn't facing it.

This method detects hits for attacks based on lines and works pretty efficiently. It can be optimized further to be quicker and more accurate, but it does its job well.

Monday, January 23, 2012

Downloads and Lobby Design

I've added a new page to this site that has some wallpapers and a screensaver. Right now there are only four wallpapers and one screensaver, but I may add more later on. Let me know if you have any ideas for more downloads.

I've also been working on the lobby redesign. The current graphics are very boring and give a bad first impression to people who haven't played the game before. Having something easier to look at will generate more interest and keep people in the game longer to wait for a match.

Here's a few of the sketches I've been doing for the redesign:

Monday, January 16, 2012

AI Battle Demo

Here's another demo of the npc enemy AI. This time I have two teams, red and green, fighting in the same space with fighters and gunships. You can control how many of each ship each team has. You can't spawn too many of one thing however, because it can get extremely laggy if you do. You can override the spawn limit by holding shift before hitting "accept and restart," but you should use this at your own risk.

The auto-respawn option will cause destroyed ships to immediately respawn from their team's wormhole. This will allow the battles to continuously run, but it prevents a "winner" if you are trying to see which side will win a battle.





Here's a few interesting battle set-ups:
  • 20 fighters and 2 gunships each
  • 5-30 fighters each and no gunships
  • 10-30 fighters on one side and 2-6 gunships on the other
  • 1 fighter vs 1 fighter (they usually end up killing each other at the same time)
  • 5 gunships each and no fighters

Monday, January 9, 2012

Beta Stats

Here's some interesting stats from the beta:
  • 29 accounts were registered
  • 2815 experience points were earned by registered users
  • Highest rank achieved: level 9 by two users
  • The balanced ship was the most selected

Click to view
You can see from the chart above that the balanced ship was selected the most. This is expected, it is the most accessible and easiest to start off with. The heavy and light ships were selected approximately the same amount and at a decent proportion to the balanced ship. Using this data and gameplay data, the ships seem to fit their roles pretty well.


Click to view
The registered player ranks are shown in the graph above. Most players did not have a rank, meaning they did not earn any experience points. This usually means they created an account but didn't play a game with other players. The beta was relatively unknown so this isn't too surprising, but it shows that the game definitely needs to have players in the lobby. The rest of the ranks are pretty spread out other than ranks 1 and 2, so they are pretty well balanced. In the final version there will be many more ranks however.


    Friday, January 6, 2012

    Beta Finished

    Thanks for the help everyone, the beta has been has been a huge success, but I have to shut down the server. I have a lot to work on now and hopefully the game will be playable again soon with a lot of new updates.

    Be sure to follow the blog for updates on Nexus.

    Wednesday, January 4, 2012

    Beta Update

    I've made a few small updates to the game:
    • Fighter drones have significantly less health. They now only require three shots each to be killed.
    • Minor graphical fix in lobby stats text
    • Altered asteroid hitbox to be more forgiving (both attacking and touching)
    However I think this may cause some caching issues if your browser doesn't like refreshing flash objects. If you have this problem either clear your browser's cache or switch to a different one. I will work on a fix quickly so hopefully you won't even notice.

    Edit: I think I got it. If you get the outdated version message just refresh once or twice and it should reload fine. If you still have issues leave a comment to let me know.

    Monday, January 2, 2012

    Test Nexus Now

    The game is live, go to the Test Nexus Online above to play in your browser. The server is still somewhat slow so if you live far away from the CST time zone you may have issues playing. I will be getting a much better server soon, so bare with it for the time being. Also as I said in the previous post the server will only be up until around Saturday so play as much as you can while you still can.

    New Powerups:

    Gunship:
    Fire a large gunship enemy into your opponent's field that can fire a large particle cannon and has a defense turret in addition. If you get close to this enemy it will automatically fire its turret to keep you away, but even worse if you get within its sight it will attempt to fire its large particle cannon.

    First it uses its targeting laser to aim, then if it has a lock on it fires its primary attack.
    Aiming

    Fire!
    The beam is pretty easy to dodge, but it has a very large range so you need to be careful or you can be caught off guard. It's primary weakness is that it moves very slow, but with its heavy armor and defense turret taking it down will still prove to be a challenge.

    Spiral Shot:
    In addition to the circle shot, you can now fire a cluster of bullets through the wormhole at once to clutter your opponent's field. This attack doesn't move as fast as the circle shot so it can be more easily avoided, but it produces a larger amount of shots that need to be dodged.
    The assist powerups now are touch-activated so if you find a blue powerup grab it for immediate benefit. There are three boosts right now:
    • Health - Increases your health by one slot
    • Invincibility - creates an invulnerability ring around your ship for a short time
    • Overdrive - Massively increases your speed and fire rate for a short time
    Thanks and let me know what you think