Category Archives: Stage 1

IDAT102 – Flashgame tweaking

There were a number of things with my flash game that I wasn’t completely satisfied with. One was the music which over time got annoying and inflated the filesize, this was a big problem on my current hosting so I have replaced the audio with a looping 10 second clip of silence so that the workaround still functions and I can re-add music later with ease along with a preloader.

In addition to this I also fixed a bug with the weather feed reading component in which it could not work with negative temperatures or temperatures above 9 degrees by enlarging the range for the substring part and using parseInt. I also updated it to use my new domain.

temp = weather.substring(13,15);
temp = parseInt(temp);

For its continued use I decided to make it so that the effect of temperature could be enabled or disabled by editing the Boolean value of a single variable.

var tempSwitch = false;

if (tempSwitch) {
//temperature finder stuff
} else {
temp = 10;
}

IDAT106 – Arduino and our project

It looks like it should be possible to collect bluetooth data using an Arduino board with a bluetooth shield. This would make an idea device for recording the data as it would be small and easily portable. Looking around it seems that the most common/intended usage is for the bluetooth to be sending data rather then being used to simply scan, hopefully the hardware is flexible enough to allow this. It also appears that writing to a USB stick stick shouldn’t be too difficult.

IDAT107 – 3D object

I have chosen to digitally replicate the Sony Playstation 2, the PS2 is personal to me despite being mass produced because of the many fun experiances I have had with mine. On March 4th the PS2 will be ten years old which serves as a reminder of how quickly time goes by especially in terms of computer technology.

I like the colour and almost brutalist appearance of the console which at the time set it apart from its competitors with its stylish matt black design.

I chose to display in an abstract grey void as if to document and view the object in perfect isolation. I payed close attention to detial using precise measurements so the model is accurate within 0.5mm.

To visually personalise it I added a correcting fluid name lable, as if to prevent confusion between mine and everyone else’s.

Originally I used the walkthrough assistant to have the camera fly though the gaps running along the length of the unit and then fly outwards and pan around to reveal the console. I felt that I needed to give a more gentle overview of the object which shows off its key features; so I changed the route to be an upward spiral with a target camera always facing the centre of the model.

IDAT106 – Arduino

On Wednesday we were introduced to Arduino boards are essentially general purpose programmable devices which users can experiment with and perform a wide variety of functions. Extensions known as Shields can be used to expand the unit’s functionality.

The device is programmed using a simple standardised software in a language very similar to Processing. In the session we experimented with basic programming of the device by using some code to make an LED attached to it flash on and off. I replaced the set durations with random number generating so the time delays varied. I later rewrote it so the delay between flashes would start at 1000ms and over time decend so that the rate of flashing increased.

IDAT101 – Website Tinkering

Following from suggestions from Craig Mason in IDAT101 I have tweaked my website. One of the suggestions was to change the main image on my front page from CompuServe’s .gif (Graphics Interchange Format) to the lovely, shiny and wonderful .png (Portable Network Graphics). I also resized the image to match the size that it is displayed at. In browsers with poor rendering engines, namely older versions of Microsoft’s Trident, resizing images as I had results in aliasing. So by changing the image I have avoided this scaling issue.

IDAT102 – Flash Game 0036-0040

In another separate .fla I experimented with XML importing and parsing.

I decided to use this BBC weather feed as a source of information to be brought into my game.

I using the example we were given I eventually created this:

//Plymouth temperature finder
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("http://newsrss.bbc.co.uk/weather/forecast/13/ObservationsRSS.xml"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
parseXML(xmlData);
}
function parseXML(xmlInput:XML) :void{
var weather:String = xmlInput.channel.item.description;
temp = weather.substring(13,14);
}

The second to last line places the contents of the description tags within the item tags within the channel tags in the XML document. The last line finds the 14th and 15th character of it, which should be the temperature.

I added a function to calculate the frequency the bonus balls appear:

function bonusRate():void {
if(temp < 4){
intervalBONUS = (Math.random() * 20000) + 5000;
}else{
intervalBONUS = (Math.random() * 30000) + 5000;
}
interval1 = setInterval(ballGenBONUS,intervalBONUS);
}

So if the temperature in Plymouth falls below 4 degrees centigrade then the frequency is more likely to be greater.

This code was later moved to the first frame to allow it to load before the bonusRate() function runs.

When testing the game on my server I encountered another error. Flash does not allow referencing data from different domains then the one the .swf is hosted on.

http://kb2.adobe.com/cps/142/tn_14213.html

A suggested workaround was to use a simple PHP proxy by creating a .php file with:

$dataURL = "http://newsrss.bbc.co.uk/weather/forecast/13/ObservationsRSS.xml";
readfile($dataURL);
?>

and by changing the new URLRequest link to point at the .php file hosted on my server. This solves the problem. For the hand in the game must work independently so I have made the code more resilient by defaulting the temp variable to 10.

Also making use of the temp data I have:

var dotsNumGOOD = 40 + parseInt(temp);
var dotsNumBAD = 8 + Math.ceil(parseInt(temp)/4);

So the hotter the temperature the more balls that can spawn. I took care not to unbalance the game to greatly.

In the first frame I also played around with dates.

var currentDate:Date = new Date();
var Year = currentDate.getFullYear();
if(Year > 2012){
messageTxt.text = "Looks like we made it"
}

IDAT102 – Flash Game 0030-0035

The biggest complaint I got back from people who play tested the game was that bad balls could spawn underneath the player which is unfair. So to prevent this I modified the ballGenBad function to include:

randomX = Math.random() * 800;
randomY = Math.random() * 600;
while((randomX > (ballP1.x - 100))&&((ballP1.x + 100) > randomX)){
randomX = Math.random() * 800;
}
while((randomY > (ballP1.y - 100))&&((ballP1.y + 100) > randomY)){
randomY = Math.random() * 600;
}

If the random number is in the immediate area around the player it will generate a new number until it isn’t.

In addition to this there were a number of other refinements such as seperating the hit tests for each ball type into seperate functions.

IDAT102 – Flash Game – 0026-0030

I first added sounds here but encountered a problem. Whenever a sound was played it would cause the player movement to freeze for a fraction of a second. This negatively impacted gameplay significantly. After attempting many different solutions I eventually found the problem. For some reason when a sound is first played the player must load something inorder to play sounds. Immediatly after finishing playing that sound it stops it. By running a continuous sound loop in the background this never stops, removing the freezing problem.