Pages

Summarize Your Life.

2017/03/03

SHALL WE PLAY A GAME….

Lately I’ve really been giving some serious thought to creating my own Java 2D game development tutorial series on YouTube, more specifically related to making a roleplaying game engine, and even further related to a more “advanced” level of things.

I’ve seen dozens of individual series, hundreds or perhaps even thousands of individual game-development videos, and I’ve even recently been commenting on a few of those said videos. I don’t want to complain, but many if not most of these series have been leaving things at a very basic level, when I know for a fact a lot of commenters are asking for help with more advanced topics and aspects of development. Well, why don’t I try to fill some of the void?

Also, my intent for the last few years was to work on something larger than the small-time projects that I have been tinkering with, all along. It is at this point in my development life that I believe I have all the required technical skills for following through on this.

Time and time again I have made reference to the old “RPG Maker” system – comprised of an engine, an editor, and a common platform of data files – which anyone can use to build a game. More specifically, the idea that I can and should begin making an open-sourced version of this (call it a clone if you wish, but I intend for it to be much, much more) but in Java. I had even begun a GameDev.net blog/journal in which I had a few blog posts; I had also created some repositories on GitHub with a handful of repositories.

But now I am thinking  that I should also try my hand at narrating the development of said projects. I am beginning anew and working through a modular development process in programming my own editor, engine, platform, and any other collection of Java libraries which are required for a completed rpg maker software to work.

So. I understand the process of creating a Java game engine and the classes associated with such; I have been working in Java since well before the turn of the century, I have watched an almost-endless supply of game-dev tutorial videos, and I have now started creating my own organized list of topics for the order and style of topics to be covered in my game. I’ve asked a few people on their experiences with streaming or recording to YouTube, and I think I have a decent picture of my options.

Yes, my tutorial series will begin with the basics of a game engine, the main game loop, game state management, and also the modular aspects of a game engine, but I plan to follow through on developing the editor as well, something which rivals the old static RPG Maker editor. Further, because everything in the RM series up to and including VX Ace allowed no extension to the editor, I am planning on showing how a Java SPI implementation can be done that allows third-party developers to extend both the engine and editor, allowing for more rounded system development.

All things are almost ready to begin my recording sessions and uploading to my YouTube channel; just a few points need to be finalized first.

2017/02/27

Another Hot Mess

Alright, just on the heels of the recently-released previous post -- a couple hours ago, give or take -- and watching more game development videos has sparked another chance to ramble on about a couple personal pet-peeves I notice other developers using.
I see this first one from time to time in code; using an if/else to return a value from a method, specifically for a boolean return value.
if(someCondition() || i > 0) {
  return true;
} else {
  return false;
}
which in any recent Java version this side of the Kessel spice run, could be simplified like this:
return (someCondition() || i > 0);
and the boolean state will be calculated and returned the same as the beginning code. It's simply that the second version does look neater, and is somewhat easier to type. Why not be nice to your fingers?
And then, for the second bugaboo. In cases where an if condition is used maybe correctly but somewhat "appears to be" not as orderly as could be. In for and while loops, if the if statement is to specify that execution should continue to the next iteration, then why not invert the if statement and just enclose the remaining lines within the loop inside of the rewritten if?
for(Room room : rooms) {
  if(room.name == "kitchen") {
    continue;
  }
  // Additional code performed if not the kitchen.
  // Can be as complex as you want it.
}
could instead be simplified to not say "continue" but instead check to see that it is not the kitchen, then perform the tasks that would be skipped if it were the kitchen.
for(Room room : rooms) {
  if(room.name != "kitchen") {
    // Additional code performed if not the kitchen.
    // Can be as complex as you want it.
  }

}
It isn't often that I see this, but, there is one more special instance that does bug me, and it's the case of constraining or clamping a value to a minimum or maximum value. I know this happens often enough (in some game entities, the X and Y positions maybe modified and constrained at least once per game tick), and the code might actually look a little cleaner if it could be rewritten a bit.
Well, every game project is likely to have at least one utility class with static methods, and the following clamping methods are sure to be one that you want to add somewhere. I also borrow from my first example in this post in some of it:
public static final int clampMax(int value, int max) {
  return (value > max) ? max : value;
}
public static final int clampMin(int value, int min) {
  return (value < min) ? min : value;
}

