开发者

Jpanel / Jframe / buffering graphics etc game structure direction

开发者 https://www.devze.com 2023-04-05 16:31 出处:网络
I\'d like some advice regarding structure of a game I\'m working on. Specifically where to place painting methods.

I'd like some advice regarding structure of a game I'm working on. Specifically where to place painting methods.

Currently there is a applet wrapper class for a Jpanel which runs the game loop.

The game itself is meant to simulate a very large area. objects will have x&y values which themselves will part of a larger x&y grid.

i.e. object1 position is 150000x30000 in grid block 1,5.

objects will need to be able to move into neighbouring grids, however I'd rather not run each grid block until needed as 99% of them will be empty.

Currently the UI is a Jpanel with a few buttons + listeners, a large drawing pane is needed to display the objects.

my question is: what class should this inte开发者_开发知识库rnal drawing pane be based on? I'd like to have control to zoom and pan around the grid. it only needs to draw what is visible, but object movements will continue in the game loop.

what painting strategy would be applicable for simple (icons really when zoomed out) moving around vast areas, I'm guessing relying on the EDT to repaint isn't going to be good enough?

I'm not really after specific code, I want to learn myself how to do this, I just need pointing in the right direction, as most things I read don't seam to quite cover what I'm after, or don't make use of JRE6+ features.

Many Thanks


Rather than paint each grid cell in your drawing pane, why don't you have each object repaint itself onto the grid?

0

精彩评论

暂无评论...
验证码 换一张
取 消