The 2DIY script archive

A resource containing Actionscript examples for 2Simples 2DIY software.

  • ActionScript
  • Animation Script
  • Collision Script
  • Start Button Script
  • Examples
  • Ideas
  • Help/Videos
  • Discuss

Games Pod Creations

Kensington Avenue Primary School have completed their 'Games Pod' workshops. Look at all the amazing games that the children have created;

Download Y4 Ali Rauhaan | Download Y4 Batool Mannahil | Download Y4 Brano Areej

Apple

Download Y4 Gershom Jay |  Download Y4 Hazal Hannah |  Download Y4 Jordan Kelly

Monster

Download Y4 Lia Nilofar | Download Y4 Maleeha Shantay catching 

Apple

Download Y4 Maleeha Shantay platform | Download Y4 Mubeen Luhan

Monster

Download Y4 Pratik Kofi | Download Y4 Sabah Sophie

Apple

Download Y4 Yasmin Helin | Download Y4 Zara Chanel 2 | Download Y4 Zara Chanel

Monster

Download Y4 Zaynab | Download Y6 Ajwadul Jamil | Download Y6 Akhil Tamoor

Apple

Download Y6 Andrew Y4 Rameses | Download Y6 Humayun Y4 Aniq

Monster

Download Y6 Jade Kiera | Download Y6 JamesG Ahmed | Download Y6 JamesR Kallum

Apple

Download Y6 Jhulian | Download Y6 Khalid Rumal | Download Y6 Lauren Shamem

Monster

Download Y6 Monica Chyna | Download Y6 Muhammad Esa | Download Y6 Petra Mohema 

Apple

Download Y6 Rachel Y4 Hannah | Download Y6 Ray Kieran | Download Y6 Reece Tristan

Monster

Download Y6 Sosan Lauren | Download Y6 Taalib | Download Y6 Taianne Krystyna

Well done to all, and to their teacher, Miss Lotriet, who had the idea for 'Games Pod'

Posted by Xannov in 2DIY Examples | Permalink

Reblog (0) | | Digg This | Save to del.icio.us |

Kensington Avenue Primary 'Games Pod'

It's good to see more and more schools introducing their children to 2DIY. Miss Lotriet, from Kensington Avenue Primary School writes;

"Today I ran my first Games Pod workshop with a mixture of children from years 4 and 6. I’m amazed at what was produced in under an hour and a half – especially considering all but two of them had never used 2DIY before! I can’t wait to create a website to house them all. Here’s a sneak preview of what some of the children in Bangkok Class created. Can you play them and give them some tips or hints as to how they could make them even better?"

Games Pod – Day 1 | Bangkok Class Blog

Posted by Xannov in 2DIY Examples | Permalink

Reblog (0) | | Digg This | Save to del.icio.us |

Actionscript Tutorial No.8

Here's the eighth in my series of tutorials aimed at helping 2DIY users to use, and understand, actionscript within their creations.

This tutorial deals with creating elements that will orbit around other elements.

Download 2DIY_tut8

Outline
In several 2DIY activities, you can place additional elements on the screen that can be used to orbit around other elements. You can make monster, apple or sun elements orbit around other elements, and even make your main character orbit around another element too.

image from simonwiddowson.typepad.com Code Explanation
Place an element on screen that will become the orbitee, and place another element on top of it that will become the orbiter. Right click on the orbiter element and click on the animation option (the second option). Within this option there is an ‘advanced’ setting where you can enter ActionScript code, and here we can set a rule to cause this element to circle around another element.

Tutorial
Create a platform activity. Add an apple element to the screen,  and then place  a monster on screen above the apple element. Right click on the monster element, and look for the animation settings option (the second option). Choose the advanced option and type in the following code;

var angle = Math.atan2(this._y - _root.s13._y, this._x - _root.s13._x) + 0.05; 

this._x = _root.s13._x + Math.cos(angle)*100;

this._y = _root.s13._y + Math.sin(angle)*100;

var angle  this sets up an variable that we are calling ‘angle’

Math.atan2 this is a trigonometrical function (remember your tan / sin / cos from schooldays?) that works out the arctan of the difference between the two elements you are using.

(this._y - _root.s13._y, this._x - _root.s13._x) this tells the activity which values to use to find the arctan above

*the value of _root.s13 will change - see notes below

