2d-games

Java fillRect() with TexturePaint is slow

人走茶凉 提交于 2019-12-11 19:48:55
问题 TexturePaint Problems I am currently making a 2D game using texturepaints. One significant problem I encountered was the fact that filling rectangles with the graphics2D setPaint method set to a texture paint is extremely slower than filling a rectangle with a base color. Is there possibly any other way to speed up painting by creating a custom class similar to Texturepaint that paints much faster? At this point I really don't know what to do because my fps is stuck at around 18-23fps. EDIT :

Animating Tiles In My Game

谁说胖子不能爱 提交于 2019-12-11 17:57:11
问题 I am making a Pokemon Style 2D java game using no libraries, just pure java, and I am working on and having issues getting a water tile to animate. I want the tile to update every half a second or so. I will post my main class, abstract tile class, water class, and screen class so that maybe you can figure out a way to so me how to animate tiles in my game. P.S: Right now I am trying to animate a water tile. And all the sprites are for testing and will be changed later. Code at DropBox:

Which design pattern is appropriate for “Sea Battle” game objects?

ぐ巨炮叔叔 提交于 2019-12-11 13:19:16
问题 The problems of my design are: I have to copy too many attributes from the interface Static field "count" doesn't work for each of successor. The field should count for example how many mines are on the game field (approximate diagram). I am sorry about mistakes. I am a novice and it is my first question here. Thank you for corrections and advices. 来源: https://stackoverflow.com/questions/25154849/which-design-pattern-is-appropriate-for-sea-battle-game-objects

Best practice for creating a composite image output for Java Swing

假如想象 提交于 2019-12-11 09:47:14
问题 Im working on a 2d game in java swing, where a procedurally generated environment is represented by a tiled array of low-res images. Currently this is all within html tags (for line breaks) in a JLabel. On top of this, I would like to display character sprites, which will not take up an entire tile, but will have some alpha components. In the past, in JS/html and JS/canvas, I have simply made sprite tiles with alpha channels and positioned them directly above a floor tiles, using tables and

Why are the 'pixels' on my scaled HTML5 canvas strangely aligned?

只愿长相守 提交于 2019-12-11 00:17:03
问题 I'm currently writing a little HTML5 canvas/JS based snake clone similar to the classic Nokia Snake. (This is my first HTML5 canvas/JS game as well as my first game, I'm still a novice programmer ;) ) To keep things simple I decided to make every segment of the snake and the cherry just 1 pixel, however that would normally result in a very tiny snake and cherry! ;) So I decided to scale the canvas with .scale(8,8) so every pixel would be 8*8. var snake = { length: 4, direction: "right", color

Why won't the bullets fire in the direction the player is facing and stay visible in PyGame?

我是研究僧i 提交于 2019-12-10 23:15:38
问题 I'm trying to make a top down shooter in Python using PyGame and I want the bullets to be drawn to the screen based on the player's orientation. I can get the bullets to draw but only when the player is in that specific direction (There is a direction variable but the bullets only show when the variable matches the state that the bullet was shot in). Here is what I believe to be the relevant code global direction global bullets global bullet_speed direction = None bullets = [] bullet_speed =

SurfaceView draw performance

梦想与她 提交于 2019-12-08 20:48:27
I am writing a test application using Android SurfaceView. I want to see if it is a viable approach to 2D game development. At the moment performance is not too great. There seems to be tiny little jerks and slowdowns every 15 or so seconds. I am only drawing about 30 rectangles on screen. I would hope it would be able to do this with ease. I decided to profile performance. I log the average draw time every 10 frames. What I have noticed is that it goes periods with good draw times, and then it jumps up. I am certain my code does not allocate memory in the game loop, so I think this problem is

AABB collision resolution slipping sides

ⅰ亾dé卋堺 提交于 2019-12-08 17:33:59
问题 So, I am currently reinventing the wheel (and learning a lot) by trying my hand at making a simple physics engine for my game engine. I have been searching the internet, trying (and failing) to fix my current problem. There are a lot of resources out there on the subject, but none of those that I have found seem to apply to my case. THE PROBLEM IN SHORT: The collision resolution does not work as intended on some of the corners when two rectangles are colliding. How it fails varies based on

SurfaceView draw performance

删除回忆录丶 提交于 2019-12-08 07:44:55
问题 I am writing a test application using Android SurfaceView. I want to see if it is a viable approach to 2D game development. At the moment performance is not too great. There seems to be tiny little jerks and slowdowns every 15 or so seconds. I am only drawing about 30 rectangles on screen. I would hope it would be able to do this with ease. I decided to profile performance. I log the average draw time every 10 frames. What I have noticed is that it goes periods with good draw times, and then

Water effect “on android” for a 2D game. Where to start?

你离开我真会死。 提交于 2019-12-08 06:28:08
问题 I wanna to add some water effects in my android 2D game to give the impression that objects are under water and the water becomes higher and higher. Is there a way to do this programmatically. May be someone can give me please some code suggestions or can say where can I find something to get started. I like to do things programmatically. One time I saw a fire effect artificial done with code. Is the same possible in the water case ? 回答1: You're going to have write a gl shader for the water