Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (526)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How am I going to make this...?  (Read 1956 times)
0 Members and 1 Guest are viewing this topic.
Offline Marbink100

Senior Newbie





« Posted 2012-03-08 01:23:08 »

Hi guys, I have a question. Using Java (of course) how would I make a Sudoku game? Shocked
I think people who know what Sudoku is will have a better time answering this. Tongue
All I know is that you need to use multi-dimensional arrays...
Any suggestions?
 Smiley

Check out ZOVE Games!!!
It's a site by me and some friends!
Offline UprightPath
« Reply #1 - Posted 2012-03-08 01:36:25 »

Sukodo. My old enemy!

Well, you can use multi-dimension arrays.

However, you'd need to have an object to make up the different types of groupings. The Squares, the Lines, and the Diagonal (If you're using this). From there, it's pretty easy to work out how you do it.

Also! Are you askin' for help with a class assignment? 'Cause I know a lot of teachers who give this one to their students to help them learn about game state stuff and the like. Cheesy

Offline Marbink100

Senior Newbie





« Reply #2 - Posted 2012-03-08 01:41:19 »

No, not for a school assignment or anything of that sort. I just felt like making a puzzle game, and Sudoku is one of my fav puzzles.
So I decided on Sudoku.
And no, I'm not doing diaganols.
Just vertical and horizontal.
Could you be a little more specific with the "different type of groupings" thing?
Thanks! Grin

Check out ZOVE Games!!!
It's a site by me and some friends!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #3 - Posted 2012-03-08 01:45:51 »

Sudoku could easily be made using just a 2D array.

Offline Marbink100

Senior Newbie





« Reply #4 - Posted 2012-03-08 01:48:53 »

Sudoku could easily be made using just a 2D array.
What do you mean? Huh
Sorry, I'm not exactly the best Java programmer...

Check out ZOVE Games!!!
It's a site by me and some friends!
Offline StonePickaxes

JGO Coder


Medals: 4
Projects: 2


Nathan Kramber


« Reply #5 - Posted 2012-03-08 01:55:12 »

Simply make a 2D array called Board or something like so:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
int[][] level = {
         {0,0,0,0,0,0,0,0,0,0,},
         {0,1,1,1,1,1,1,1,1,1,},
         {0,1,0,0,0,0,1,0,0,0,},
         {0,1,0,0,0,0,1,0,0,0,},
         {0,1,0,0,0,0,1,0,0,0,},
         {0,1,1,1,1,1,1,1,1,1,},
         {0,1,0,0,0,0,1,0,0,1,},
         {0,1,0,0,0,0,1,0,0,1,},
         {0,1,0,0,0,0,1,0,0,1,},
         {0,1,0,0,0,0,1,0,0,1,},
      };


Then you can either devise a way to generate levels, or put in preset levels.

I would make it so that a "99" or some number bigger than 0-9 represents a black space, then simply add a new Black object to an ArrayList and cycle through it, checking if it got clicked on or changed or whatever.

-Nathan

Check out my website!
Offline Marbink100

Senior Newbie





« Reply #6 - Posted 2012-03-08 02:00:05 »

Thanks! I'll try it out  Wink

Check out ZOVE Games!!!
It's a site by me and some friends!
Offline StonePickaxes

JGO Coder


Medals: 4
Projects: 2


Nathan Kramber


« Reply #7 - Posted 2012-03-08 02:02:58 »

No problem! This might help too: how to check through the array for the blank spots -

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
for (int x = 0; x < ROWS; x++)
      {
         for (int y = 0; y < COLUMNS; y++)
         {
            mapData = level[y][x];
           
            if (mapData == 99)
            {
               EmptyTile e = new EmptyTile(e);
               e.setX(x);
               e.setY(y);
               emptyTileList.add(e);
            }
         }
      }

Check out my website!
Offline Marbink100

Senior Newbie





« Reply #8 - Posted 2012-03-08 02:05:39 »

Thanks again! Grin

Check out ZOVE Games!!!
It's a site by me and some friends!
Offline ra4king

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #9 - Posted 2012-03-08 02:37:57 »

Or, simply just have a 2D int array that holds the visible numbers (0-9) and the not visible ones (-1 to -10, where you negate and subtract to get the right answer).

This way, a block, horizontal, or vertical check is extremely simple.

Also, when rendering the table, if the value is < 0, leave that cell blank Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline UprightPath
« Reply #10 - Posted 2012-03-08 02:41:54 »

That's dangerous. You'd have to have two different arrays to hold the data then and match them up.

Because otherwise you can just put in values until it updates correctly to complete it!

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (72 views)
2014-11-26 15:22:04

toopeicgaming1999 (62 views)
2014-11-26 15:20:36

toopeicgaming1999 (15 views)
2014-11-26 15:20:08

SHC (29 views)
2014-11-25 12:00:59

SHC (27 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (27 views)
2014-11-24 19:59:16

trollwarrior1 (40 views)
2014-11-22 12:13:56

xFryIx (78 views)
2014-11-13 12:34:49

digdugdiggy (56 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!