2d

Can't add multiple of same rectangle

回眸只為那壹抹淺笑 提交于 2019-12-02 17:01:08
问题 I want to make multiple of the same rectangle on my borderPane to make walls for the game. Each wall is going to look the same and be the same size. I know the image works and that there are no other errors. I use the following code to add the rectangles: public class Antz extends Application{ public BorderPane borderPane; public Scene scene; public Image wallImage = new Image("/recources/images/walls.png"); public Rectangle wall = new Rectangle(); public int[][] walls = {{1,0,0,0,0,1,1,1,0,1

html5 canvas strokeStyle?

我的未来我决定 提交于 2019-12-02 16:23:49
I am trying to map an image to a "3d" grid that simulates cloth using strokeStyle and canvas, i have the image included but it is currently acting as a background image and not actually flowing with the "cloth" as is ripples, I.E the image is static as the grid flows. here's the jsfiddle which is self explanatory ( only works in Chrome). any help is much appreciated. here is the javascript that renders the image into the background, How do i stop from rendering as a background image and only make it fill the grid?: function update() { var img = new Image(); img.src = 'http://free-textures

2D tile map generation

杀马特。学长 韩版系。学妹 提交于 2019-12-02 16:23:28
I'm developing a 2D tile engine and at this moment I'm working on map generation algorithms. I tried the basic ones usually involved in simple heightmap generation like hill generation perlin noise diamond square but I always get the same problem: this kind of algorithms seems suitable when dealing with tile maps that also have a height component but this is not my case. I basically have sprites like grass, sea, desert and so on but they shouldn't be placed inside the map according to a generated height but something like everything starts from ocean islands are placed in the middle of the map

Mathematics and Game Programming

混江龙づ霸主 提交于 2019-12-02 14:44:42
I want to program graphical 2D games more complex than the basic 2D stuff I already know. I don't want to do 3D programming. Just more complex 2D stuff. I dropped high school before I could learn a lot of stuff so I walked away with enough algebra knowledge to balance my checkbook and do some light 2D Cartesian programming. Are there any good resources out there for a guy with a limited attention span (say 20 minutes apiece for a subject I'm keenly interested in) to learn, gradually, how to do something more useful with math in programming? You need to be competent in Trigonometry: Wikipedia

Shortest route between multiple points

偶尔善良 提交于 2019-12-02 14:33:41
I need to find the shortest route between multipe points. Let's say that I have these four points: var startPoint = new Point(1, 1); var pointsToGoPast = new List<Point> { new Point(3,1); new Point(2,4); }; var endPoint = new Point(10, 10); So, I want to find out which points to go past first, in order to get the shortest route, from startPoint to endPoint. Can anyone help me? Update: It has to go past each of the points in the pointsToGoPast list. The cost is even for each route. You can do this by Dijkstra's Algorithm. Sample project with code here The only thing that needs to change is the

Android OpenGL ES and 2D

北战南征 提交于 2019-12-02 13:47:29
Well, here's my request. I don't know OpenGL already, and I'm not willing to learn it, I want to learn OpenGL ES directly since I'm targeting my development to android, however. I want to learn OpenGL ES in order to develop my 2D games. I chose it for performances purpose (since basic SurfaceView drawing isn't that efficient when it comes to RT games). My question is: where to start? I've spent over a month browsing Google and reading/trying some tutorials/examples I've found anywhere but to be honest, it didn't help much and this is for two reasons: Almost all the articles/tutorials I've came

How to find average of elements in 2d array JAVA? [closed]

旧城冷巷雨未停 提交于 2019-12-02 13:39:56
I need help with the following program: "Write a method that will take a two-dimensional array of doubles as an input parameter & return the average of the elements of the array." Can anyone tell me how to go about it? My current code: public static double average(float arr[][]) { double sum = 0; int count = 0; for (int row = 0; row < arr.length; row++) for (int col = 0; col < arr[0].length; col++) { sum += arr[row][col]; count++; } return sum/count; } I don't know how to let the user input the array elements and array dimensions (row/columns). Also how do I call this method from main? I am

Finding valid neighbors in 2D array

巧了我就是萌 提交于 2019-12-02 13:13:42
问题 So, I have a 4x4 2D array (it will always be these dimensions). Starting with a location on the array, some row and column, I want to find all of its valid neighbors. So far, I have a really clunky implementation. //add row if ( !((row + 1) > 3)) { //do stuff } //sub row if ( !((row - 1) < 0)) { //do stuff } //add col if ( !((col + 1) > 3)) { //do stuff } //sub col if ( !((col - 1) < 0)) { //do stuff } ... and so on This is brutal. I feel like I do not need to check every single neighbor when

Homing Missiles, How Do They Work?

喜夏-厌秋 提交于 2019-12-02 13:00:36
What I am trying to create An object that will launch a missile towards the player, if it collides with player, player dies. The Problem How does the missile move towards the player. How do I make the missile move so that it does not instantly move directly towards the player(to slowly move on an angle). I have a formula for the mouse to be the "Player" and the missile to go towards it. mouse = Mouse.GetState(); mousePosition = new Vector2(mouse.X, mouse.Y); A = (mouse.X - Position.X); B = (mouse.Y - Position.Y); C = (A * A) + (B * B); C = (float)Math.Sqrt(C); Angle1 = A / C; Angle2 = B / C;

Creating a dynamic 2D matrix in Java

流过昼夜 提交于 2019-12-02 12:30:48
I want a dynamic matrix, number rows and columns unkonw, filling it by clicking on a button. Bu there is more: I don't want to add entire rows, but just one cell at the time, one click = one cell added. Of course not randomly : 1st cell of 1st row, 2nd cell of 1st row... and then the same of the 2nd row and so one... I know about UJMP, ArrayList, but it's not quite what I'm looking for. Please be accurate on your answer, thank you in advance. Use this: List<List<Integer>> dynamicMatrix = new ArrayList<List<Integer>>(); dynamicMatrix.add(new ArrayList<Integer>()); dynamicMatrix.add(new