2d

Java 2D and resize

泪湿孤枕 提交于 2020-02-03 08:36:31
问题 I have some old Java 2D code I want to reuse, but was wondering, is this the best way to get the highest quality images? public static BufferedImage getScaled(BufferedImage imgSrc, Dimension dim) { // This code ensures that all the pixels in the image are loaded. Image scaled = imgSrc.getScaledInstance( dim.width, dim.height, Image.SCALE_SMOOTH); // This code ensures that all the pixels in the image are loaded. Image temp = new ImageIcon(scaled).getImage(); // Create the buffered image.

Unity - 2D shader / lighting like Terraria or Starbound

我的梦境 提交于 2020-02-01 02:50:47
问题 I have a map with a lot of sprites. I could add a material to the sprite with diffuse shading and than add lots of lights. But that won't give me the result I want. And is performance heavy. Examples In the first image you can see that light is generated by torches. It's expanding its light at its best through 'open spaces' and it is stopped by blocks fairly quickly. Here is a great example of the top layer. We can see some kind of 2D directional light? Please note that the lighting inside

Unity - 2D shader / lighting like Terraria or Starbound

一世执手 提交于 2020-02-01 02:50:33
问题 I have a map with a lot of sprites. I could add a material to the sprite with diffuse shading and than add lots of lights. But that won't give me the result I want. And is performance heavy. Examples In the first image you can see that light is generated by torches. It's expanding its light at its best through 'open spaces' and it is stopped by blocks fairly quickly. Here is a great example of the top layer. We can see some kind of 2D directional light? Please note that the lighting inside

double pointers and 2d arrays in c

不想你离开。 提交于 2020-01-30 06:07:17
问题 I'm trying to access a 2D array using double pointer int x[2][2] = {{10, 20},{30, 40}}; int *xp; int **xpp; printf ("%d %d\n%d %d\n", x[0][0], x[0][1], x[1][0], x[1][1]); printf ("\n"); xp = *x; printf ("%d %d\n%d %d\n", *xp, *(xp + 1), *(xp + 2), *(xp + 3)); printf ("\n"); xpp = (int**)x; printf ("%d\n", **xpp); What I get is: 10 20 30 40 10 20 30 40 Segmentation fault Question: How should I access the array using xpp ? 回答1: Rather than ... int x[2][2] = {{10, 20},{30, 40}}; int **xpp; xpp =

After Game Over how to stop score from increasing

∥☆過路亽.° 提交于 2020-01-25 00:19:09
问题 Im making a endless runner game and am using a 'ScoreManager' object with a box collider 2d set to 'is trigger' increasing the score every time a object hits it. But I want it to stop increasing the score if the health reaches 0. This is the ScoreManager code: public int score; public Text scoreDisplay; void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Obstacle")) { score++; } } private void Update() { scoreDisplay.text = score.ToString(); } I would like to add a: public int

Pixels Array Too CPU Intensive

断了今生、忘了曾经 提交于 2020-01-24 18:57:46
问题 I have been working on a Java 2D game for a little while. It is a raster graphics system with an array of pixels (integers). private BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB); private int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); I then create an array of integers separately, manipulate it with the screen objects (rendered from external image files, such as .png), then copy that array into my main one, which is projected

A* Algorithm 2D Game Pathing issues

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-24 11:22:06
问题 I have decided to pick up my old 2D game engine from back in the day and continue work on it This is my first attempt at trying to implement some basic AI for enemies and I am having some issues. Here is a run down on how I am treating the AI for enemies. If the player is within a certain range of the enemy, the enemy moves towards the player by just checking to see if he is up or down, left or right of the player and adjusting it's Coordinates accordingly. If the enemy hits an obstacle that

Sudoku Board Using JPanels in Java

 ̄綄美尐妖づ 提交于 2020-01-24 05:50:07
问题 I know there have been several posts already about Sudoku-related questions, but I am not sure any of them have exactly what I am looking for... I am trying to build an empty Sudoku board in Java using JPanels and JTextfields. I also need to create a menu on the right hand side with another JPanel. The board itself is a 9 x 9 square, divided into 9 3x3 squares. Note that each smaller square is set off by a heavier border than the regular intersquare borders. Each square is a text field. Write

Drawing with Transparent Paint on Android

这一生的挚爱 提交于 2020-01-24 04:37:21
问题 When I use Paint with Color.TRANSPARENT on a normal 2D canvas in Android, I don't get any results and my intention was to get rid of some of the contents on the canvas. I mean the contents that I want to dispose of don't disappear. This is the code for my Paint : mPointFillPaint = new Paint(); mPointFillPaint.setColor(Color.TRANSPARENT); mPointFillPaint.setAntiAlias(true); mPointFillPaint.setStyle(Paint.Style.FILL); mPointFillPaint.setStrokeJoin(Paint.Join.MITER); 回答1: The following Paint

Drag 2dtexture from inventory to game

五迷三道 提交于 2020-01-24 00:40:33
问题 Allright, so I am making a mobile 2d building game. where you can drag a rectangle or circle from your inventory in the game. how I would like it to be set up: on the top or right side is an inventory with objects/textures, when I drag one of the items from my inventory into the game. it then removes the item from the inventory. after that the items inventory will all move 1 slot up. so that the first slot is allways occupied. How would I make this work? can someone please help me think or