Sunday, March 4, 2018

2048 Clone in Java, a Journal

I am revitalizing this blog to try and keep track (and think through) design choices with my next project in Programming 2. The first two projects were mostly a flop, and I wondered out loud to my friends if doing this would help me stay on track. This is essentially a rubber-ducky journal. If it helps anyone else, that's awesome, but it is mostly for me.

Our goal is to create a version of the math game 2048 with a themed spin on it. The theme we are assigned as default is Star Wars, but if we can come up with another theme, it will be an extra 5 points.

The original 2048 can be found here: http://2048game.com/
The Star Wars version we are mimicking is here: https://0x0800.github.io/2048-STARWARS/

I'm only starting to set up my class structure, of which I've determined I need at least 3 things.

  • The Game class will handle:
    • Game States - currentGame, gameOver (gameWin and gameLost), restartGame
    • Current score and best overall score
  • The Tile class will handle:
    • Tile borders and whether a tile can combine with another tile
    • Tile values
    • Tile colors/symbols
  • The Board class will handle: 
    • Number of tiles on the board
    • Tracking tile positions
    • Tracking empty tiles
    • Spawning new tiles
There is also an FXML document and a Controller class, since we're using JavaFX and SceneBuilder to create the UI and handle animations, soundFX, and music. Here's a rundown of what the game should have:

  1. Background music
  2. Animations
  3. Sound effects for each piece
  4. Tile must be abstract
  5. Must use an interface
  6. Must correctly keep track of current score, high score, and if the game was won or lost
  7. Bonus: A HELP function that will highlight possible moves
  8. Bonus: A theme other than Star Wars
  9. Bonus: A SWAP (cheat) function to allow for the swapping of two tiles
What I would like to add is an extendable panel that will display the values of the pieces, since we'll be working strictly with symbols. I think I can do so with the Gluon Navigation Drawer, but I'll need to research how it works and make sure it will do what I'm envisioning.

I'll update with my progress as this week goes on. Hopefully, with it being Spring Break for the next week, I'll have plenty of time to get some of the structure hammered out!

Sunday, March 26, 2017

Character Creation Design

Something I would like to do for my Introduction to Programming class is write a prototype for a character creation dialogue. I don't think my instructor will be requiring a final project, but this will be a good way for me to practice applications to game design and I can use what I learn from it to apply to the codebase I'm working with now.

The code I'm using has support for guest accounts and normal user accounts, which we'll call subscribed users. The flow of connection would be as follows:

Splash Page
|
Account login or creation
|
Character login or creation

Starting from the creation option of Character login or creation, the dialogue will proceed as follows:

Choose your character's race:
Elf, Draconian, Halfling, Human, Ogre, Dwarf, Gnome, Minotaur
If there is a subrace, select subrace:
Elf (selection of 5 subraces)
Draconian (selection of 5 subraces)
Dwarf (selection of 4 subraces)
|
|
Choose your character's class:
Warrior
Rogue
Naturalist
Mage
Tradesman
(Each of these base classes will have customizable skillsets that determines their specialization; with these specializations, there would be up to 20 different classes to choose from. I feel like this will reduce complexity during character creation)
|
|
Choose your character's gender:
Male
Female
|
|
Choose an alignment for your character:
(No selection defaults to True Neutral)
Lawful Good | Lawful Neutral  | Lawful Evil
Neutral Good  |   True Neutral    |  Neutral Evil
Chaotic Good  | Chaotic Neutral |  Chaotic Evil
|
|
Choose a starting region:
(This dialogue will allow for players to experience different parts of the game, no matter what race they begin with. I plan on having NPCs who react to some races differently than usual, such as if an elf decided to start in the Dwarven region.)
|
|
Select a name for your character:
(This dialogue may move up to follow the character gender rather than coming at the very end. I wonder if players rather make all the choices they can before deciding on a name, or if they would rather name a character before making decisions such as alignment and starting area.)
|
|
Write a brief, 2-3 sentence description of your character (optional):
(This step could be skipped, but to give a player the option to describe their character in a text-based game before they even enter the game would be beneficial, I think. Some can't come up with descriptions on the fly, which is why it would be optional. I would try to work some code in that would check the description area and post a reminder at, say, level 10 and beyond, alerting a player to an empty description field.)
|
|
Entry to the game

Each step of the way, there would be an index of dictionaries for each term, and hints to use these dictionaries (i.e.: Type "help race" for more information.). These dictionaries will have entries for each race, each class, each alignment, and each starting area. There will probably be an entry for name suggestions and description advice, too.

This is the basic structure I'll be trying to achieve with the character creation program, and what I'll be aiming to write before the end of the semester. Hopefully, I'll be able to integrate it into the codebase that I'm working with, although it's written in Python 2.6 to support some dependencies. I'll have to submit this for class in Python 3.5.

Tuesday, March 21, 2017

Talking Projects

I consistently brainstorm about the projects I want to see completed. The one that I think about the most is a MUD that I want to play around with.

I've thought about all sorts of features I want to implement, but one of them that has surfaced over the past couple of weeks is the ability to roll a character as customized as you want it to be, and at any point, randomize the rest.

Say you have 5 steps in character creation:

Step 1: Choose your name
Step 2: Choose your race
Step 3: Choose your starting class
Step 4: Choose your stats
Step 5: Choose your alignment

Kind of a simple creation, but say you know you want a human thief named Doug and you don't care about the rest. I think it would be great to have a randomizer (aside: one that won't fuck you over as you progress through the game, which would take quite a few verification checks on each class so someone can't roll a mage with 2 int and 18 str).

Part of the reason I want this so bad is because I have been captivated by the idea of customizable coded and non-coded traits. By this I mean:

Coded: Abnormally tall (+height), abnormally short(-height), clumsy(-dex), diplomatic(+cha), strongman(+str, -dex), agile(+dex, -str), etc.

Non-coded: Drinking problem, hates water, afraid of sleeping outside, talks too loud, etc.

So there could be aspects of these traits that benefit a character, others that detriment in one way or another, and some that just make the character overall more interesting. While that would invite specific traits to be selected all the time by those who are only concerned with big numbers, the prospect of having a "random character generator" for anyone bored and looking for inspiration could be a fun aspect, especially for a MUD, wherein much of the draw is the RP element.

One of the more evil ideas I came up with while brainstorming some of these traits was a "lack of sense of direction" trait, which would remove the (north, east, south, west, up, down) exit lists at the bottom of rooms with (exit, exit, exit, exit, exit, exit). It wouldn't randomize the exits, partially because I think that would be a pain to implement and I wouldn't want it to be IMPOSSIBLE to play a character with this trait, just slightly more interesting.
I am absolutely certain that if I successfully implemented something like this, it would be never be picked. But it amuses the shit out of me and I might do it simply because of that.

Another thing to mention would be the inverse relationship between "negative" traits and "positive" traits. Pick a trait that will negatively impact your gameplay, such as the example above, and more positive traits become available for initial selection.

Tuesday, December 27, 2016

Catching Up on Life Things

My interest in programming has not waned over the course of these last months, though I consistently hit walls and take extended breaks from learning anything new. It is the harsh struggle of learning something without the looming threat of deadlines or the presence of a mentor.

While I feel as though I haven't made much progress on my own, I have taken steps towards securing my learning capabilities. I've enrolled in courses at a new STEM school locally. Well, sort of locally. I commute an hour to attend, but my degree concentration is Computer Science and Game Design. I am well on my way to having a well-rounded education on software engineering with a focus on what makes games what they are. I would have never imagined pursuing a Bachelor's degree in Comp Sci when I graduated from high school.

My first semester left little time for me to pursue anything programming-related (damn prerequisites), but now that the semester is over, I've been cramming everything I can get my hands on about C, trying to beat the clock on these last two weeks of winter break before I start back in with a Python introduction course. My school won't teach C, but will instead jump from Python to C++ to Java. It doesn't bother me, though. C and C++ are both powerful in their own ways and I'll only benefit by learning them both. I figure I'll just skate through Java and apply the programming theory I learn to the other languages I know.

Still, I've come to realize that blogging about programming was helpful while I was actively posting about a couple of years ago. While I work on a personal project related to MUDs, I'll start trying to more actively discuss what I'm learning. So, yay! Activity!

Other life-things going on? I'm happily married now. My husband and I live with my best friend and we play Overwatch together A LOT. I lowkey enjoy Widowmaker but I'm a Zenyatta main. Might be getting back into GW2 or World of Warcraft (???) if school and projects allow, but it's probably not the greatest idea to do either of those things, considering I already moan about not having time to do stuff! I've also discovered that having just a few years of art experience has made me very valuable at school, and I'm glad to have a bit of versatility. I've done more art for game projects this semester than I thought I would and it was a lot of fun. I may post some of those up here. Since the last time I posted, I found a new favorite book series (Patrick Rothfuss's "The Name of the Wind") and I have written an enormous amount of prose for my own characters, as well as designed some content for the eventual MUD I will host.

Will I get around to posting again today? Who knows! But the next post I make will definitely be more interesting than this one.

Monday, March 7, 2016

From October 2, 2015

I apparently had this written back in October of last year when I was working on a calendar program in C, but I never posted it because it was titled "To be written tomorrow..." and I obviously got fucking distracted. Anyway, here's my (very likely hackish) calendar program.

After mulling over this ALL day, here is the answer I've come up with for this programming project.

/* Write a program that prints a calendar. */

#include <stdio.h>

int main (int argc, char* argv[]) {

    int days_month, week_begin, var1, var2;

    printf("Enter the number of days in the month: ");
    scanf("%d", &days_month);
    printf("Enter the day of the week the first day falls upon (1=Sun, 7=Sat): ");
    scanf("%d", &week_begin);

    var2 = 1;
    while (week_begin > var2) {
        printf("   ");
        var2++;
    }

    for (var1 = 1; days_month >= var1; var1++, ++week_begin) {
        printf("%3d", var1);
        if (week_begin >= 7) {
            printf("\n");
            week_begin -= 7;
        }
    }
    printf("\n");

return 0;
}

I looked up the answer in the book answer key and 50% of my program is almost identical to the author's program. Woohoo!
Unfortunately, that last gnarly bit with the if statement is vastly different from his. He used all sorts of maths like remainder and variables - 1 * variables to get his answer. I can't see the relationships of numbers quite that easily... yet. :(

How to Learn How to Program on Your Own Time

An observation from a girl who is trying to learn how to program in her own time

  1. Read books about programming languages
  2. Read blogs (/subreddits/forums/mailing lists) about programming
  3. Be inspired by the big picture constantly
    • Even while working on the little shit
  4. Don't get distracted
  5. Write one-off programs 
  6. Read more books about programming languages
  7. Read more blogs about projects that you are interested in
  8. Don't get distracted
  9. Read other peoples' programs
  10. LOTS of other peoples' programs
  11. Write more programs
  12. Don't get distracted
  13. Think about programming in your spare time
  14. Theorize how a bigger program might work
  15. Write said program
  16. Fix all the bugs in said program
  17. Don't give up
  18. Don't fucking get distracted
I swear, I would be a hell of a lot further along if I could stop playing the same games that are inspiring me to learn this stuff. I feel the same way about this as I have about every musical instrument I have ever tried to learn -- yeah, I know where the keys are and what they do, but not really well enough to put together anything that sounds decent. Damn practice, why u b so hard??

Thursday, September 24, 2015

Roguelikes

I keep threatening to post about the additional research I've been doing, but I'm so wrapped up in reading about it that I have yet to actually write a post.

That, and work has been a little harrowing. Everyone has wanted their projects completed by Friday this week, which crunches our schedule into a "drop-everything-else-that-was-not-immediate-and-do-this" nightmare. When it's one out of every ten jobs, this isn't an issue; but when it's six out of ten orders, it gets hairy.

Enough about boring work.

The title of this post may have gotten some attention already. Either you are wondering why I would stick those two words together in such a bizarre way, or you are wondering what it was that I found pertaining to this particular style of game (default: neither of these things, just get on with your point).

Roguelikes are a type of game that is based on the 1980's text-game Rogue. They encompass game features such as procedural map generation, turn-based gameplay, and sometimes permanent character death. More information can be found here (Wikipedia) and a basic chronology of roguelikes can be found here (also Wikipedia).

Anyone who has been around this blog for a while knows that I'm enamored with the design of MUDs. Roguelikes began in 1978 with the release of Beneath Apple Manor, the same year that MUD1 was released in England. Both styles of game have their own appeal, though MUDs are by far more intensive as far as content generation goes. I assume that part of what makes roguelikes so popular is the lack of a need for so much manual content generation. The maps of the earliest roguelikes were made up of text characters, as shown below.

Source: http://www.kathekonta.com/rlguide/index.html, which will be mentioned shortly in detail

The classification of roguelikes gets a little bit convoluted, considering there are a large amount of games out there that share some of the same qualities, but not quite all of them. Some argue that Blizzard's Diablo is a roguelike, and others say otherwise, and there are many other cases like this. But these games led to a genre of dungeon-crawling games, of which the goal is simply to traverse the generated maps, find all the goodies, and kill all the bad guys.

I was having a lot of fun doing my research about roguelikes. Somewhere in the midst of it, and I don't know what inspired me to do it, but I typed "how to program a roguelike" into Google.

I have been thrilled with the results.

First, I have to shout super kudos to my first resource. This guy took personal time to write, very candidly, a step-by-step process of programming a roguelike. And the advice he offers in this guide is not specific to roguelikes; it is advice from a professional in the field who is imparting some hard-learned lessons from his experience in software development. I think I find that equally as impressive as the time he has spent writing the guide.


The guide is not complete, partially because of some issues in his platform (look on his blog for more information). Regardless, the 9 articles he has completed are packed with great information about developing a roguelike (or any program) with good structure and clarity.


I also found this article on RogueBasin, a wiki page dedicated to the roguelike genre. It does not go into anywhere near as much detail as the Beginner's Guide does, but it covers some really great points and gives something akin to a checklist for anyone planning to develop a roguelike. I enjoyed some of the considerations mentioned.


Of course, I have to post Archive.org's MS-DOS library. I think it is so neat that they have so many old games available to stream on their browser emulator. Here is a link to a playable version of Beneath Apple Manor, if anyone is interested in traveling back in time.


That about does it for me for today. I want to dive back into my programming exercises in the next couple of days, so hopefully I will have some progress to write about thereafter.