+0.05;  this value adds a small amount to the variable ‘angle’ that results in the orbit effect. We can alter this to create a faster orbit (use a smaller value)

this._x = _root.s13._x + Math.cos(angle)*100;

this._y = _root.s13._y + Math.sin(angle)*100;  these two lines together are used to calculate the position of the object that is orbiting. It calculates the position of the orbitee, using the cosine or sine of the angle, and multiplies it by a value to create the orbit radius. The smaller the value, the closer the orbiter appears to the orbitee.

Now press the play button. Your character moves very slowly to begin with, but gradually speeds up as apples are collected, and the value of dx rises.

What does this do?
By using trigonometry to calculate the angle between the orbitee and the orbiter, the result is the ability to create an effect of one element orbiting around another object. 

Task
Create a platform game. Add a character, and then add some apple elements at various places. Place monster elements on top of the apple elements and add the orbiting code. Now each apple is being ‘protected‘ by a monster. Can you safely avoid them and collect all of the apple?

Notes
You can create a situation whereby the main character becomes the orbiter - and you can steer the orbitee, with your main character orbiting it, around the screen. To achieve this use a sun element and add the code to this (you cannot add actionscript to the main character).

Because you are adding the code in a different location, you do need to change the code slightly, and instead of using 

var angle = Math.atan2(this._y - _root.s13._y, this._x - _root.s13._x) + 0.05; 

you need to use

var angle = Math.atan2(_root.player._y - _root.s22._y, _root._x - _root.s22._x) + 0.05; 

Make sure you place the _root.player code before the _root.s22 code, as you want the player to orbit the element, and not the other way around.

You also need to add some code to respond to key presses to move the sun element around the screen. This has been mentioned in other tutorials, but to recap;

if(Key.isDown (80)==true) {this._x +=1;} to use the P key to move right

if(Key.isDown (79)==true) {this._x -=1;} to use the O key to move left

if(Key.isDown (81)==true) {this._y -=1;} to use the Q key to move up

if(Key.isDown (65)==true) {this._y +=1;} to use the A key to move down

To work out the value of the orbitee element use the following;

In a collecting or journey game; _root.s2-_root.11 (monsters), _root.s12-_root.s21 (apples), _root.s22-_root.s31 (suns) Further objects added will be _root.s32, _root.s33 etc 

In a platform or snake game; _root.s3-_root.12 (monsters), _root.s13-_root.s22 (apples), _root.s23-_root.s32 (suns) Further objects added will be _root.s33, _root.s34 etc

In collecting, platform and snake games, use _root.player for the main character

In journey games use _root.car for the main character

You can find out more about this feature here

Posted by Xannov in Tutorials | Permalink

Reblog (0) | | Digg This | Save to del.icio.us |

ActionScript Tutorial No.7

Here's the seventh in my series of tutorials aimed at helping 2DIY to use, and understand, actionscript within their creations.

This tutorial deals with increasing the speed of your main character.

Download 2DIY_tut7

Outline
In 2DIY platform activities, you can make your character move really slowly, and gradually increase the speed they move at using monster elements.

image from simonwiddowson.typepad.com Code Explanation
Right click on a monster element and click on the collision options (the third option). Within this option there is an ‘advanced’ setting where you can enter ActionScript code, and here we can set a rule to increase the speed that a character moves at.

Tutorial
Create a platform activity. Add an monster element to the screen, right click on it, and look for the collision settings option (the third option). Choose the advanced option and type in the following code;

_root.dx=1;

_root.dx=1;  this tells the activity to alter the speed of the main characters movement (by default ‘4’ is the normal value. Lower values are slower, and higher values are quicker)

Place the monster element in the same place as the main character element - this will ensure that when the activity starts the code is activated and the speed of the character is instantly slowed - and also make it transparent by colouring it in with the chequerboard pattern (you do not want to see the monster element on screen).

Place more monster elements at various points within the activity with the same code, but each time increase the value of the _root.dx= by 1 (so use 2, then 3, then 4). Above each transparent monster element you use, place a collectable apple element. This will give the effect of every time an apple is collected the characters speed will increase.

Now press the play button. Your character moves very slowly to begin with, but gradually speeds up as apples are collected, and the value of dx rises.

What does this do?
By increasing the value of dx you are increasing the speed that the main character moves at. 

