Over the past few months I've been very slowly learning Java and becoming better and better through re-writing this game multiple, around six, times now. This game will, hopefully, be a playable RPG in the future but for now it's just a little project of mine.It's taken quite a while but I managed to wrap my head around how a bit of these things such as collision detection work and so I was able to finally get it working and into the game. Now that that, in my opinion, huge leap has happened I can finally start working on some of the more fun and interesting parts of the game.

Although there isn't much to show, here is what the game currently looks like:

Random Ideas for the Future:

The game will be a top down view just like an old NES style SRPG.

There will be no set classes in the game. You decide if you want to be mele, caster or ranged at the beginning but you can become whatever you want.

The game will be open ended as to allow me to keep adding content.

Current Goals:

Put enemies into the game and have them move around using waypoints.

Create a decent looking map to play on.

Get a custom made player sprite to replace the current one that I ripped off of google images.

Does anti-aliasing work on png images that are being loaded from the folder that the program is running from, if so I'll check out how to use it.

Pixels that are see-through will appear white against another background with .png's... I think it maybe a problem that'll have to be solved in an image editting program like photoshop.

The other thing you may be able to do (not sure, haven't tried) is adding a tiny blur effect to buttons... This might solve the problem. Either way, if it's too time consuming, I would say put a pin in it and come back to it later when the game is reaching alpha/beta testing.

I just did a little test with the blur tools in photoshop, the button is really small so it didn't make a very noticable difference in-game. I think I'll do as you've also suggested, I'll put "Make new buttons!" on my to-do list.

I just did a little test with the blur tools in photoshop, the button is really small so it didn't make a very noticable difference in-game. I think I'll do as you've also suggested, I'll put "Make new buttons!" on my to-do list.

I did a little bit of work today, although I don't have anything new to show I do have a quick question. Is it acceptable for me to have a 'Global Variables' class such as the two below so that I can just use them whenever and wherever I want or will doing this create some obstacle, problem, etc... that I may run into later on?

//All of the global formulas used in the game will be stored here.classGlobalFormulas{publicdoubleattackFormula(intmainAttribute, intweaponRoll, intpassiveSkills, intbaseDamage) {return ((mainAttribute/2) + weaponRoll + passiveSkills + baseDamage); }

Edit: In other news I've finished what I currently need to do on the character creation screen so I've started to try and wrap my head around how to actually create the game. I'm currently reading up on various ways to display and update images but I probably won't have anything working for awhile.

I'll check out those videos when I get a chance. Why is it not good design and what would be a better way to do it; The only other way I can think of using all my variables wherever I want would be an annoyance. I'd need to keep using something like:

It's not good design because it's just not object-oriented at all. I'll grant that OO is sometimes a little bit overblown, but if you're going to write in Java, it's really what the language is heavily geared toward. In fact, throwing everything into a global isn't even good structured programming, OO or not.

I don't pretend to have the teaching skill to introduce OOP, which is why I pointed at those videos (I've not watched them, but I've seen them referred to before). I'd at least consider a class like Player to collect things like name, alignment, level, stats, and so forth. The formulas, I don't know enough about your game to say, but I'd consider a Weapon and Spell class, with

Just so I can figure this out a bit more, here's an example I'm making up based on what I know and kinda-sorta know.

1.) The game is launched and the user creates a character.2.) When the user clicks continue on the character creation screen a constructor in the 'character' class would be fed all of the stats and information from the various variables in the 'characterCreationMenu' class. If I use something along the lines of:

Would I be able to somehow pass around and get the variables from the referenceCreatedCharacter object and work with the variables that way? I'm pretty sure when I google around after I submit this question I'll find a way to do that but the one thing that might be hard to find is the type of object that referenceCreatedCharacter is, it's not declared as an int, byte, short or anything as far as I can see so I'm not sure how to pass it around.

BTW, thanks for the weapon/spell class idea. I think I'll try something similar when I get there after re-writing the program.

Edit: Oh and the formulas are just some simple equations that me and my friends figured out, it works for our table-top game so I'm trying them out in this game.

I'm pretty sure when I google around after I submit this question I'll find a way to do that but the one thing that might be hard to find is the type of object that referenceCreatedCharacter is, it's not declared as an int, byte, short or anything as far as I can see so I'm not sure how to pass it around.

Objects are values like anything else, and you pass them like anything else. I don't want to sound overly critical, but this is super-basic java programming knowledge that you need to get comfortable with, perhaps by following some tutorials or books.

As for wanting to avoid a constructor that takes a zillion args, that's understandable. One thing you could investigate is the Builder Pattern, which would be very appropriate for something like a RPG character where you're literally building them up in pieces. You need to get basic reference semantics under your belt first though.

I'm pretty sure when I google around after I submit this question I'll find a way to do that but the one thing that might be hard to find is the type of object that referenceCreatedCharacter is, it's not declared as an int, byte, short or anything as far as I can see so I'm not sure how to pass it around.

Objects are values like anything else, and you pass them like anything else. I don't want to sound overly critical, but this is super-basic java programming knowledge that you need to get comfortable with, perhaps by following some tutorials or books.

