How can I optimize my 2d java game rendering?

386
August 20, 2017, at 2:14 PM

My problem is, I have a game with a random generated map and it has only 30-40 fps because of the number of blocks.(You can imagine my game like a 2d minecraft).

First I search for the first tile what is in screen. Then start a loop render tile next tile... until I reach the last tile what you can see.

(I don't use any of the Java classes like graphics/graphics2d I use my own code what is an int[] with the rows of teh screen in it and when I render a tile I change the int[x+y*width] position of the screen to the correct pixel of the block)

I think logically this is the best way to render my map and i don't understend why is the low fps. I am wrong or I need to search for some other problem in my code? Or there is any better rendering method?

If I skip the rendering of the world, there is stabile 120 fps what is capped there. What can be the problem?

Rent Charter Buses Company
READ ALSO
how to know when a select finds 0 rows mysql, getFetchSize() not working

how to know when a select finds 0 rows mysql, getFetchSize() not working

I am trying to make a username only register if that name is not taken, using JDBC connection and checking on SQL DatabaseI have the code that checks for the SELECT * FROM user WHERE username = 'jessica';

307
java getting stack overflow-program is not recursive

java getting stack overflow-program is not recursive

I have been working on my "Random Trivia" program and I keep getting stack overflow with NO recursiveness, at least I cannot find any, here is the code to Guijava, the main class(and only class)

221
How can you read a boolean array?

How can you read a boolean array?

I have this boolean array that I am using in my app, but I have no idea how to save this array that I am usingHere is how I am saving the array:

384