Task
Create a platform game. Add a character, and then add some apple elements at various places. Add some transparent monster elements below some of the apple elements using the code mentioned above.

Notes
You can use this in reverse  - and begin with a fast moving character, but each time an apple element is collected the code is written so that the value of dx is reduced by 1 each time.

Posted by Xannov in Tutorials | Permalink

Reblog (0) | | Digg This | Save to del.icio.us |

ActionScript Tutorial No.6

Here's the sixth in my series of tutorials aimed at helping 2DIY users to use, and understand, actionscript within their creations.

This tutorial deals with creating time limited effects such as higher than normal "power jumps".

Download 2DIY_tut6

Outline
In 2DIY platform activities, you can make your character jump higher for a limited time using a monster element, as well as a sun element.

Code Explanation
2diy_tut3_img1Right click on a monster element and click on the collision options (the third option). Within this option there is an ‘advanced’ setting where you can enter ActionScript code, and here we can set a rule to increase the height that a character can jump.

Tutorial
Create a platform activity. Right click on the play button (the triangle) and add the following code below the code that you see (DO NOT REMOVE THE CODE THAT IS ALREADY THERE!)

var timer: int = 0;

var this tells the computer that you are setting a variable

timer is the name of the variable you are setting

int = 0; this gives a value of 0 to the variable timer

Add an monster element to the screen, right click on it, and look for the collision settings option (the third option). Choose the advanced option and type in the following code;

_root.jumpSpeed=-20;

_root.timer=1;

_root.jumpSpeed=  (this tells the computer the height that the character can jump up. It is a negative value as the character has to rise UP the screen)

_root.timer=1; (this sets the condition to start a timer that determines how long the extra jump height lasts)

Now add a sun element to the screen and add look for  the ‘animation’ settings (the second option). Choose the advanced (ADV) option and enter the following code;

if (_root.timer >0 ) {

_root.timer++;

if(_root.timer >90) {

_root.jumpSpeed=-16;

_root.timer=0;

}}

if (_root.timer >0 ) asks whether the timer has been activated by the monster element code. If the timer value has reached 1 (when the character touches the monster element) then the next line of code is activated;

_root.timer++; the value of ‘timer’ increases by 1 each time this runs

if(_root.timer >90) asks whether the value of the timer has reached 90 ( about 3 seconds). If it has, then the next line of code is activated)

_root.jumpSpeed=-16; and _root.timer=0; the jump height is returned to normal, and the timer value is reset to 0

Now press the play button. Try jumping and see how high you jump. Now move onto the monster element and jump again. You are jumping higher. Move off the monster element, wait a few seconds and jump again. The jump has returned to its normal height.

What does this do?
By using the sun element to run the code, you are telling the computer to constantly check what the value of a timer value is. Initially this is 0, and remains 0 until the character collides with a monster element. When this happens the value of the timer becomes 1, and this triggers the code in the sun element to run making the jump higher. The timer value rises and rises until it reaches 90, and then both the jump height and timer reset themselves to what they were at the beginning of the activity.

Task
Create a platform game. Add a character, and then add some apple elements on a high platform - a platform too high to reach. Add a monster element and make it look like a spring / canon. Add the code to this element and use it as a ‘powerboost’

Notes
The sun element that contains the code can either be made to appear invisible (colouring it with the chequerboard pattern), or add some clipart and place it on screen as a static element. 

You can find out more about this feature in this article

 

Posted by Xannov in Tutorials | Permalink

Reblog (0) | | Digg This | Save to del.icio.us |

« Previous Articles | More Articles »

Search

Recent Posts

  • 2DIY with Gifted and Talented groups
  • Making characters fly (and other effects)
  • High Lawn Primary Games
  • Creative Learning
  • Gallons of Games
  • Games Pod Creations
  • Kensington Avenue Primary 'Games Pod'
  • Actionscript Tutorial No.8
  • ActionScript Tutorial No.7
  • ActionScript Tutorial No.6

Recent Comments

  • Xannov on Discuss
  • Angela Canas on Discuss
  • Xannov on Discuss
  • Angela Canas on Discuss
  • Xannov on Discuss
  • Ali on Discuss
  • Xannov on Discuss
  • Max Wainewright on Discuss

Archives

  • June 2011
  • May 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010

More...

2Simple Talk

login
Follow @xannov

| The 2DIY script archive |

Design by @xannov