2d

A* Path finding algorithm running extremely slow [duplicate]

久未见 提交于 2019-12-13 02:43:46
问题 This question already has an answer here : Implement A star (A*) path algorithm in large map, low performance (1 answer) Closed 3 years ago . I am currently working on my first game for android, and my first time creating an a* path finding algorithm. It is a 2d game. I have created one enemy containing this algorithm (ie. It is being ran once every frame) and it slows down performance from 60fps to 1-2 fps. Obviously something is horribly wrong, I have tried looking online for solutions but

three.js 2D mouseclick to 3d co-ordinates using raycaster

≡放荡痞女 提交于 2019-12-13 02:39:42
问题 I'm trying to draw 2D objects in z=0 plane, now I want to convert screen mouse co-ordinates into 3D world co-ordinates. I used camera below: camera = new THREE.OrthographicCamera(SCREEN_WIDTH / - 2, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_HEIGHT / - 2, NEAR, FAR ); camera.position.set(0,0,500); camera.lookAt(scene.position); container = document.getElementById( 'ThreeJS' ); container.appendChild( renderer.domElement ); var floorGeometry = new THREE.PlaneGeometry(1000, 1000, 10, 10); var

Fast paletted screen blit with OpenGL

不羁的心 提交于 2019-12-13 02:33:58
问题 A game uses software rendering to draw a full-screen paletted (8-bit) image in memory. What's the fastest way to put that image on the screen, using OpenGL? Things I've tried: glDrawPixels with glPixelMap to specify the palette, and letting OpenGL do the palette mapping. Performance was horrendous (~5 FPS). Doing palette mapping (indexed -> BGRX) in software, then drawing that using glDrawPixels . Performance was better, but CPU usage is still much higher than using 32-bit DirectDraw with the

Random position in string array? Java

社会主义新天地 提交于 2019-12-13 02:01:41
问题 Working on building a tic tac toe game. I'm trying to use as simple of methods as possible. I'm currently working on getting the cpu to randomly choose a spot in the array to place the "O" at. How do I go about doing this? This is what I have so far. import java.util.Scanner; import java.util.Random; public class Player { String player = "X"; String cpu = "O"; //private int[][] theBoard= new int [3][3] ; private String[][] theBoard= {{" "," "," "}, {" "," "," "}, {" ", " "," "}};; Random

Java2D removing old pixels after moving image?

房东的猫 提交于 2019-12-13 01:27:32
问题 So I'm moving an image in Java2D and it bounces aswell. For some reason, it always leaves behind a trail of old images. How could I fix this? Main class: package org.main.graphics; import java.awt.Graphics; import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import org.main.entity.Entity; import org.main.entity.Loael; @SuppressWarnings("serial") public class GameWindow extends JFrame implements Runnable { private List<Entity> entities =

Looking for an efficient algorithm to find the boundary of a swept 2d shape

删除回忆录丶 提交于 2019-12-13 00:36:06
问题 I have piecewise curve defining a generator (think brush) and a piecewise curve representing the path the brush follows. I wish to generate the boundary that the generator curve creates as it is swept across the path. This is for an engineering CAD like application. I am looking for a general algorithm or code samples in any language. 回答1: I suggest the following papers: "Approximate General Sweep Boundary of a 2D Curved Object" by Jae-Woo Ahn, Myung-Soo Kim and Soon-Bum Lim "Real Time

What kind of shader for 2D games (ie. Super Mario)

空扰寡人 提交于 2019-12-13 00:18:05
问题 I've been trying to figure out how to use OpenGL ES 2.0 for 2D. So far I think I have a handle on most things. But the one thing that I haven't figured out is what to do for the shaders? I understand that you set up the camera/view and the lights in the shader, but I don't want shadows or any kind of sign of lighting. Basically I just want to move sprites around the screen and have the sprites look exactly like they did when I drew them in photoshop. Anyone have an example of a shader that

MEMORY MAP for 2d / multidimensional arrays

断了今生、忘了曾经 提交于 2019-12-13 00:08:56
问题 Can anyone please explain visually as to how the 2D array is stored in memory as: a , &a, &a[0] , a[0] all have the same address... It seems like a pointer pointing to itself in a way...and that cant be right... This has been bugging me for nearly a year and searching on the web has lead me to no apt answer as well..... help is really appreciated....thanx enter code here #include<stdio.h> int main() { int a[2][3]={10,20,30,40,50,60}; int row =0,col=0; printf("&a = %d ",&a); printf("\na = %d "

2D Fourier Transformation in C

纵饮孤独 提交于 2019-12-12 18:35:31
问题 I implemented 2D DFT and IDFT using equation from this site http://homepages.inf.ed.ac.uk/rbf/HIPR2/fourier.htm I think these are correct and nicely explained. Implementation looks like that: for(int i=0;i<inImage.width;i++) { for(int j=0;j<inImage.height;j++) { float ak=0; float bk=0; for(int ii=0;ii<inImage.width;ii++) { for(int jj=0;jj<inImage.height;jj++) { float x=-2.0*PI*i*ii/(float)inImage.width; float y=-2.0*PI*j*jj/(float)inImage.height; // ak+=inImage.pixels[i][j]*(cos(x)*cos(y)-sin

R — Method for Interpolation over 2d datset with missing values

吃可爱长大的小学妹 提交于 2019-12-12 17:21:39
问题 I am currently using the 'Akima' interp routine in order to do 2d linear interpolation. I'm currently trying to do linear interpolations as best as I can by excluding the bad datpoints and interpolated values that depend upon them. I don't want to do any spline fitting just linear interpolation. I can think of two ways to do this using the existing akima package; by partitioning the 2d datasets into valid subsets that do not have missing data points, and then interpolating on each, and then