Thursday, August 30, 2012

Speed Art Game - Card Game


This is how far I got in 2 hours making a card battle game.
Play it here: http://adf.ly/CPCLV

I also need help making an intro and outro for these videos. If you are interested, please PM me!

Music:
Aurora - ApproachingNirvana


Monday, April 2, 2012

AS2: Save Data

Source file available here: http://adf.ly/6xzBr


Welcome! In this tutorial, I will show you how to save data such as variables, text box data, char positions, and much more! This is handy if you need a "Save Game" option.


Alright, to get started, open up a new AS2 document.


First, make a button symbol. Call it "saveBtn". No instance name required.
Then, make another button. Call it "loadBtn". Still, no instance name.


Now for this tutorial, I will show you how to save a player's position on the screen.
So go ahead an create a character and name it "charMc". Give it an instance name of charMc.






















Now, let's make the character move with the arrow keys. Right click on our charMc movie clip and select "Actions". In the actions, type:



onClipEvent(load){
speed=3;
}
onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
this._x+=speed;
}
if(Key.isDown(Key.LEFT)){
this._x-=speed;
}
if(Key.isDown(Key.DOWN)){
this._y+=speed;
}
if(Key.isDown(Key.UP)){
this._y-=speed;
}
}


That is all the coding we need for charMc. All we have to do now, is enter in save and load actions in the buttons. In the "saveBtn" button, type:



on(release){
_root.pos = SharedObject.getLocal("tutorial");
_root.pos.data.charMc_x = _root.charMc._x;
_root.pos.data.charMc_y = _root.charMc._y;
}


And in the "loadBtn" button, type:



on(release){
_root.pos = SharedObject.getLocal("tutorial");
_root.charMc._x = _root.pos.data.charMc_x;
_root.charMc._y = _root.pos.data.charMc_y;
}


And that's it!
On the first line of the save and load code, we are making a new cookie that will be stored locally on the player's computer. Next line on the save code, we call the "charMc_x" and "charMc_y" variables to store the player's position. In the load button, we search for that variable in the cookie and display it. If you wanted to save the score, you could use this in the save button:
_root.pos.data.score = _root.score;
And then in load button, just flip it around!
Hope this tutorial was helpful!


Source file available here: http://adf.ly/6xzBr

Sunday, April 1, 2012

I'm Back!

Sorry for the lack of tutorials!
I was designing a game for a state competition. Now that it's over, it's time for some amazing tutorials! Be ready for constant weekly updates :]

-Eric

Saturday, October 22, 2011

AS2: Shop System

Source file available here: http://adf.ly/3LnLS

Welcome! Today I will be showing you how to create a shop system in your flash games with the use of ActionScript 2.0.

Let's start by creating a new AS2 Flash document.












For this tutorial, you will only have 4 things in your library. 3 of the 4 are buttons named "item1", "item2", and "item3". The other thing is also a button named "purchase_btn". You will need to create these now. Just select each item individually, and convert them to a symbol (button) by pressing F8 on your keyboard or right clicking them and selecting "Convert to Movie Clip".






















The picture above are the 3 items I created, and my purchase button. You are now done with making the library items.

Now we need to add several Dynamic text boxes. There are 7 total for this tutorial.
Here is a list of the ones you will need and their Instance Names or Variables. The ones highlighted in blue are Variable Names, and the ones in red are Instance Names.

Money - "money"
Cost of Item - "cost"
The Item's Name - "itemName"
Shop Message - "msg"
Amount of Blue Squares - "blueSquares"
Amount of Red Squares - "redSquares"
Amount of Green Squares - "greenSquares"

Here is a visual display of the textboxes:
Do not put any text inside the textboxes, I just wanted to make it clear which ones were which.


















Now that we have named our Dynamic textboxes, we can start adding code.
In the first frame, we need to determine how much money we want to start out with, and how many of
each item we have in our inventory. So in the frame's actions, type this:


money=100;
blueSquares=0;
redSquares=0;
greenSquares=0;


We have now set what we want for each value. Now we need to add coding that lets us purchase items. On the purchase button, type this:



on(release){
if(_root.itemName.text=="Blue Square" && _root.money>=10){
_root.money-=10;
_root.blueSquares+=1;
_root.msg.text="You have bought 1 Blue Square."
}else
if(_root.itemName.text=="Red Square" && _root.money>=20){
_root.money-=20;
_root.redSquares+=1;
_root.msg.text="You have bought 1 Red Square."
}else
if(_root.itemName.text=="Green Square" && _root.money>=30){
_root.money-=30;
_root.greenSquares+=1;
_root.msg.text="You have bought 1 Green Square."
}else
if(_root.itemName.text=="Please select an item."){
_root.msg.text="You have not chosen an item!"
}else{
_root.msg.text="You don't have enough money!";
}
}

Let's take a look at what this means:

if(_root.itemName.text=="Blue Square" && _root.money>=10){
_root.money-=10;
_root.blueSquares+=1;
_root.msg.text="You have bought 1 Blue Square."
}
Each of these "if" statements is checking to see if 1, we have selected the Blue Square item as indicated by the  "itemName" textbox, and 2, if we have enough money to purchase the item.
You will notice that after each "if" statement, there is an "else" action. This means that, if the function above is false, (if we do not have enough money/item not selected) then check for this function, and if this function is not true, check the next function.


