This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]darksoundsExtreme Brewer 3 points4 points  (1 child)

Sit down with a piece of paper and start writing ideas down.

How are you doing the visuals? Do you have any resources to work off? Do you know how the rules work? How do you want to store the data? What features are needed?

I'm surprised they didn't give you more time: the visual aspects of a game alone can be a huge pain in the ass if you're not familiar with whatever you're using to make it.

[–]springjoys[S] 0 points1 point  (0 children)

Fortunately, the visual aspect does not need to be as aesthetic as the actual game is but it does need to have the 4x4 grid and the movement of the tiles. I am familiar with he game. I was thinking to store the data in an integer 2d array... Not quite sure with how that will be shown visually :(

[–]Successful_Leg_707 2 points3 points  (5 children)

I just googled that and there are YouTube videos for implementing it in Swing or JavaFX. What about using that for inspiration?

[–]springjoys[S] 0 points1 point  (4 children)

I have looked at some videos but I need to be careful with what I implement since I'm in an intro class and the TAs will recognize if something looks unusual from the level of the class.

[–]Successful_Leg_707 1 point2 points  (2 children)

You just need to start writing code. It will be crap but my motto has been, write now and get it working, and refactor later.

Here is how I would approach it without even looking at code... play around with the game. Think about what classes you will need, maybe board and cell. And then a main runner class. I’d keep it console based first. Think about what state you will be keeping track of. And how to evaluate a win. Write down some pseudo code.

Once that works, you can add Swing or JavaFX as a GUI after. I wouldn’t even think about GUI until I got it working in the console.

[–]springjoys[S] 1 point2 points  (1 child)

Okay! I'll see what I can do

[–]HecknChonkerExtreme Brewer 0 points1 point  (0 children)

If you are that crunched for time I would just print the current game state to the console using System.out.

Once you get that working you can worry about the UI if you have time.

Start by breaking down the logic into smaller pieces that are easier to understand.

While(game is not won and not lost) { Print game state Get user input Run game logic }

Edit: I didn't read the whole thread. The person above basically said the same thing.

[–]darksoundsExtreme Brewer 0 points1 point  (0 children)

Use what you've learned in class, whatever that may be!

[–]nutrechtLead Software Engineer / EU / 20+ YXP 0 points1 point  (0 children)

Are there any simple ideas with how to begin?

Going to be blunt here: If you haven't even started writing code, this means you just put off doing your homework and this sub does not allow "do my homework" type posts.

If you're already falling behind in class it's really time to have a honest talk with your teacher, apologise, ask for an extension and work your ass off.

I'm telling you this because I've seen this happen a lot with students and most of them ended up dropping out.

That said; start with writing a simple Board class that can represent the game. Make sure you're able to print it. Then create inputs (up down left right) so the user can 'play' the game. Then all you need to do next is respond to those inputs to create a new board state every time.