Archive for August 2007

ActionScript based clock

a simple analog clock based on shapes.

download

all the ActionScript is all contained in a single file: Clock.as
this is added into the movie with #include “Clock.as” on the frame level

if there is interest, I’ll rewrite this as an object, add a few more options, and improve the script a bit.

it can be made small
(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

or large
(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

Method to get data of a single wordpress post

function get_post_content($id) {
	global $wpdb;
	$query =
		" SELECT ID, post_title, post_excerpt, post_content, post_content_filtered "
		."FROM $wpdb->posts "
		."WHERE ID = '$id'";
	$pages = $wpdb->get_results($query);
	if( ! empty($pages) && isset($pages[0]) ) {
		//echo( 'Title: '.$pages[0]->post_title."\n" );
		//echo( 'ID: '.$pages[0]->ID."\n" );
		return $pages[0]->post_content;
	}
	return '';
}

note that this method does not distinguish between posts that have or have not been published, this allows the content of an unpublished post to be used eleswhere.

AVR Toolchain - Build 2006-02-06

Documentation

AVR Toolchain Build Tests

AVR Libc User Manual

 

Downloads


AVR-Toolchain - 2006-02-06 Build Binary Package - No Docs


AVR-Toolchain - 2006-02-06 Build Binary Package

 

Notes

the single greatest number of “bug” reports we get are due to the user not setting the env variable AVR.

on a linux system:

export AVR=/usr/local/avr (or wherever you've installed it, $HOME/avr, /opt/avr, etc )
export AVRROOT=$AVR
export AVRBIN=$AVRROOT/bin
export AVRLIB=$AVRROOT/lib/avrlib
export PATH=$AVR/bin:$PATH

these can be placed in your ~/.bashrc file
of course, the $AVRROOT should be where the user has placed the toolchain and avrlib ( /opt/avr and ~/avr are popular too )
there is a generated rc file in the root of the install dir as well, it can be modified to suit.

From avr-as –help

AVR options:
  -mmcu=[avr-name] select microcontroller variant
                   [avr-name] can be:
                   avr1 - AT90S1200, ATtiny1x, ATtiny28
                   avr2 - AT90S2xxx, AT90S4xxx, AT90S8xxx, ATtiny22
                   avr3 - ATmega103, ATmega603
                   avr4 - ATmega83, ATmega85
                   avr5 - ATmega161, ATmega163, ATmega32, AT94K
                   or immediate microcontroller name.
  -mall-opcodes    accept all AVR opcodes, even if not supported by MCU
  -mno-skip-bug    disable warnings for skipping two-word instructions
                   (default for avr4, avr5)
  -mno-wrap        reject rjmp/rcall instructions with 8K wrap-around
                   (default for avr3, avr5)
Known MCU names:
  avr1 avr2 avr3 avr4 avr5 at90s1200 attiny10 attiny11 attiny12 attiny15
  attiny28 at90s2313 at90s2323 at90s2333 at90s2343 attiny22 attiny25
  attiny26 attiny45 attiny85 at90s4433 at90s4414 at90s4434 at90s8515
  at90s8535 at90c8534 at90pwm2 at90pwm3 at86rf401 attiny13 attiny2313
  attiny261 attiny461 attiny861 attiny24 attiny44 attiny84 atmega603
  atmega103 at43usb320 at43usb355 at76c711 atmega48 atmega8 atmega83
  atmega85 atmega88 atmega8515 atmega8535 atmega16 atmega161 atmega162
  atmega163 atmega164 atmega165 atmega168 atmega169 atmega32 atmega323
  atmega324 atmega325 atmega329 atmega3250 atmega3290 atmega406 atmega64
  atmega640 atmega128 atmega1280 atmega1281 atmega644 atmega645 atmega649
  atmega6450 atmega6490 at90can32 at90can64 at90can128 at94k

Basic “getting started” needs

  • a few AVRs
  • a compiler/linker
  • a mechanism to upload/download to/from the microcontroller
  • breadboard
  • a power supply
  • various components ( LEDs, resisters for said, ect )

AVR Toolchain - Build 2006-02-06 - AVR-Libc User Manual

AVR Toolchain - Build 2006-02-06 - Build Tests

Renderings of the Puzzle-Box From the Hellraiser Series

an initial rendering to check for lighting and placement


 
 
after rebuilding and cleaning the meshes (and a few tweeks on lighting)

 
 
more streamlining of the meshes and animation, and if it were constructed of aluminum.

 
 
the textures are tedious, excessive time must be spent either setting them up within Blender, or designing them outside of it.
given that it is far too easy (for me at least) to do something horribly wrong while editing the maps within Blender, I chose a method using the “excessive design” approach. the map specifics are exported to SVG, then edited, then converted to PNG via a script for Blender to import.
I’ve also divided the meshes a bit more, and added more animation.

a Flash dice roller

a Flash dice roller using custom-rendered virtual dice.
(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

of course, this could be customized to match a particular sort of roll and style of game.
the next version contains the ability to set all of the attributes from the HTML page, and to send the results back to it’s containing HTML page.

for example, in firewater productions’s game “Chaos University”, the standard is 5 dice:
(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

Flash loading progress animations

a simple image vewer, mostly put together to test transition effects and loading progress animation.
note: none of the viewers will ever load anything, the xml media list has only one dummy entry (to force it to continuously show the loading progress animation).

a shape based animation

an iconic clock, another shape based animation

a graphic based animation, this uses a single image, an offset, and a mask

a graphic based animation, this rotates a single image

A simple Flash game

a simple flash game thrown together quickly for the sole purpose of testing an ActionScript library.

Freya’s Rune

a simple bindrune done with svg.

Example of a Flash application passing data to the containing page

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque sollicitudin accumsan est. Sed volutpat elit ut diam. Mauris placerat placerat sem. Nullam non pede eget tellus adipiscing tempor. Duis ullamcorper. Cras sem justo, lacinia a, tempus vel, facilisis in, dui. Mauris eros erat, ultricies non, mattis nec, pulvinar at, libero. Proin purus. Donec interdum. Nam consequat dui. Ut nec leo. Nulla purus est, rutrum et, pretium ut, lacinia sollicitudin, felis. Nulla facilisi. Aliquam nibh eros, tempor vel, tincidunt eu, luctus id, metus. Praesent pellentesque.
This text is replaced by the Flash movie.

Flash Player and and a Javascript capable browser are requred.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque sollicitudin accumsan est. Sed volutpat elit ut diam. Mauris placerat placerat sem. Nullam non pede eget tellus adipiscing tempor. Duis ullamcorper. Cras sem justo, lacinia a, tempus vel, facilisis in, dui. Mauris eros erat, ultricies non, mattis nec, pulvinar at, libero. Proin purus. Donec interdum. Nam consequat dui. Ut nec leo. Nulla purus est, rutrum et, pretium ut, lacinia sollicitudin, felis. Nulla facilisi. Aliquam nibh eros, tempor vel, tincidunt eu, luctus id, metus. Praesent pellentesque.
This text is replaced by the Flash movie.

Flash Player and and a Javascript capable browser are requred.

Method to draw an ellipse

Notes:
as this method uses a series of lines to construct the curve, a low angular change will result in a smoother curve. however, if a higher value is used, this will construct what appear to be “warped” polygons. for example, an angular change of 45 degrees (Pi/4 rad) will give an eight sided polygon. changing the dx and dy will still result in an elliptical shape.

ActionScript:

with( MovieClip_Object ) {

	//center of ellipse
	var x0 = Stage.width/2;
	var y0 = Stage.height/2;
	//ellipse bounds
	var dx = 300;
	var dy = 100;
	//angular change
	var dn = 1 * (Math.PI/180);

	var r,x,y;
	lineStyle(1, 0x000000);
	for( var n=0; n<2*Math.PI; n+=dn ) {
		x = dx*Math.cos(n);
		y = dy*Math.sin(n);
		moveTo(x0+x,y0+y);
		x = dx*Math.cos(n+dn);
		y = dy*Math.sin(n+dn);
		lineTo(x0+x,y0+y);
	}

}

Bobble Head

A rather silly “bobble head” animation

in this version, the backend bases the force to apply on the number of clicks, it is also possible to base the force applied on the distance the head is dragged, or on length of time the head is clicked.

Simple Trig With ActionScript

angle conversion:

var angle_deg = angle_rad * 180/Math.PI;
var angle_rad = angle_deg * Math.PI/180;

find (x,y) from angle and radius:

var x = radius * cos( angle_rad );
var y = radius * sin( angle_rad );

a minor issue you will come across in ActionScript is that all of trigonometry functions in Math are based on the angle in radians, and a MovieClip’s _rotation property is based on the angle in degrees (this is not a bug or a flaw, but rather a design decision).

so a bit of simple algebra…

using a ratio:

angle_in_degrees/degrees_in_a_rotation = angle_in_radians/radians_in_a_rotation

one full rotation from origin to origin is 360 degrees or 2π radians:

plugged into the ratio:

angle_in_degrees/360 = angle_in_radians/2π

and solving for either variable:

angle_in_degrees/360 = angle_in_radians/2π

( angle_in_degrees/360 ) * 360 = ( angle_in_radians/2π ) * 360

angle_in_degrees = ( angle_in_radians * 360 ) /2π

angle_in_degrees = ( angle_in_radians * 180 ) /π

angle_in_degrees = angle_in_radians*180/π

and

angle_in_radians/2π = angle_in_degrees/360

( angle_in_radians/2π ) * 2π = ( angle_in_degrees/360 ) * 2π

angle_in_radians = ( angle_in_degrees/360 ) * 2π

angle_in_radians = ( angle_in_degrees/180 ) * π

angle_in_radians = angle_in_degrees*π/180

  • Categories

  • Need Code Written?

  • Need a Coding Job?

  • Tags

  • Archives