00:00
00:00
Newgrounds Background Image Theme

Callipsio just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Maid! Sweep Some Mines! Now!

1,025 Views | 17 Replies
New Topic Respond to this Topic

Maid! Sweep Some Mines! Now! 2008-06-17 10:20:42


I'm looking for a tutorial on how to make a simple MineSweeper game in Flash with AS2. I am completely clueless and will bow down and worship you if you give a link to a tutorial, post the code here, or even better, send me the code. Thank you.

Response to Maid! Sweep Some Mines! Now! 2008-06-17 10:50:17


At 6/17/08 10:20 AM, Archon68 wrote: I'm looking for a tutorial on how to make a simple MineSweeper game... or even better, send me the code.

Seems like an oxymoron to me.

Response to Maid! Sweep Some Mines! Now! 2008-06-17 10:55:22


Seems like an oxymoron to me.

?

Response to Maid! Sweep Some Mines! Now! 2008-06-17 11:29:59


You want a tutorial to make a MineSweeper type game, but you'd prefer to be sent the program. Which means you're not making anything after all.

And try learning AS. You're not gonna understand any tutorial if you don't know how to program in AS.

Response to Maid! Sweep Some Mines! Now! 2008-06-17 11:31:13


This guys actually not as stupid as this topic makes him look.

If this is for your windows parody please make SkiFree or Ski3 or whatever it was as well


BBS Signature

Response to Maid! Sweep Some Mines! Now! 2008-06-17 14:13:03


I'll try

Response to Maid! Sweep Some Mines! Now! 2008-06-17 14:24:31


At 6/17/08 11:31 AM, CaiWengi wrote: This guys actually not as stupid as this topic makes him look.

If this is for your windows parody please make SkiFree or Ski3 or whatever it was as well

Just 'cause its for a parody doesn't mean you should just use someone elses code. Now you sound just as stupid.

No one will just give you the code.

Response to Maid! Sweep Some Mines! Now! 2008-06-17 14:24:35


At 6/17/08 11:31 AM, CaiWengi wrote: This guys actually not as stupid as this topic makes him look.

Obviously he's not stupid but that doesn't take away from the fact that he's very new to ActionScript and can't handle the language well yet.

I mean, a "Windows Parody" is one of the more basic things you can do in Flash (if it's like all the others) so setting out to do a minesweeper type of game after that might be a little to big of a step.

Although, when you think about it, it all comes down to logic. I mean, off the top of my head, I think you should have a 2D array with all rows and columns and have it randomize where the mines are and then place numbers around them by reading where the mines are. Then when you click on a tile check in the array what it is (tile, number or blank) and if it's a mine: game over, if it's a number: open it, and if it's a blank: open everything around it that are also blanks or numbers.


BBS Signature

Response to Maid! Sweep Some Mines! Now! 2008-06-17 15:25:10


All I was trying to get across, was that I know instantly upon seeing his post you thought he was just like most of the other muppets posting topics for game code, and this guy is not as bad. As far as ive been able to tell anyway.


BBS Signature

Response to Maid! Sweep Some Mines! Now! 2008-06-17 15:30:59


At 6/17/08 03:25 PM, CaiWengi wrote: All I was trying to get across, was that I know instantly upon seeing his post you thought he was just like most of the other muppets posting topics for game code, and this guy is not as bad. As far as ive been able to tell anyway.

Don't defend people on the interenet you don't know, they have a funny way of letting you down. His post will be taken as it's taken, if he can prove otherwise then he should, if not then leave things as they are.

Response to Maid! Sweep Some Mines! Now! 2008-06-17 15:34:01


At 6/17/08 03:30 PM, Deathcon7 wrote:
Don't defend people on the interenet you don't know, they have a funny way of letting you down. His post will be taken as it's taken, if he can prove otherwise then he should, if not then leave things as they are.

Ok, Ill respect you e-penis (signupdate*postcount) and will take what you say into consideration in the future. You make a fair point after all


BBS Signature

Response to Maid! Sweep Some Mines! Now! 2008-06-18 08:01:22


I realize now that this topic makes me look like an idiot, but I'm actually pretty good with flash and AS. I just wanted some help... and that seems impossible with you Newgrounders.

Response to Maid! Sweep Some Mines! Now! 2008-06-18 08:33:25


At 6/17/08 03:34 PM, CaiWengi wrote: Ok, Ill respect you e-penis (signupdate*postcount) and will take what you say into consideration in the future.

Signup date and post count should not be a reason to respect a user more or less. You should however respect Deathcon7 because he is Deathcon7 and deserves it.

At 6/18/08 08:01 AM, Archon68 wrote: I realize now that this topic makes me look like an idiot, but I'm actually pretty good with flash and AS. I just wanted some help... and that seems impossible with you Newgrounders.

You made a topic where you blantly asked for code. What do you expect.


BBS Signature

Response to Maid! Sweep Some Mines! Now! 2008-06-18 08:37:34


At 6/18/08 08:01 AM, Archon68 wrote: I realize now that this topic makes me look like an idiot, but I'm actually pretty good with flash and AS. I just wanted some help... and that seems impossible with you Newgrounders.

It's not impossible. But being coders ourselves who spend lots of time making our own codes and games, it's a bit difficult for us to take someone seriously who wants it sent to them instantly without doing any work. And you need to specify which language you're working in too. But that's ok, a lot of us make this kind of thread.

Minesweeper itself is a general gametype, so it is likely to not have a specific tutorial. But good luck with future AS'ing.

Response to Maid! Sweep Some Mines! Now! 2008-06-18 09:39:59


I'm not writing the entire code for you (That's not teaching you anything =P ), but I'll give you the jist of it.

