måndag 27 augusti 2012

Room with a glass table

This is a little room that i made in Blender 2.63 with Blender Cycles. And now i have one year of experience of working with blender. I will still change some things in the picture i think, put so far i'm happy how it all ended up :)

onsdag 4 april 2012

Room

A small room that i made in Blender, just had a simple idea that i wanted to try so i did. Ended up pretty nice.

tisdag 31 januari 2012

Glass with water


This was a little scene that i made in Blender 2.61 with the new Cycles Render, (with a tutorial ofc but i learned much!). I'm happy with the results and worktime was about 4-5 hours.

lördag 14 januari 2012

Hangman Tutorial

This is going to be a tutorial of how to make a simple Hangman game in Flash As3.

The Easiest way to start is to make all the MovieClips, TextFields and buttons and put them into our scene.
Make two textfields, one for the right words we have guessed on and one for the wrong ones with the names guessText on the one with right letters and wrongChar for the one with the wrong letters.
Make a button for start, restart and all the letters in the alphabet (a-z) and name the buttons btn_a, btn_b to btn_z, btn_start and btn_restart.
Do a movieclip with how many lifes your "hangman" should have and one frame for if we win and one for if we fail.


Now we are at the programming. We can start by making some variables.

The part were the computer choose a random word looks like this :


var computerChoice:int = 0;
var names:Array = new Array("speaker","cat","hamburger","firetruck","lamp","mouse","car","soda");
var playerChoice:String = "";
var hangmanWord:String = "";
var win:int = 0;



The :String is to make that you only can put letters in it, no numbers
The :int is so you only can have a number with no decimals after and no letters.


In the array you can put what ever the words you want and how many words you want, as long as you do it right. You can do that in many different ways. But this is fast and easy, but you must do it like this : ("test", "testTwo")


-------------------------------------------------------------------------------------------------------------------------------


Now we are gonna create EventListeners for our start and restart button so they will work when we press on them :


btn_start.addEventListener(MouseEvent.CLICK, Starting);
btn_restart.addEventListener(MouseEvent.CLICK, Restarting);

-------------------------------------------------------------------------------------------------------------------------------------



Now we are going to create some functions for what we want our buttons to do, in this case, start our game. And we make the EventListeners for our buttons of what letter we choose :

function Starting(e:Event):void
{
Start();
}

function Start():void
{
computerChoice = Math.random() * names.length;
hangmanWord = names[computerChoice];
for (var iter:int=0; iter < hangmanWord.length; iter++)
{
guessText.appendText("_ ");
btn_start.visible = false;
btn_restart.visible = false;
mc_hangman.gotoAndStop(2);

btn_a.addEventListener(MouseEvent.CLICK, CharA);
btn_b.addEventListener(MouseEvent.CLICK, CharB);
btn_c.addEventListener(MouseEvent.CLICK, CharC);
btn_d.addEventListener(MouseEvent.CLICK, CharD);
btn_e.addEventListener(MouseEvent.CLICK, CharE);
btn_f.addEventListener(MouseEvent.CLICK, CharF);
btn_g.addEventListener(MouseEvent.CLICK, CharG);
btn_h.addEventListener(MouseEvent.CLICK, CharH);
btn_i.addEventListener(MouseEvent.CLICK, CharI);
btn_j.addEventListener(MouseEvent.CLICK, CharJ);
btn_k.addEventListener(MouseEvent.CLICK, CharK);
btn_l.addEventListener(MouseEvent.CLICK, CharL);
btn_m.addEventListener(MouseEvent.CLICK, CharM);
btn_n.addEventListener(MouseEvent.CLICK, CharN);
btn_o.addEventListener(MouseEvent.CLICK, CharO);
btn_p.addEventListener(MouseEvent.CLICK, CharP);
btn_q.addEventListener(MouseEvent.CLICK, CharQ);
btn_r.addEventListener(MouseEvent.CLICK, CharR);
btn_s.addEventListener(MouseEvent.CLICK, CharS);
btn_t.addEventListener(MouseEvent.CLICK, CharT);
btn_u.addEventListener(MouseEvent.CLICK, CharU);
btn_v.addEventListener(MouseEvent.CLICK, CharV);
btn_w.addEventListener(MouseEvent.CLICK, CharW);
btn_x.addEventListener(MouseEvent.CLICK, CharX);
btn_y.addEventListener(MouseEvent.CLICK, CharY);
btn_z.addEventListener(MouseEvent.CLICK, CharZ);

}
}


The :void is for something that don't return anything.

Math.random is for making something choose something out of an array for an example at random.
A gotoAndStop is s you can go to a special frame in a MovieClip if it have more frames.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------



Now we are gonna make out function so our restart button will work as we want it to work :

