Dan Moody

+ Follow
since Feb 27, 2011
Dan likes ...
Eclipse IDE Debian Chrome
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dan Moody

Stephan van Hulst wrote:There should be absolutely no advantage to this approach, other than lower access times on disk, which is a silly optimization anyway, because you probably aren't even loading *that* many files at a time. As a matter of fact, using sprite sheets may raise the amount of memory used, because you have to load bigger parts of the image at once to be able to extract data for a particular sprite, or you have to write awkward program logic to construct the sprites without loading the entire image into memory, as you're finding out right now.

Have you actually performed tests to determine that A) using the sheet approach improves performance and B) this improvement is justified?

I only ever read that doing this sort of thing can use more memory if you're not careful...that was what I found

and I have not been able to get a running example (yes, you're right, the logic needed to actually do this is ridiculous) but I have seen it working before.

It would just make things easier in my head, I would only ever have to load one image as a singular resource, I could just draw on another tile and then write some code to implement that part. Plus, I could possibly make my own fonts etc (and given a lot of the games I try to make are kinda low res anyway, this would be really cool).

I understand its a very odd, outdated and logically bad way to do this, but I'm just looking to expand knowledge with loading images.

Here's the BufferStrategy I use (this sets each pixel).

From there, I can add a frame limiter and stuff, but the main objective is to learn how to load images this way (I have actually already practiced with separate images but to no luck unfortunately).
10 years ago

Riaan Nel wrote:Dan, I'm afraid that I don't have an answer for you, but I'd like to add to your question.

What's the advantage of using a sprite sheet over a bunch of individual sprite images?

Well for one, using just one image would dramatically mean that I would have to use less memory, if you think about it, the amount of KB (or MB if we're going High Quality Images) stacks up. While a runnable jar is normally no more than about 5KB for me, using just one image would use less amount of memory.

Also, the sprites would be consitently the same size, I could also use a custom made font that I could draw inside the sprite sheet.

And, I've found that the main way this is done uses Bitwise Operation when defining the tiles etc, which means the amount of memory it uses there is tiny.

I don't want to use loads of images, I'd rather just load one image and then load like, sprites, off of it.

But thank you for the reply
10 years ago

I've gotten to know Games Programming relatively well (thanks to the guys here most of all!) and I have a regular BufferStrategy that I use and it's really cool. But now I want to get into some really hard stuff (well, I say hard, it is for me at least).

I've learnt that very old games (for like, Sega Mega Drive etc etc) used like a Sprite Sheet where it would consist of a 32x32 square grid. The sprites would be loaded from the appropriate tile. How would this be achieved in Java?

I'm guessing the theory is something like:

SpriteSheet has tiles.
SpriteSheet width = tile * 32.
SpriteSheet height = tile * 32.

(I'm now derping at figuring out how loading each individual tile would work).

I'm confident there is someone here who would know how to do this. You guys have certainly been awesome enough in teaching me and getting me this far so I'll say thanks now.

10 years ago
Hello all,

I know I post on here a lot but A: I have so many questions and B: This is best place for me to get help.

I currently have sprites working, I can move them around and stuff but I want to keep the sprite in the window, sort of like a border so the sprite cannot move outside of view.

I have already tried using a method called keepInView() and it basically got the x and y of the player entity and went kinda something like this:

But this didnt work....and I've tried playing around in the code and I've had no luck anywhere...

Here's my code for all 3 files so far:

Launcher.java :



Any help is greatly appreciated....

Also, where can I get some really good LWJGL tutorials? I'm going to try that once I have the hang of this
10 years ago

John Todd wrote:Game development is a specialty itself and a huge subject to discuss.
It is a common practice to layer your game this way:

  • Application framework: code to get the game started and initializing the rest of the subsystems. This is where you are going to ignite the main loop of your game.
  • Game state manager: Responsible for managing each state of your game (examples of game states: Main menu, credits screen, options ..)
  • Graphics engine: Responsible for the visual output. For example: animating 2D sprites or 3D models

  • But this structure is mainly used to serious games development, it might be overkill for your game but it will really help you if you are serious about games development.

    I'm just struggling with syntax and really really learning how it all works, what everything does and why...I guess that'll come with experience and I shouldn't set my sights so high as making games now...

    I don't know.

    I really want to figure out how to make my sprite NOT go outside so the window so I can't see him. How to make things collide, getting bullets to ACTUALLY work...

    I just don't get how other people can figure this out so well and I struggle like hell!!
    10 years ago

    Stephan van Hulst wrote:I recommend starting off *really* simple, if this is the first time you're doing this. For instance, make your zombies dots, and the shooter can be an arrow or triangle.

    Your first assignment is to draw a shape on a panel, and then let it move around programmatically. You can do this easily using Swing. I believe the Oracle tutorials contain a section on Swing 2D.

    I has a JAR!

    OK, I'll admit now, I got most of the code off of a website but I know how it works! Honest!

    Want to see it? It's attached
    10 years ago

    Stephan van Hulst wrote:I recommend starting off *really* simple, if this is the first time you're doing this. For instance, make your zombies dots, and the shooter can be an arrow or triangle.

    Your first assignment is to draw a shape on a panel, and then let it move around programmatically. You can do this easily using Swing. I believe the Oracle tutorials contain a section on Swing 2D.

    Bump, I'm working on it now

    Expect the JAR in a few hours
    10 years ago

    Maneesh Godbole wrote:

    Dan Moody wrote:
    How do I start with Game Developement in Java?

    Well the logical point to start would be to try and answer what kind of game do you want to write. Have you thought of that?
    As a rule, always list what you want to do, and then try and figure out how you can do it.

    I've always wanted to do a top-down zombie shooter kind of thing but I just don't know what to to, how to start, what kind of Graphics methods I'll need (I can't even load pictures using the paint method!)
    10 years ago
    Hello all,

    How do I start with Game Developement in Java? I have a fairly good understanding of how Java works, some of the classes etc. but I don't know how to start with the Game Development side.

    Any places you can point me to that ISN'T NewBoston?

    Your comments are greatly appreciated.
    10 years ago
    Hi all,

    I am currently trying to make a game and I'm struggling with loading images. For some reason (or whatever reason) I can't do it.

    Code Below:

    Any help would be greatly appreciated.

    Thank you.
    10 years ago

    John Jai wrote:If the variable InsertNumberHere in DannyBoy class is static, you can access it like DannyBoy.InsertNumberHere. If that's instance variable, create an object for DannyBoy and access with that.

    Ahhhh, OK...

    Thank you very much you guys are super friendly and polite...Waaaaay better and easier to understand than those guys over at StackOverflow....
    10 years ago

    John Jai wrote:

    Dan Moody wrote:

    John Jai wrote:before you start mocking me...

    sorry, I thought I was helping you!

    No no, I meant it as in "before you start laughing at me because I don't know how to import" it just came out wrong.

    but I am grateful for your help, honest
    10 years ago

    John Jai wrote:Declare and assign an int variable insertWordHere to 0.

    So now if you print nums[insertWordHere] it prints 2.

    Ah! Thank you sir!

    While we're here, how would I import a variable from another file and use it,

    before you start mocking me, I do know the code to import something, but its just a case of using the stuff inside it...

    Assuming I had a file called DannyBoy in a package called golden.brown. So I know the code would be: import golden.brown.DannyBoy; and there was an int variable in there called InsertNumberHere, what exactly would I do to use that variable and the number assigned to it?
    10 years ago

    Winston Gutkowski wrote:

    Dan Moody wrote:A: Is it possible to change the array number or whole syntax of the array into a word of some-kind.


    B: If so, how do I do it?

    Well first you have to think through the rules of how we write out a number in longhand.

    Taking the numbers you have currently in your array as examples, what do you want your program to print out?


    Basically, I know that if want to get the number 2 from that array I will have to type nums[0] but I want to know how to change it so it says nums[insertwordhere] or something, I'm not too sure but I don't want it to be a number, I want the number to be a word.
    10 years ago

    So I make an array and it will assign each element a number, I want to change the element numbers into words.

    So say for example my code was the following:

    int nums[] = { 2, 14, 18, 17, 76, 87, 58962 };

    I know that the number 2 would be registered as nums[0] but I want it to be a number, not array syntax.

    A: Is it possible to change the array number or whole syntax of the array into a word of some-kind.
    B: If so, how do I do it?

    10 years ago