public static final int clampMaxMin(int value, int max, int min) {
  return (value > max) ? max : (value < min) ? min : value;
}
That third one looks like it would be useful for a lot of game entities and other objects; let's examine the case of constraining an entity's X and Y coordinates on a map. If these methods were included in a class named UtilityStatics, then usage of the last method might look something like this:
posX = UtilityStatics.clampMaxMin(posX, world.maxWidth, 0);
posY = UtilityStatics.clampMaxMin(posY, world.maxHeight, 0);
Depending upon how the lines were spaced out or wrapped before this, this could give you a savings of maybe six lines of code in each entity, just by simplifying the update tick constraining to a templated static method.

About Those Java 2D Game Development YouTubers...

It has been a while since I last posted here. A LONG while. But in a sense, that's good; because now I'm starting with fresh content. In specific, I've been following a few Java game development tutorials playlists on YouTube, and boy oh boy do I have a few suggestions...


First things first. I've known Java programming since around the early-1990s, at least picking up the basics at the time I was a high-school senior. I had not really done much with it since, making a few hobbyist things -- rpg utilities, dice-rolling class libraries, general gaming support classes, et cetera, and so forth. Yeah, I've been around, so I know things -- but I still keep in touch with plenty of game-dev noobs, to help them the way someone else helped me. Don't believe that I know everything about everything; but please do that I do have a lot of experience, I've learned from obvious mistakes, and I also want to help you too.


Second things ... eh, second? I really have seen some hot-and-heavy commentary going on in the past about "which is the best IDE", that often devolves down into "absolute proof" pointing out the features of one over another. I'm not about to be dragged into such a debated topic, but I will say that my personal choice is NetBeans IDE, because in my case it's allowed me to be much more productive in coding and refactoring. But the point here is, try a few different IDE programs, and see which works the best for you. Watch a few YouTube tutorials seeing active development taking place with each of them, get a sense of how the program may or may not fit you as you would type code


Third? On to the meat of the feast; now I'm getting closer to the "Java game dev" aspect, but I suppose I should also mention the rpgs. I have also -- either fortunately or unfortunately, take your pick -- played as well as developed with a software tool/infrastructure called "RPG Maker" by a tiny little company called Enterbrain. Being someone who loves to tinker with roleplaying games, on the tabletop as well as digital domain, I have dug around to see what this RM craze was all about. I've dug deep into it from the VX and VX Ace days, and then also gone back to the XP days to get some context of how things were. Feel free to try other, non-Java-development things, just to give yourself alternate perspectives and ideas about what is out there.


And now, it is comes down to this. I mention I have been watching some YouTube playlists over the last few years, yes? Well, all along I have been leaving comments below the videos pretty much alone; but lately more than ever I've been on the mindset that "Why not respond to some? The questions are there, the channel owner isn't all or even most of the comments, so ... why not use some of my expertise to help out?" -- With various results as you might expect. Eh, "you win some, you lose some", but I don't let it get to me.


So. This thing. "Java 2D Game Development Tutorials". -- If you have ever created such a series, or even watched or followed along with the videos, you begin to notice many patterns: patterns that I will, time and again, mention and provide experienced commentary upon.

The Introductory Video(s).

One necessity, of course, is in saying who they are, maybe where the series is going, perhaps a specific design goal or purpose behind why such a series is being developed. In some cases a video tutorial series might be the person's second time through a development series, a "reboot" of sorts, where they admit momentarily how lost they got along the way of developing the precursor series.


Or, sometimes the YouTuber or streamer does not really go into the logic or pacing or even order of their video series; in such cases, the viewer can only ascertain such things from commentary and example from the video content itself, as time passes. If the viewer is lucky, perhaps the YouTuber might have a defined list of objectives or modules through which the series will proceed; and if the viewer is extremely lucky, perhaps the 'tuber might illustrate and explain his or her thoughts and style of it all.


