@Ra4king yea I understand that part, but for a background Image in canvas how do I set a static background Image like paint component does in Jpanel or do I just draw it first? I don't want to have to keep re painting it right? 2nd question, to clear a canvas you do clear rect right or something else?

ReBirth has already answered that question: just draw the image first. Don't worry about performance since it is negligible for a single image.

And yes you use clearRect or fillRect to clear anything. The Graphics2D operations are the same for everything. However, it would be unnecessary to clear the screen if you are already drawing a background image.

Thanks man you're always there when I need ya and rebirth too! Hey another question, what should I do for canvas when I want to load another lvl, like clean up a screen just clear rect? Or what is the proper way to clean up to prepair for another zone?

There is nothing to "clean up". When you draw, it stays on the screen only for that one frame until you redraw. So essentially you are redrawing everything 60 times a second. When loading another level, you are probably going to be using the same or different background image, which will clear the screen anew for different stuff to draw.

So my game is an RPG and there will be maybe you will be at an Inn or maybe a dungeon. So you're saying by just loading those classes and each Npc entity etc once I just not draw them they will be gone visually an In memory?

If you wanted to implement levels you could use objects for each level and then have an object for "currentLevel". Your game could just control the drawing from the current level and then when you change level, just change the currentLevel to a new one and initialize it. Its kind of like having game states (eg. in-game, menu, etc.) but each state is a different level.

I mean memory wise =D, how is the garbage collection for images, once not drawn all references are gone?

You are confusing drawing with objects. When you draw anything on the screen, the pixels are copied from the image to the screen. The Image object still exists whether you draw it or not. It's not until you remove all references to that Image, by setting the reference to null, when the garbage collector retrieves the memory.

And you shouldn't be worrying about performance and memory this early. Just write a game already!

Btw, jammas615 about your message about lvl states. I mean for an average turn base 2d rpg like maybe Fireemblem etc would you consider those lvls? I mean what is the usual standard to switch between lvls/zones? Are lvl/states an efficent way of doing so?

I mean memory wise =D, how is the garbage collection for images, once not drawn all references are gone?

Think about this. You want to have field of grass. You load one smallest unit (tile) of grass and draw it repeatly. It shows that an image object can be used multiple times. Screen has its own amount of memory use. Even a black window uses memory. What you should consider is object that is created by you.

Btw, jammas615 about your message about lvl states. I mean for an average turn base 2d rpg like maybe Fireemblem etc would you consider those lvls? I mean what is the usual standard to switch between lvls/zones? Are lvl/states an efficent way of doing so?

Well, to be honest, i've never used levels and level switching like that, however i know it works well for game states. But for an average turn-based, 2D rpg i suspect that it will be more than adequate, and also from what i saw in your video. The trick i think is to do what you think best and what you want to do, then if you do run into probems, learn from them and properly fix things up (eg. redesign).

@Above thanks, gotcha =). Also another question for you you guys, I got my canvas working and everything seems fine tri buffering and my delta time is great but it seems when I go from 60fps to 100 fps animations go a bit too fast, why is this? Why are they moving too fast and not synchronized well, what is the best way to combat this I thought delta time was supposed to do so?

Then I take delta pass it through update which is then passed through set delta method to my board class b3.update(delta time) that is then passed through for other methods dealing with time such as animations and movement. Or is that incorrect? The other methods in the board class such as playerSprite.setTime(takes in delta from the board class) and then looks over that time and checks if seconds go by or minutes to do game updates based on the overall delta time of the main games time.

When I set it to 100fps as opposed to60fps at 100 fps things seem to move slightly faster than they should like 3 frames tick for monster movement looks like 5-6 at 100fps+.

Isn't this correct? What am I doing wrong??? It appears that my game Logic is faster than it should or should I not even worry about 100fps as long as 60fps stays the same? I was before just using timer every 14ms to update an action preformed method to do update logic and repaint(), found this loop on the forums and it seems much better although, can someone please explain how to sync game logic properly? Thanks

Is my logic correct? Such as accumulating delta time and updating stuff w.e time I want like 500ms? And where should I be multiplying delta?For example In my setTick Method in my monster Sprite class for my main sprite movement it updates every 500ms.

So for xVelocity I want my sprite to move 3pixels but with a delta time of 14ms I'd be moving at 42pixels per second?

How can I make sure I just move x pixles perSecond? This is in regards of a simple RPG. Btw I should be using delta time for keeping track of ALL time right? Or am I confused with the purpose of delta time?

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