ActionScript 3 - Using References to Improve Game Performance
Jun 24, 2011Programming
I couldn't think of an easy way to explain references (or pointers), so I'm going to jump right in with examples.
Continue Reading ›
Fast Unit Vector Calculation for 2D Games
Jun 17, 2011ProgrammingComments (3)
Here's a quick description of a unit vector for those that don't know. A unit vector is a vector with a magnitude (distance) of 1. The vector can be pointing in any direction, but the magnitude will always be 1. To get a unit vector from any old vector, you "normalize" that vector, which gives you a new vector with the same direction but a magnitude of 1. Unit vector and normalized vector are often used interchangeably.
Continue Reading ›
ActionScript 3 Semi-Transparent CopyPixels
May 31, 2011Programming
When working with BitmapData and copyPixels, you'll quickly run into the limitation of not having an alpha attribute with which to change the transparency level of objects. If you're like me, you started out using Sprite and MovieClip in your games and could easily fade-in or fade-out objects using the alpha attribute. Unfortunately, BitmapData does not have the alpha attribute, so how do you adjust transparency dynamically while using copyPixels?
Continue Reading ›
ActionScript 3 Semi-Transparent BitmapData, ARGB
May 31, 2011ProgrammingComments (1)
Creating semi-transparent BitmapData in ActionScript 3 is done using an ARGB hexadecimal value (32-bit). ARGB stands for Alpha-Red-Green-Blue and is just like an RGB hex value but with an alpha level at the beginning. Due to the alpha level, ARGB hex values are 8 hex digits and not 6. If you aren't familiar with hexadecimal, I suggest reading up on it before continuing.
Continue Reading ›
Beginner JSON Guide/Tutorial (JavaScript, PHP, AJAX)
May 17, 2011ProgrammingComments (2)
JSON stands for JavaScript Object Notation. It is a widely-used model for transferring variable data as text, and is often used in combination with AJAX to create the basis for highly-interactive, portable, and modular websites (Facebook, Twitter, etc).
Continue Reading ›
Beginner AJAX Guide with GET and POST Examples
May 12, 2011ProgrammingComments (5)
AJAX allows you to update parts of a page with server-side content using JavaScript, without reloading the whole page. AJAX is not a new language, but rather a method for using JavaScript to achieve this functionality.
Continue Reading ›
Using CSS for printable documents instead of a separate print page (website)
Mar 24, 2011Programming
Many websites have a print link that opens up documents in a separate window with special formatting for print. This works, but often times you can achieve the same result using CSS and the media="print" attribute. What I generally do is specify two external stylesheets, one for media="all" and one for media="print". For example:
Continue Reading ›
Actionscript 3 Beginner Introduction to Package and Classes
Mar 10, 2011ProgrammingComments (5)
Most Flash Actionscript 3 developers start out by writing code directly into the Actions window (F9), or into a separate .as file and using include to include that code into the Actions window. This works fine for simple programs, but to get the most out of Flash and Actionscript 3 you should learn how to use Packages and Classes.
Continue Reading ›
MySQL Full-Text Search PHP Tutorial
Feb 22, 2011Programming
MySQL's full-text search allows you to quickly search a table for single or multiple keywords from multiple columns. It does this by using an index on the columns that you want to search. There are a few limitations that you should know of. Indexed columns can only be CHAR, VARCHAR, or TEXT, MySQL does not by default index words that are less than 4 characters, and any word that appears in over 50% of rows is excluded from the results. There are also stop words.
Continue Reading ›
Actionscript 3 Passing Variables from HTML to Flash (FlashVars, Query String)
Jan 17, 2011ProgrammingComments (1)
Passing variables to a Flash movie that is embedded in a web page can be done using either the query string or FlashVars. The difference between these methods is that using query string will cause browsers to re-download the Flash movie each visit, while FlashVars allows browsers to use the cached version. Depending on the functionality you want, one method may suit you better than the other.
Continue Reading ›
Actionscript 3: Faster Math.floor and Math.ceil using int typecast
Nov 19, 2010ProgrammingComments (2)
In order to use int typecasting in place of Math.floor or Math.ceil, you must first understand exactly what these functions do: Math.floor takes a number and returns the next lowest whole integer. Passing 0.9 will return 0 and -0.9 will return -1. Math.ceil returns the next highest integer, so will return 1 from 0.9 and 0 from -0.9. This is different than truncating, which would return 0 in all cases, and is why typecasting using int (usually used to truncate) wouldn't seem to work at first.
Continue Reading ›
Bounding Box vs. Bounding Circle Collision Detection Performance AS3
Nov 17, 2010ProgrammingComments (1)
Before doing more complex collision detection in a game, it is useful to first check and make sure a larger bounding area is colliding. This is so that only one calculation needs to be done for each collision detection most of the time, and then further collision detections are only done if objects are close and potentially colliding.
Continue Reading ›
Fast Distance Threshold Formula AS3, C++, Java, Python
Nov 17, 2010Programming
Most game programmers are familiar with the distance (magnitude) equation and how inefficient it is. Using a square root is a costly function that usually can't be afforded many times per frame. Here is a much more efficient distance equation for situations in which you want to check the distance against a threshold (such as determining if two bounding spheres collide).
Continue Reading ›
Actionscript 3 Code Performance Tips & Testing
Nov 16, 2010ProgrammingComments (1)
In Actionscript 3 there are usually different coding methods to achieve the same output (this can be said of any programming language). Variables can be declared in different ways, math equations can be performed in different ways, you can move code into functions, perform things on single lines or multiple lines, and so on and so forth. While different methods may achieve the same output, certain methods are often faster than others. This post is dedicated to finding as many performance tweaks and enhancements as I can, and I will update it as I find more.
Continue Reading ›
NewerPage 4Older