First, make arrays with 0s in. This whole explanation shall be done with a 5 by 5 grid example. With my example, you would have:
var Grid:Array = newArray([0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0])
Then, get TWO random number between 0 and 4, and get the Flash to, at that point in the arrays, change the 0 to a 9.
For example, if the numbers came up as 3 and 0, it would pick the FOURTH array (Arrays start at 0, so the Flash calls the forth array part 3) inside Grid:
[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]
And within that, it would choose the first 0, and change it into a 9:
[9, 0, 0, 0, 0]
Leaving you with:
[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [9, 0, 0, 0, 0], [0, 0, 0, 0, 0]

As well as this, make it add one to the numbers "around" it. I.E. Make it add one to array part 2[-1]. 2[0], 2[1], 3[-1], 3[1], 4[-1], 4[0] and 4[1]. Since there is no "-1", it may throw up an error. That doesn't matter, unless it stops the code. By the way, the best way to do this would be with two for loops.

Make Flash repeat this for as many mines as you wish to have.

Then create a Movie Clip. This is your grid square. Give it 12 frames (11 if you don't want the whole flag thing), all with the stop(); code on. The first should be the grid square un-clicked. The second should be a square with no mines near it (A "zero" square). The third should have a one on it, to show there is one mine nearby. The forth, a two. And so on and so forth, until reaching frame 11, which should have the 9 otherwise. But don't give it a nine, give it a mine. The twelth frame should have a flag (or whatever, if you want a flag system).
Finally, remove it from the Stage (if it is there), and go into your library. Right-click it, and choose "Linkage". Select "Export for Actionscript", and give it a name (I'm using "Gridsquare" in my example).
We'll add the code to the frames later.

Then, set the code up to generate the grid, similar to this (think "Tile-Based Programming"):
for (rows=0; rows<Grid.length; rows++) {
for (columns=0; columns<level[rows].length; columns++) {
attachMovie("Gridsquare", "r"+rows+"c"+columns, _root.getNextHighestDepth());
//Attaches the Grid Squares
_root["r"+rows+"c"+columns]._x = columns*10;
_root["r"+rows+"c"+columns]._y = rows*10;
//Works out the Grid Square's location
_root["r"+rows+"c"+columns]._width = 10;
_root["r"+rows+"c"+columns]._height = 10;
//Width and height of the Grid Square
}
}

Finally, add some more code to the grid squares...
The first frame should have code telling it that on pressing it, getting its x co-ordinate, dividing it by 10, then its y, and dividing that by ten, to get the part of the Array it refers to. Then, make it get that part of the array, and telling it to gotoAndStop-ing on the right frame. If the number is 9 OR ABOVE (to account for a mine next to it adding one to something that is already a 9), make it go to frame 11. Otherwise, make it go to the frame number with the array number + 2.
If you are having flags, you have to give it a way to go to Frame 12. Right-click causes trouble on a Flash, remember (plus, Mac users can't right-click). Also, you may wish to use a variable to make this only work if there aren't too many flags already in play (only so many mines, only so many flags!).

Frame 2, the "zero" frame should be given code which, when it goes to that frame, it makes the frames above it, below it and beside it all go to their appropriate frames (remember, they have instances of "r"+rows+"c"+columns).

The mine frame should have the appropriate coding to end the game (or to make the player lose health, or whatever). You may wish for it to make every grid square show its number, like in the actual game. This is similar to the "zero" square, so it shouldn't be too hard if you've managed that.

If you wish to have a "flag" square, then you'll have to give it coding which means it adds one to a variable for the amount of flags on the field, then one to another if it is in the correct position (check the array number refering to the square it is on). Also, get it to remove one from the latter number if it is removed (but only if it was in the correct place to begin with!). My last point was assuming you are giving it code to be removed.
As a final note about flags, you may want to add codes to check when the number of flags and the amount of flags in the correct position are both equal to the number of mines.

And that's it! I think...

Seriously, if you're willing to code all that, I'll be thoroughly impressed! But I don't expect you to (I mean, I'm not going to!). I suggest you stick with an easier idea unless you are REALLY determined.
And of course, the bits of code I have added are far from perfect, and you'll have to change a lot of it to suit your game!

Well, I like your project as a whole, but this may not have been your best idea.
Good luck in your work though! =)


Doomsday-One, working on stuff better than preloaders. Marginally.

Response to Maid! Sweep Some Mines! Now! 2008-06-18 09:55:35


At 6/18/08 09:39 AM, Doomsday-One wrote: var Grid:Array = newArray([0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0])

new Array*

Sorry, my space button has been acting up =)


Doomsday-One, working on stuff better than preloaders. Marginally.

Response to Maid! Sweep Some Mines! Now! 2008-06-18 10:17:53


Thank you.

:-)

Response to Maid! Sweep Some Mines! Now! 2008-06-18 10:43:16