function Restarting(e:Event):void
{
playerChoice = "";
hangmanWord = "";
win = 0;
computerChoice = 0;
wrongChar.text = "";
guessText.text = "";
Start();
btn_a.visible = true;
btn_b.visible = true;
btn_c.visible = true;
btn_d.visible = true;
btn_e.visible = true;
btn_f.visible = true;
btn_g.visible = true;
btn_h.visible = true;
btn_i.visible = true;
btn_j.visible = true;
btn_k.visible = true;
btn_l.visible = true;
btn_m.visible = true;
btn_n.visible = true;
btn_o.visible = true;
btn_p.visible = true;
btn_q.visible = true;
btn_r.visible = true;
btn_s.visible = true;
btn_t.visible = true;
btn_u.visible = true;
btn_v.visible = true;
btn_w.visible = true;
btn_x.visible = true;
btn_y.visible = true;
btn_z.visible = true;
}





You can have .visible = false; for something that you don't want to show, like we did with the start and restart button when we have started the game.
--------------------------------------------------------------------------------------------------------------------------------------------------

And now to the last part! We are going to make so that we will be able to win or lose and so that our letters will work as we want them to do. So now we just have to make some more functions, on for everything here and one for every letter from A-Z, and some ifs to do different things of whats gonna happend if something else happends.

So we are soon done!



function chooseLetter():void
{
var flagChar:Boolean = false;
trace(hangmanWord);
guessText.text = "";

for (var iter2:int = 0; iter2 < hangmanWord.length; iter2++)
{

if (hangmanWord.charAt(iter2) == playerChoice)
{
trace(iter2);
guessText.replaceText(iter2 * 2,(iter2 + 0.5) * 2,playerChoice);

flagChar = true;
win++;
}


}

if (! flagChar)
{
trace("You lost a life");
wrongChar.appendText(playerChoice);
mc_han
gman.gotoAndStop(mc_hangman.currentFrame + 1);


}

if (win == hangmanWord.length)
{
trace("win");
mc_hangman.gotoAndStop(8);

btn_restart.visible = true;

}

if (mc_hangman.currentFrame == 7)
{
mc_hangman.gotoAndStop(7);

btn_restart.visible = true;

}

}



function CharA(e:Event):void
{
playerChoice = "a";
btn_a.visible = false;
chooseLetter();
}

function CharB(e:Event):void
{
playerChoice = "b";
btn_b.visible = false;
chooseLetter();
}

function CharC(e:Event):void
{
playerChoice = "c";
btn_
c.visible = false;
chooseLetter();
}

function CharD(e:Event):void
{
playerChoice = "d";
btn_d.visible = false;
chooseLetter();
}

function CharE(e:Event):void
{
playerChoice = "e";
btn_e.visible = false;
chooseLetter();
}

function CharF(e:Event):void
{
playerChoice = "f";
btn_f.visible = false;
chooseLetter();
}

function CharG(e:Event):void
{
playerChoice = "g";
btn_g.visible = false;
chooseLetter();
}

function CharH(e:Event):void
{
playerChoice = "h";
btn_h.visible = false;
chooseLetter();
}

function CharI(e:Event):void
{
playerChoice = "i";
btn_i.visible = false;
chooseLetter();
}

function CharJ(e:Event):void
{
playerChoice = "j";
btn_j.visible = false;
chooseLetter();
}

function CharK(e:Event):void
{

playerChoice = "k";
btn_k.visible = false;
chooseLetter();
}

function CharL(e:Event):void
{
playerChoice = "l";
btn_l.visible = false;
chooseLetter();
}

function CharM(e:Event):void
{
playerChoice = "m";
btn_m.visible = false;
chooseLetter();
}

function CharN(e:Event):void
{
playerChoice = "n";
btn_n.visible = false;
chooseLetter();
}

function CharO(e:Event):void
{
playerChoice = "o";
btn_o.visible = false;
chooseLetter();
}

function CharP(e:Event):void
{
playerChoice = "p";
btn_p.visible = false;
chooseLetter();
}

function CharQ(e:Event):void
{

playerChoice = "q";
btn_q.visible = false;
chooseLetter();
}

function CharR(e:Event):void
{
playerChoice = "r";
btn_r.visible = false;
chooseLetter();
}

function CharS(e:Event):void
{
playerChoice = "s";
btn_s.visible = false;
chooseLetter();
}

function CharT(e:Event):void
{
playerChoice = "t";
btn_t.visible = false;
chooseLetter();
}

function CharU(e:Event):void
{
playerChoice = "u";
btn_u.visible = false;
chooseLetter();
}

function CharV(e:Event):void
{
playerChoice = "v";
btn_v.visible = false;
chooseLetter();
}

function CharW(e:Event):void
{
playerChoice = "w";
btn_w
.visible = false;
chooseLetter();
}

function CharX(e:Event):void
{
playerChoice = "x";
btn_x.visible = false;
chooseLetter();
}

function CharY(e:Event):void
{
playerChoice = "y";
btn_y.visible = false;
chooseLetter();
}

function CharZ(e:Event):void
 {
p
layerChoice = "z";
btn_z.visible = false;
chooseLetter();



 }

}

-------------------------------------------------------------------------------------------------------------------------------

So thats how you make a Hangman game in Flash As3!
Hope you liked it.