MiniBusiness
Jan 18 2008, 07:51 PM
QUOTE First of we set up the scene, What you will need is a button, I just made a simple graphic with a gradient, then convert it to a button symbol by right clicking and choose convert to symbol. Give the button an instance name, we will need it when we have to do some action scripting. I called mine "roll". Then we need a simple text box, place it center on the stage, and change its property to dynamic textbox, so its able to receive information through actionscripting. Basically this is what we need to make things work, but to make the game a bit more interesting we also need some graphic for visual appeal. I just made 6 different view of a dice, I made it in Photoshop, (I could have done it in any graphic related environment. Import your images to the stage, File -> Import -> Import to stage and locate your dice image files. Now separately convert all images to movie clips and give them instance names like this dice_1, dice_2, dice_3, dice_4, dice_5 and dice_6. I very important thing now is to place all dice movie clips exactly on top of each other, an easy way to do this is to type in the x and y coordinates for all movie clips. Now to the fun part, the action scripting.
roll.onPress = function () {
_root.result.text = 1 + Math.floor(Math.random()*6); /*numbers between 1 and 6 */
}
This function tells flash that when someone clicks on the button the textbox will show a random number between 1 and 6 using the Math function in flash, a very useful tool. The next thing is to make a simple function that makes all our dice movie clips invisible, we will do this every time we need a new shuffle, then only show the dice with the same number of eyes as shown in the textbox (eg. random number 1 then dice_1._visible = true).
function invisible () {
_root.dice_1._visible = false _root.dice_2._visible = false _root.dice_3._visible = false _root.dice_4._visible = false _root.dice_5._visible = false _root.dice_6._visible = false
}
Now we will need to call this function every time the button is pressed so we have to add to the onpress part of our code.
roll.onPress = function () {
_root.result.text = 1 + Math.floor(Math.random()*6); /*numbers between 1 and 6 */
invisible();
}
We are almost done, this next part is the most annoying part to type, its not that complicated its an if condition with 5 else if's, this will control that if the number 1 comes up, then we will show dice movie clip one, if number 2 comes up, then we will show dice movie clip two and so on. This code also has to be added in the buttons onpress code so the final onpress code will look like this.
roll.onPress = function () {
_root.result.text = 1 + Math.floor(Math.random()*6); /*numbers between 1 and 6 */
invisible();
if (_root.result.text == 1) { _root.dice_1._visible = true } else if (_root.result.text == 2) { _root.dice_2._visible = true } else if (_root.result.text == 3) { _root.dice_3._visible = true } else if (_root.result.text == 4) { _root.dice_4._visible = true } else if (_root.result.text == 5) { _root.dice_5._visible = true } else if (_root.result.text == 6) { _root.dice_6._visible = true }
}
Just to clarify I will try to explain how this if and else if part works.
if number 1 comes up then show dice 1
else if number 2 comes up then show dice 2
else if number 3 comes up then show dice 3
And so on.
Here is the final code.
--------------------------------------------------------------------------------
roll.onPress = function () {
_root.result.text = 1 + Math.floor(Math.random()*6); /*numbers between 1 and 6 */
invisible();
if (_root.result.text == 1) { _root.dice_1._visible = true } else if (_root.result.text == 2) { _root.dice_2._visible = true } else if (_root.result.text == 3) { _root.dice_3._visible = true } else if (_root.result.text == 4) { _root.dice_4._visible = true } else if (_root.result.text == 5) { _root.dice_5._visible = true } else if (_root.result.text == 6) { _root.dice_6._visible = true }
}
function invisible () { _root.dice_1._visible = false _root.dice_2._visible = false _root.dice_3._visible = false _root.dice_4._visible = false _root.dice_5._visible = false _root.dice_6._visible = false }
Reply
Jeigh
Jan 18 2008, 09:00 PM
I'm too lazy to figure out what exactly that code (that you stole *cough*) is supposed to do, but I'm sure its nothing too intense. Games are best made, especially small ones, if its creative and original by the author. I'd suggest anyone that saw this and got excited about making a game take a basic board game like checkers or something and try to recreate it. Thats a good start to programming games
Reply
toby
Jan 20 2008, 02:52 PM
What language is that? Doesn't look like C or Actionscript, Java?
Reply
bhupinder
Jan 25 2008, 12:22 AM
Is that even a script lol! What are you using it for?
Reply
pyost
Jan 25 2008, 09:55 AM
Similar Topics
Keywords : game, coding
- Grid-iron - Management Game
(0)
Wow Game
(1) Greetings! Introduction I represent MTVault.com I want to take a little of your time to
introduce our company and what we can offer to MMO players. We are a newly formed organisation with
members having worked in this field of business for many prior years. We currently specialise in 3
major MMO games (WoW, AoC, EVE) and aim to deliver every customer’s purchase upto satisfactory needs
with competitive prices, speedy delivery, and great customer service. Our services Gold/Currency
and distributed on: -World Of Warcraft US + EU -Age Of Conan US + EU -EVE Online ....
Looking For Coder To My Web Game
(0) Hi My web browser game is almost done its only the layout/theme left What we are looking for is
another coder so everythign will run smoother and go better right now we have 1 coder,but we want 1
more Its a huge game to say its allways something for the players to upgrade or build They can
research new stuff such as building and other they can build different building to make what they
want,and after they have build their buildings they can also upgrade them to either get more off
something or the stuff the building creates,creates faster and so on There is a few bu....
What Is Your Favorite First Person Shooter Game?
(0) I know, a very generic question, however I am very curious to see. Also, please say if the game is
Vista Compatible or not. Since Vista is relatively new, there are many decent FPS games that are not
even able to run on Vista! I would have to say mine would be Half Life 2: Episode 2. Anyone
know more information about Episode 3 as well?....
Free Action Game Online
(0) free action games : Play Free Online Games, sports games, massive multiplayer
games, action games, puzzle games, flash games and more, casual games
http://www.miniclip.com/games/en/action.php ....
What You Need Before You Can Create A Text-based Game..
Using PHP, HTML and MySQL (5) Please comment and rate, after you finished reading! /smile.gif"
style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
################################################################# Change log: Aug 22 2008: The
Tutorial Was Created. V1.0.0 Aug 30 2008: Added XHTML and a small CSS part. Also corrected some
small things and added this change log. V2.0.0
################################################################# OK.. Many people here want to
create text based games. Many of you ask us here on the forums: "how to create a text-based ....
Making Educational Game
3d game, like walking in country (3) Please, i would like to make a progra/game like walking in a country, visiting houses. Specially
church is in my mind. with some music(in church religious)..... or, but its not so important -
meeting people and talking with them. I cant say, but something between RPG and adventure, maybe
with some small missions like finding cross, or old pergamen.... but in 3D. Maybe i can download
some 3d models from net, so 3d modeling is not required for this tool. Just engine - with physics,
colisions detect, maybe water effect, but not so important, then i need no so many programmi....
Game'istaan - Game Development Contest @ Niit
(2) EDIT: Screenshots of the new Release Here goes the link:
http://maxotek.net/scripts/php-ajax/winExp...omber%20Man.zip A game development contest named,
Game'istaan started on the 5th of this month at NIIT, India. Each of the teams (max 3 students
per team) need to submit their entries by the 4th of september. The coding can be done in C++, J2ME,
FLASH or C#. I went for C# which was not among the list, initially. It was introduced because very
few (just us in our zone) opted for C++. The game I am developing is 'Bomber Man'.
Currently, the game ....
Xml Needed?
Is XML required for a text based game? (4) As the description says. Is XML required when making a text based game or is it not needed at all?....
Novalogic Games
Which game is the best in your opinion (1) Hey i was just wondering if anyone here has played on any of the games.. and if they have, which one
would you consider to be the best.. this isnt just the graphics because the older games dont have
good graphics anymore.. so include which one you enjoyed most! Also, there is the new game
coming out soon called Delta Force: Angel Falls and i was wondering which of you would be playing
that in the future. For me personally it was Land Warrior and it just keeps bringing me back even
if it is a good 8 years old now....
Halo 3
The best game out there next to gearsofwars (3) Recently ive benn playing halo 3 on x box live my gamer tag on x box live is SoilderBROSKI well
anyways when i started playing this i thought it was dum but then after playing it online for like a
week i got realy realy good i became luitenent Srry if i didnt spell that right. anyways i got realy
good at using the sniper and the shoygun as a combo i sniped three guys with 1 shot how many pepole
can say they have ive goten over kills triple kills and double kills like nothing anyways i wanan
know your opinion on halo 3 ty.....
Torn City
A very big Text Based Game (9) I have been playing Torn City for over a half a year. But the game is HUGE! theers are around 25
thousand people playing that game. It has alot of stuff to do. visit Torn City Im a player but i
really like it.You can make factions, companies, buy houses,kill people, and buy guns there is a
HUGE varity of guns in that game. its a game were you find new stuff to do every day.. just dont
like waiting lol. but its how it is. Im looking forward to making a game like this!!
/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />....
Making A Turn Based Game Like Ogame
Help would be nice =D (9) The Idea came to me and Just wanted to know what kind of code I'll need to know ect ect Also
Help would be nice, because I'm kind of fresh =D x....
Slavehack
An Online Hacker pwnage game (12) Hey someone might have posted this before but I wanted to say...Slavehack (www.slavehack.com) is a
really awesome game. Its a browser based online virtual haxxoring game. QUOTE What is Slave
hack ? Slave Hack is an online hacking simulation game, Slave Hack is NOT related to any real
hacking ! All in-game is virtual, everything is made up..like the IP ranges, software, warez
etc. Ok I'm not afraid anymore..so tell me about the features? To start with the best: SH is a
free game, you never need to show your credit card. You start SH with a very old (133Mhz,....
Battle Dawn
Online game review (2) Review of Battle Dawn Hi guys, last week I started playing a game called Battle Dawn. It’s
an online strategy game. You play on a map of the world, when you start you can build your colony
anywhere on earth. I built mine right over my home town of Nelspruit. The topography of the game is
very good; it’s got all the lakes, mountains and desserts of the real world! There are 4
resources in the game. Metals, oil, food and energy. Metals and oil are used to build things, food
is used to feed your colony and increase its population and energy is used to perform....
Gba Game Program
(5) Just woundering if anyone appart from me has even tried to create games for the gba
And if so... were you... A: successful or any good at it... B: what type
of scripting did you use... I use HAM and VHAM (Click here to go to the Home page)
(sorry about the colour just had to try it... /tongue.gif" style="vertical-align:middle" emoid=":P"
border="0" alt="tongue.gif" />)....
Entropia Universe
The most expensive 'game' on Earth! (8) Entropia Universe, the most expensive 'game' on the planet... QUOTE The Entropia
Universe is more than a game. The Entropia Universe is for real. Real people, real activities and a
Real Cash Economy in a massive online universe. From EntropiaUniverse.com Yes...Entropia
Universe, the game in which someone paid $100,000 for a virtual space station (for news article
click here ). I got sucked in for the first time about 6 months ago, it was called 'Project
Entropia' then. With the allure of making REAL MONEY in a game...Entropia Universe has....
Please Recommend A Decently Priced & Good FPS Game
(36) anyone know a cool game that I can buy for a reasonable price and is a good game I will play a lot
becasue know im just really bored... Can you please help me?....
Need For Speed Most Wanted!
The best game! (19) I bought this game and I just love it! I have a Driving wheel do it doubles your fun! the
police makes it a lot cooler and the graphic are just WOW!!!!! It would be a lot
cooler if they would have a lot of shops lik ein underground 2.... But except that is a great
game! I myself have the blacklist edition and its a lot cooler becasue you have a list of people
you have to beat and if you beat all of tehm you win.......
Help Me Create A Text-based, Turn-based Game
Similar to X-kings, Inselkampf, Ogame, Travian,etc.. (9) Can anyone help me create a game similar to the ones mentioned above? It isn't intended to have
lots of graphics, but maybe a few... Any response will be much appreciated.....
New Game: Sudoku
(17) There is a NEW game in town. Its SUDOKU. This game is about patience and strategy. Everyone all ages
can play this game as it is considered a universal game without language barriers. ....
Freelancer: The Forgotten Game
(9) Any one remember this game? It's been over 4 years since this game has been released, but i
still haven't found a single game that measures up in comparision. for the uninitiated -
here's the history Freelancer was a massive project started by microsoft way back in 1998, when
they decided to make the ultimate space fighter game. it was supposed to be realsed in 2000, but got
delayed, and was released in 2002-03 (don't remember) The game is completely perfect - never
seen a game like it before. it had awesome graphics, superb gameplay, and immersive sound....
Wuts A Good Game Maker Program?
(12) whats a good game maker program where i can add them to my site?....
The Best Strategy Game
old strategy (29) hey i buying an old strategy game soo plz help mee to the best the best the best old strategy game .
post your favourite and why thx for helping mee /smile.gif' border='0'
style='vertical-align:middle' alt='smile.gif' /> ....
Make Your Own FPS Game
(32) i happend to be searching the internet, as i usually am doing from 5-9 on a daily basis...and i came
accross this advertisement that sparked my intuitive imaginiation (wow big words...what do they mean
?) ne ways...heres what the ad said... First Person Shooters are one of the most enduringly
popular game genres. Now, for the first time, anyone can make their own action packed FPS games
without any programming or 3D modelling knowledge. Bringing a new benchmark to game creation, the
innovative and multi-featured FPS Creator has been three years in development and off....
Online Multiplayer Game
What language to learn in order make it? (16) If you look at e.g. THIS LINK What language would you use to make something like that?
/wink.gif' border='0' style='vertical-align:middle' alt='wink.gif' /> ....
Creating A Game In Rpg Maker 2000/2003
Part 1 - New Game and the Database (18) Creating a game in RPG Maker 2000/2003 Part 1 (I AM ONLY GOING TO TEACH YOU HOW TO MAKE AN
RPG GAME IN THIS TUTORIAL!) First of all, you need to find some resources. When I say
resources, I mean Character Sets, Chip Sets, Music, Backdrops, and Enemies. (Also others) The
perfect place to find thoses would be at one of these great websites: www.gamingw.net
www.phylomortis.com But, before you save them, you need to create a new game. Once you click on
"New Project", this screen will pop up. The Directory Name is simply the name of the folder that
it will....
Best Snes Game?
(25) What do you think is the best SNES game of all time???....
What Is The Best RPG You Have Ever Played
RPG=role playing game (120) i have played many RPG's in my time and hands down i would have to say Dark Age of Camelot was
the best one i ever played, now im curious to see what everyone else thinks the best RPG ever made
was....
How To Make A Text Based Online Game Script ?
(23) Does anyone know if there is a easy was to make a text base online game, Like a free templet, or if
anyone know how to make one and can help me.....
Looking for game, coding
|
|
Searching Video's for game, coding
|
advertisement
|
|