(For an aside-comment, I don't really care if the speaker is male or female, young or old, of this or that nationality or skin color -- I only care that the person making the video has some natural cadence or rythm in their speaking ability, and enunciates the words as clear as can be expected, given their computer, microphone, and assorted recording equipment. I do wish that more of the YouTube tutorial series were eloquent English-speaking females -- not in support of any damnable socio-political agenda that may be out there, but only because I wish to hear it clearly, and if I were a betting man I would bet that a higher ratio of females than males can speak more eloquently, I am betting on the female voice itself as providing a clearer tutorial than many male speakers.)


And this mythological premiere video might also tell which IDE or development infrastructure that the video maker is using; I am not surprised that the majority use eclipse as their tool of choice, but I am thinking it's deplorable that it's the only tool they describe as what to use. Really. The development world has many, many MANY more than that; as mentioned above, I use NetBeans IDE, but I've also seen Jetbrains, and many others. Heck, a developer could even really use a plain-text editor to create the classes if they so chose; but such a person is betting on their own development skills (which might not be as perfect as they think). I would rather hope that a developer would use a proper IDE which provides syntax-coloring, highlighting, error-detection, and refactoring support, but that's just me.

Jumping Into Coding Classes.

And then, it gets right down into it. For the realm of a Java 2D/tile-based game development series, you will absolutely detect a series of opening development videos in common with almost everyone else doing the same thing. The first stop on the development train just so happens to be in creating the project, creating the "main class", and then creating the "main game loop", in this order. If the video series is a collection of short (less than ten minutes each) videos, each of these steps might be in separate video, each aspect described ten ways to Sunday. Sometimes it's more of a hodgepodge of talking and defining things that a student of Java programming should already know, sometimes it's literally as terse as copy-pasting some templated code and making a few alterations.

Start With a Main Class.

One point that irks me, and I admit it, is that the developer typically makes the main class also hold the main game loop. Well. While that is not breaking any Java coding techniques, technically I prefer to break this apart somewhat. So a class that looks like this


public final class Main extends Canvas implements Runnable {
  // some fields and methods to get to the main game loop etc.


  private Main() {}


  @Override
  public void run() {
    /* game loop code */
  }


  public static void main(String[] args) {
    /* instantiation code */
  }
}


could be broken apart a little bit so that it only starts with the static main method. In my implementation, I have that "extends Canvas implements Runnable" and game-loop methods in one, or sometimes two, separate class, the precise methodology depending on what I'm intending, and that might change from one project to another. No, this "main class" in my opinion should only serve one purpose: instantiate the game engine by first examining any passed-in arguments in a private static inner class, within the Main class


public final class Main extends Canvas implements Runnable {
  private Main() {
    // instantiation code, no args found, "normal" startup
  }


  private Main(Args args) {
    // instantiation code, args found/parsed, handle or pass along
  }

  public static void main(String[] args) {

    // more code;
    if(args != null || args.length > 0) {
      new Main();
    } else {
      new Main(new Args(args));    }

  }


  private static final class Args {
    // maps or array-lists of parsed command-line arguments
    Map parsed;


    Args(String[] args) {
      // constructor, parsing implementation
    }
  }
}
If the static main method detects that the args parameter is null, the private constructor is instantiated and execution proceeds from this point; else if the arguments are not null,  an Args object is created and the arguments are iterated through, attempting to parse each one as a potential command that may be pushed along into the game, and the second Main constructor is the method to pass it along.


The point is, maybe the developer wants to optionally enable or disable certain "debugging" aspects in a play-through of the game engine, perhaps even based upon whether this is a debugging session or is a "released" game; and having a command-line parser object can be helpful in this regard. Whether it's to output to "System.out.println()" some text or help information, or to change some down-stream execution roles or properties (maybe screen width, height, or scale), specifying some String arguments can be very helpful.

Main Game Loop Logic.

I also see a lot of "copy-paste" of the main game loop logic; sometimes, the developer actually does explain a bit about game ticks (updates), rendering, and perhaps even a touch of thread operations. The techniques should also make clear just why it is important to have a steady frame-rate across all computers; if the game will contain any multiplayer or an online aspect, then game synchronization will be a very real necessity, although most Java game tutorials will not get into this until later.


The concept of game states and then game state management is also very important. I learned this concept years ago, even before exploring into the RPG Maker game editors/engines/platforms, but it did surprise me how well those RM creations did the state management in the Ruby scripting classes.


Basically, each aspect of the game is a state, typically subclasses of an abstract State class: the title screen, the menu screens where a new game is started or loaded from file, or even saved to disk, the tile-map instance being played upon is a state, and even game-over (win or lose) screens are game states.


Sometimes the concept of states are introduced right after developing the main game loop, sometimes not until a little while later; but often the tutor begins hard-coding some game map, some entities, some objects to get the viewers' understanding on a roll. In any case, after getting to a more-or-less-final "game loop" code, the sooner the coding gets to creating a state system the better, and the sooner both the tutor and viewers can go on to deeper topics.

Assets, Resources, and Referencing Objects.

This is sometimes the very first point at which viewers who follow along really start having serious problems. It is at this point that the introduction of images being used as sprites, animations, map tiles, et cetera. And, for some people who make a simple mistake or two, the errors start building from here.


It's not that the viewer is in any sense stupid or lacks an ability to follow the tutorial; it's that perhaps how it is described how Java handles reading in these graphical assets, and how the IDE handles the project structure, that might be confusing. I have seen well-typed source code that is, shall we say, a little less well-described in narration?


The basics are this: the Java class ImageIO is used to obtain a reference to a PNG image file, which is assigned to a BufferedImage object; then the image may be held in memory and used later on in displaying something to the screen. But, where exactly should these graphics be placed in the project?


Back to thinking about the IDE that might be used -- most people may use eclipse but this applies mostly across the board. A typical Java project will be created and instantiated with the primary Java source path, typically a folder named "src" under the project's root, and maybe optionally a primary testing-source path, a folder named "test" also under the project root; but unbeknownst to many beginner Java coders is just how extensible this (Ant-based) is to add to.


Underneath the project root may be one or more files, sometimes hidden or not shown within the IDE itself, to discourage accidental editing by the developer -- but these files are still there, on the disk under the project path. They may contain dozens, hundreds, or even thousands of lines of metadata and project description, often in plain-text like an XML-based format. Well, we still don't need to edit these metadata files by hand -- normally -- because our IDE's project explorer should make it easy enough to select our project's Project Properties dialog and tweak it as necessary.


And so it is at this point, that in an attempt to keep the Java code files separate from the non-code is made. These are assets, like binary font files, images of all sorts, sample game data like textual map definitions, and other plain-text or even binary files as necessary. The YouTuber or streamer makes at least some attempt to descriibe what to do, without perhaps going deeper into the why it is done this way; but it really does boil down to creating a folder path under the project root, and then manually adding it into the project definition files, either through the project dialog or via manual editing.


One tendency I have noticed is that this "resources" folder is mistakenly added into the project's source packages, as if the "res" is part of the package being included, when really "res" should have been added upstream from the "src" folder instead, so that both "src" and "res" are "sibling" child folders within the project root path. And then, the images and non-code assets are placed into this "res" folder.

What About That Slash?

Yes, the use of the slash character in universal resource names and addresses is in fact very important. By default I will use the "forward slash" (the top of the slash leans to the right of where the bottom of the line is) in such Java String asset references. Since we are referring to a URN that will be found within the final built jar, we begin with a forward-slash, then the name of the resource package (each folder level being separated only by an individual forward-slash), and ending with the actual file being referenced (with the actual file-extension).


Any spaces in folder or file names should either be removed, or substitute a "%20" for every single space in the reference string. Better yet, just do not be in the habit of including files which have spaces in their names to begin with, because it may be a source of headaches down the road.


Having a fonts package within your resources path that contains for example a Consolas.ttf font file, we will have the following static String reference to be loaded:

"/fonts/Consolas.ttf"
and it will be loaded properly, with no error. I really do not know how I can describe this any easier, yet I still see questions in YouTube comments that show examples of resource references beginning with "/res".

And Time Goes On....

Each successive video in a tutorial series, I now see quite a few comments about "when will you develop x feature" or "how can I do x in my project". It's understandable, but often this is the viewer getting impatient about getting into some "really interesting" facet of game development.


At its core, most game-development tutorial series are about learning the basics of Java coding, especially where it comes to game development. And then, viewers have an idea about perhaps a specific subgenre of game that they want to see developed, but which might not be within the scope of the actual tutorial series, but which few other game development tutorials are taking on themselves. It's rather easy to see and understand why, the tutor is trying to get as many started in a game development format as possible, and hope that the viewers take it and do something impressive on their own.


It's at least whimsically funny to me that at least half of the requests of "how do I" topics are either in developing a 2D "platformer" style of game, or an RPG where entities and characters than the viewer has dice. Having already mentioned near the beginning of this already-lengthy post my exploration and excursion into the RPG Maker series of editors and engines, I must admit that I too have searched YouTube for Java dev tutorials that went in that direction.


Yes. I want to make an rpg-maker-like game engine, editor, and platform infrastructure in Java. Technically, I already have, having followed through so many Java game development tutorial series from other YouTubers, and adapting and refactoring code so many ways to Sunday, that I've had a patchwork-quilt hodgepodge of Java class libraries full of ... well, almost everything necessary to make an RPG Maker.


I don't know what more to add here, other than that I shall attempt to add further posts to this old dusty blog, wherein I think, and think, and type out lengthy posts on incredibly mundane as well as interesting topics related to game-development issues that I have happened across. Follow me or not; comment or not; but I shall at least try to bring a conversational style to this, and try to foresee what common Q&A topics as necessary. So, ... "into the breach, dear friends", and join me on an interesting journey.

2013/03/05

Um, I realize I haven't posted in a while, but....

I'm rather befuddled at some of the sources of traffic to this blog. Now, I realize I haven't done much of anything with this blog in a while, but is it suddenly a "thing" for odd niche-market porn sites to be the previous site before coming here? (No, get your mind outta the gutter, and ... ewww!) I've no desire for traffic to come from such sites; I'd rather get a more thinking crowd to communicate with.

But really, why is it that every time I turn around that pornographic matter is suddenly being pushed my way? I don't need it; I don't know anyone who really "needs" it. Is there some kind of stealth tagging going on, and if so, why am I getting this junk? I realize I'm a single thrity-nine year old male with healthy emotional and intellectual drives, but ... the extent of porn out there is just ... "out there". Bizarre. And not even pretty.

How can I stop people from visiting this blog after visiting pornographic sites? I assume this is impossible, because of the way the Internet is built. Someone mentioned I should just change my profile to say I'm in a relationship, even if I'm not, but I'm not the type to lie like that, even just a little white lie of convenience.

To be honest, I'd rather be getting traffic from people who share a literary interest; someone to talk about reading and writing a large story series in general, and perhaps even  in a unique science-fiction universe in specific. I know, I already have a Facebook page for my writing stuff, but I also know some people no longer use Facebook, or who already follow blogs through the Blogger platform, but I've left this open in case I felt like posting here

So. Here's what I'm gonna do. I will give it two weeks, during which time I shall strive to post at least once every two days, some kind of posting related to writing or my story series. Not that I will be perfectly on schedule, but I will try.

2011/06/13

Starship Says It’s Not Over (‘Til It’s Over)

As I'll say time, and time, and time, and time again, I am a reader and viewer of science fiction. In one forum, I happened to want to write out a long commentary about one aspect, but decided to write it here, instead of there. Forgive the interruption in the otherwise-story-writing theme. On SciFi-Meshes.com, a site where sci-fi enthusiasts can post their endeavors for modeling objects, I commented about Star Trek versus Gene Roddenberry’s Andromeda, especially that I felt the latter was a story universe that could be worthy of the starship model being designed.

[QUOTE](Funny to say this, but: I consider Andromeda as having "fixed" everything that is "broken" about the Star Trek universe, but for obviously different reasoning;[/QUOTE]

I wish to clarify my own words: I am not attempting to diminish all that is the Star Trek story universe; the JJ Abrams snafu did that on its own. But I certainly think the Andromeda universe (actually, comprised of three galaxies that are important to the storylines) allows for far more adventure, danger, intrigue, and overall story possibilities than Trek did/does. While I presume parallel compare-contrast reviews already exist, I'd like to offer this interchange as a definition of the key differences.

Compare the Background Stories.

Star Trek started as, and has mostly remained, primarily a "wagon train to the stars" story. If examined objectively, it has a pseudo-colonial feel to it, even into the Next Generation era; that is, it exists as a stand-in for some undefined future civilization to develop from. The Federation Star Fleet is more akin to the cavalry troops in Dances With Wolves, in that it explores and patrols the "wilderness" that is space.

The Andromeda story, on the other hand, is that the universe had a cohesive civilization, and ... it fell apart, either through the member worlds' or species' arrogance, corruption, greed, or some darker force heating up the universe to re-forge it in the manner of his desire.

It seems to be, what with all the quotes at the front of the show, that the Andromeda universe (before the fall) has been the status-quo for thousands of years, in story terms. So, it has a very rich background. Or, better put: it’s what the Star Trek universe could become, if it existed for the same length of time.

Compare the "Present Situation".

As each series shows the viewer, two very divergent manners of dealing with the universe are presented. The dividing line I base on, is: What is the struggle toward or away from?

  • The pseudo-colonial Star Trek original series' USS Enterprise has a five-year mission to patrol space, find life, learn all that is learnable, (oh wait, that's V"GER, um, the Borg, but both are snap-in analogies for what the Federation really is), find its way back “home”, … essentially "making way" for the future. Starfleet exists … simply to exist. But, what else? It’s a nice story.
  • The "glorious heritage" of the Andromeda universe, in its opening two-part show, presents the loss of civilization and, subsequently, one captain's will to restore what was lost. The struggle is against the status-quo of three centuries after the fall. Captain Hunt, his ship, and the crew exist to restore a balance, to do more than just let things stay the way they have become.

Can the goals of Star Trek stand on their own? Certainly, I’m not denying its role as entertainment alone. But, should it stand on its own? To be honest, an exploration mission (no matter how long) on its own will always be trumped by the goal to restore something that was lost, to rebuild, to fight against a darker agenda (a demon-like, dark-souled spirit, engineering the collapse of freedom from the shadow realm).

The Ending or Moral of the Story.

The plight of civilians, commerce, and industry are also important. Star Trek doesn’t promote the personal freedoms that citizens of the republic which is the United States of America and its partner country Israel live under. But the Andromeda universe is full of civilian and commercial endeavors, and not in the liberalist “capitalism is evil and must be destroyed” kind of mental bent. I am fully appreciative of the freedoms allowed and opportunities offered by the freedoms of belief and choice, and the right to voice such opinions, even if it differs with mine.

I’m not trying to drag current political agendas into this; it's just … as plain as the nose on your face. Whether you subscribe to the "Star Trek is Socialism" mindset or not, it certainly tends to lean on the semi-socialist/semi-utopian trope a bit in places. Trek morality seems to hide a lot of the diplomacy and politicking that must be going on behind the curtain in order for civilization to develop; further, aside from "the Borg" or "Q" or occasional skirmishes, there's no true overarching villain (except that each movie had its own villain) throughout all series.

The Andromeda storyline, on the other hand, was built from the ground up to be a struggle against the aforementioned dark spirit and dark forces that did its bidding. All indications were that this spirit was focused on controlling, on corrupting, and on destroying when matters did not go its way. Much like the progressive-minded political pursuits which seems to be working “behind the scenes” today….

2010/12/15

I'm ... back. Among ... others?

... with a new poll ... at the top.
Okay, enough with the horizontal ellipses. Yeah, it seems like every so often I roll back around to check on what is left of my blog. I've been thinking of the Internet memes that pop up out of nowhere, some staying with us for longer than we would presume possible. The poll perhaps alludes to some of the things that leapt out at me.
But for those who are waiting for me to finish something with either my writing or my software for writers, believe me I have not forgotten; I've just been feeling a little lost lately. I've got to get started again somehow; so, let this be the verse.