As for wanting to avoid a constructor that takes a zillion args, that's understandable. One thing you could investigate is the Builder Pattern, which would be very appropriate for something like a RPG character where you're literally building them up in pieces. You need to get basic reference semantics under your belt first though.

Constructors and passing around variables was one of the two units in my CS course that I didn't understand at all so I'm somewhat clueless when it comes to working with them without some sort of googled reference. Also, thanks for the link!

Edit: I've looked into constructors a bit more and I'm going to try to re-write my program as to get rid of the global variables completely, I have one question before I'm able to re-write any of the menus. What type of variable would be created from:

1

TestOneTwotempReference = newTestOneTwo();

I need to know because I wont be able to pass the tempReference into the constructor for my actionlistiners to work without knowing the type; Well that's what I think I need to do anyways...

You have to rethink this a bit, it's really not that hard Like Sproingie said objects are values like anything else. And in java everything is an object So passing values around isn't difficult. There isn't really any difference between passing primitive data types and objects.

Well, I just re-wrote everything and got rid of all the 'fields of a class' aka fake global variables. The entire unit in my CS class just somehow started to make sense after reading these comments although I'm not sure how. I've set up the shell of a character class which uses getters/setters as well so I made a lot of progress. ^.^

I do hate to ask things like this, but if anyone has ten or so minutes to do a quick checkover of the code so-far and just make sure that I haven't done anything too badly it would be a great help. ^.^ There is one issue I've begun to notice, but it may be because of the insane amount of code being executed. Whenever I click "New Game" and it executes the 'CreateCharacterCreationMenu' class there will be about half a second or so of lag before the character creation screen will appear. If anyone can figure out a way to fix that little issue that would also help to!

You can ignore the sections with a massive amount of comments in them, I still haven't had the time to go through and erase most of them.

Learn to find errors yourself, you won't be able to rely on other people forever.I don't think there is anything wring with the code (I haven't actually read it yet), because my experience with swing taught me that it is unexpectedly slow at random times.Just get on with the game and worry about it if it gets worse.

Learn to find errors yourself, you won't be able to rely on other people forever.I don't think there is anything wring with the code (I haven't actually read it yet), because my experience with swing taught me that it is unexpectedly slow at random times.Just get on with the game and worry about it if it gets worse.

I'll just do that then, since I don't see errors now I'll just wait until I find one. I haven't used swing enough to agree or disagree with what you've said, but I do think the large amount of code being executed has something to do with it either way. ^.^

The equivalent (not really) of global variables is static variables.But you have to put the classes name in front like this:

1

AClass.AVariable

Static variables are used when using Static classes - they are values of the class and not of any specific class. The best explanation would just be that you put the class name because they don't belong to any (specific) object. Static variables are used like globals in some cases because of the accessibility in many places - as Wikipedia defines it accessible in every scope. Good discussion here: http://www.artima.com/forums/flat.jsp?forum=1&thread=39370

Even static classes have a separate instance per-classloader. This is way way out of the scope of the OP's design questions though, and "stay away from globals" is still a good guiding principle to go by.

As with all rules of thumb, there may be exceptions, but if you're experienced enough to know when to break the rule, you didn't have to ask the question.

Even static classes have a separate instance per-classloader. This is way way out of the scope of the OP's design questions though, and "stay away from globals" is still a good guiding principle to go by.

As with all rules of thumb, there may be exceptions, but if you're experienced enough to know when to break the rule, you didn't have to ask the question.

I don't see when I'd ever need to break the rule now that I have everything working as intended without them.

How did you get along with Swing when your Java skills are that basic?Just wondering

Swing is very easy, I'd say one of the easiest parts of Java. Very self explanatory - import javax.swing.*, make a frame, set the size, make it visible. Other subjects like IO are more difficult to learn imo because you have to choose between byte streams, object streams, etc.

Thanks to a random post I was reading on this forum I figured out how to make a game loop, after that I searched on google for a way to change the code that I already had written for an applet project from my CS class so that it would work in this program. It works, but I ran into a 'freeze' effect which I kinda-sorta know the source of but I'm not sure how to fix it.

If anyone has a sec to help me figure this out then here is the explanation or something like that:

I have a game loop that, just for testing purposes, prints as message every time the thread runs. The code for the game loop is as follows:

gamePanel.repaint(); //Re-loads the JPanel, also known as gamePanel, so that the removed components disappear.TestRendergameWindow = newTestRender (gamePanel);gameWindow.startThread();gameWindow.run(); } }});

From what I can see, the thread is being started too quickly which is causing the 'gamePanel.repaint();' from the 'Continue' button to freeze before the components on the JPanel can be repainted. Although the repaint freezes the thread runs properly and that. Is there some way to stop everything for a around 500 milliseconds so the repaint can work properly?

When I say the repaint 'freezes' I mean that the whole JFrame, JPanel and all of the components become unresponsive so that the only way to stop the program is CTRL+C in the cmd and all of the components stay on the JPanel as they looked when the repaint was (called?) in the 'Continue' button's code.

Edit: I hardly know what I'm doing with the game loop other than some theory's on how I'll use it so if anyone has suggestions on how to change it, please say so!

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