if(_root.itemName.text=="Please select an item."){
_root.msg.text="You have not chosen an item!"
}else{
_root.msg.text="You don't have enough money!";
}


The "if" statement here is saying that if we have not selected an item at all, let the user know that he/she has not selected an item from the shop.
The last line is the last function that is checked, that lets the user know that they do not have enough money to purchase the item.

The last coding we need is simple, we just need to be able to click on an item and display the cost and name of it. For each item, type this:


on(release){
_root.cost=10;
_root.itemName.text="Blue Square";
}


You can change the cost and name to whatever you want, but make sure that the "itemName.text" matches the same text you put in the coding for the purchase button.



















That does it! If you need help understanding the code or anything dealt with in this tutorial, please download the source file. It will help you! Thanks for viewing this tutorial!

Source file available here: http://adf.ly/3LnLS

Monday, October 10, 2011

AS2: Mouse Controls Character Rotation

Source File Available Here: http://adf.ly/38qsi

Welcome to Tutorial #9! In this tutorial, I will teach you how to aim your character towards the mouse position.
Let's get started by opening up a new Flash AS2 document:












Now let's draw our character on the stage. Then convert it to a movie clip called "char". Next, put the registration point where you would like to have the character's rotation axis at. In this case, I'm putting mine in the center box, so that the character rotates around the center of itself:











Now let's open up that actions of the character and type:

onClipEvent (enterFrame) {
disx = _root._xmouse-_x;
disy = _root._ymouse-_y;
Radians = Math.atan2(disy, disx);
Degrees = 360*Radians/(2*Math.PI);
_rotation = Degrees;
}


1.) disx and disy are setting variable for the x and y coordinates of the mouse cursor
2.) Radians is settings the variable for the distance between disx and disy
3.) Degrees calculating the rotation angle
4.) _rotation is settings the angle to the Degrees variable


Now you are done! Test your game to see your character aim at the mouse.
This concludes Tutorial #9! Thanks for viewing and remember to subscribe to my blog for more tutorials!

Source File Available Here: http://adf.ly/38qsi

Sunday, October 2, 2011

AS2: Paypal Donate Button

Source File Available Here: http://adf.ly/30e2V
Welcome to Tutorial #8! In this tutorial I will show you how to add a Paypal option in Flash for purchasing items.

Let's start by opening up a new Flash AS2 document:












Now lets create a button that says "Paypal" on it. Convert it to a button movieclip and name it "paypal_btn".













Also, make sure you give the button an instance name of "myPurchaseButton". If you don't give it that instance name, your button will be non-functional.













Now let's open up the actions of the button by clicking on it and hitting F9 on your keyboard or right clicking it and selecting "actions". Type this:


myPurchaseButton.onRelease = function() {
formData = new LoadVars();
formData.cmd = "_xclick";
formData.business = "my-email-example@domain.com";
formData.item_name = "Donation";
formData.amount = "$10.00";
formData.send("https://www.paypal.com/cgi-bin/webscr", formData, "POST");
};


The code is pretty much self explanatory. Just change the email, item_name, and amount to your preferences and you're done! Once you click the button, it should bring you to the purchase page in Paypal, prompting you of your pre-purchase.

Thank you for viewing this tutorial! Be sure to become a member to receive notifications of all new weekly tutorials on my blog!

Source File Available Here: http://adf.ly/30e2V

AS2: Timer

Source File Available Here: http://adf.ly/30cZq

Welcome to Tutorial #7! In this tutorial, I will show you a quick an easy way to make a countdown timer for your game.

Let's start by opening up a new Flash document and choose AS2 as your coding language.












Now lets create a Dynamic text box on the stage. Give it an variable name of "timer" in the properties panel.

















Lastly, we need to open up the frame's actions. So click on the frame you are on in the timeline, and hit F9 on your keyboard or right click the frame and choose "Actions". Type this:

stop();
timer = 20;
countdown = function(){
_root.timer--;
if(_root.timer<=0){
_root.timer=0;
}
}
countdownInterval = setInterval(countdown,1000);


Lets take a look at what this means:


1.) stop(); means to stop the timeline from continuing the timeline animation.
2.) timer = 20; is setting the timer text box we made to start at 20 seconds.
3.) countdown = function(){ is setting a variable name (countdown) as a function.
4.) _root.timer--; means to constantly subtract seconds from the timer.
5.) if(_root.timer<=0){ means if the timer is less than or equal to 0 seconds, then execute the following command.
6.) _root.timer=0; means to set the timer to 0, so it won't subtract into negative numbers.
7.) countdownInterval = setInterval(countdown,1000); is setting an interval of subtracting seconds as close to a normal second as possible.

Now you're done! It should look like this:









Thanks for viewing this tutorial! Don't forget to become a member of this blog to get notifications of weekly tutorials!

Source file available here: http://adf.ly/30cZq