Java-Gaming.org Hi !
 Featured games (91) games approved by the League of Dukes Games in Showcase (757) Games in Android Showcase (229) games submitted by our members Games in WIP (843) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Show Posts Pages: [1]
 1 Game Development / Game Mechanics / Re: Rotating a 1D matrix on: 2013-07-28 15:28:44 So I guess there are a lack of linear algebra folk around here haha Close the thread, I've figured it out after reading a bit about matrix transformations.
 2 Game Development / Game Mechanics / Re: Rotating a 1D matrix on: 2013-07-22 16:49:30 When the object is rotating, the pixels themselves aren't rotating around their center, they're just rotating around another fixed point. So with that effect, there are pixel sized gaps evenly spread throughout the object. I think this happens in order to preserve the actual shape of the object.
 3 Game Development / Game Mechanics / Rotating a 1D matrix on: 2013-07-22 15:02:35 So the way I render images onto the screen involves having an array of color data from a buffered image. I can manipulate that one image, through the color data, and basically render any other image into that main buffered image. The problem I'm having right now is I'm having trouble implementing a rotation transformation correctly on this array. I've gotten strange results, where the sprite is rotating around the origin (top left corner). I couldn't really figure out how to make it rotate around it's center or any point. Also with that rotation, there are tiny gaps in the sprite while it's rotating.
4  Game Development / Shared Code / Polled Input Implementation on: 2013-07-20 03:39:40
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96 `public class Input implements KeyListener, MouseMotionListener, MouseListener {   private HashMap inputs = new HashMap();   public int mouseX, mouseY;   public void update() {      for (Map.Entry entry : inputs.entrySet()){         entry.getValue().update();      }   }   public boolean isDown(int keyCode) {      Inputs input = inputs.get(keyCode);      if(input != null){         return input.isDown;      }      else return false;   }   public boolean isClicked(int keyCode) {      Inputs input = inputs.get(keyCode);      if(input != null){         return input.isClicked;      }      else return false;   }   public void keyPressed(KeyEvent ke) {      int keyCode = ke.getKeyCode();      if(!inputs.containsKey(keyCode)){         Inputs input = new Inputs();         input.toggle(true);         inputs.put(keyCode, input);      }      else inputs.get(keyCode).toggle(true);   }   public void keyReleased(KeyEvent ke) {      inputs.get(ke.getKeyCode()).toggle(false);   }   public void mousePressed(MouseEvent mo) {      int mouseCode = mo.getButton();      if(!inputs.containsKey(mouseCode)){         Inputs input = new Inputs();         input.toggle(true);         inputs.put(mouseCode, input);      }      else inputs.get(mouseCode).toggle(true);   }   public void mouseReleased(MouseEvent mo) {      inputs.get(mo.getButton()).toggle(false);   }   public void mouseMoved(MouseEvent arg0) {      mouseX = arg0.getX() / Engine.SCALE;      mouseY = arg0.getY() / Engine.SCALE;   }   public void keyTyped(KeyEvent ke) {   }   public void mouseClicked(MouseEvent arg0) {   }   public void mouseEntered(MouseEvent arg0) {   }   public void mouseExited(MouseEvent arg0) {   }   public void mouseDragged(MouseEvent arg0) {   }   public class Inputs {      private int presses, absorbs;      public boolean isDown, isClicked;      public void toggle(boolean pressed) {         if(pressed != isDown) isDown = pressed;         if(pressed) presses++;      }      public void update() {         if(absorbs < presses){            absorbs++;            isClicked = true;         }         else isClicked = false;      }   }}`

So I've experimented in different implementations of getting input from the user. This current implementation allows me to poll for constant input and also achieve a psuedo event system with the isClicked method. Also, with the addition of a hash map, I can check for any java KeyEvent or MouseEvent very quickly. Is there anything else that can be improved? I've been through many implementations, adding on what I learn over time, and I'll be glad to take any advice.
 5 Game Development / Game Mechanics / Re: Java2D rendering with BufferedImage RGB data on: 2013-06-18 04:08:15 Quote from: CodeHead on 2013-06-18 04:02:03It may be a different way of rendering, but I don't think there would be any benefit, and in fact may be detrimental. It's a lot quicker to assign a color value to an array element (if pixel level manipulation is required) than to assign multiple values to a rectangle object. There are other reasons to avoid this approach, but in the end, you want to work with the API, not against, or around it.As BurntPizza said, if performance is your top concern, consider a different API than Java2D. Personally, I haven't hit the wall with Java2D yet. I get around 1200+ FPS on a fairly modern machine at 1024x768 resolution with every pixel being touched during my rendering loop. Even my craptastic 7 year old laptop with integrated Intel video still manages to crank out 120 FPS in the same scenario. The only sure way to know is to try out a few different approaches, and see what works best for you. Do you mind sharing your approach, it would be greatly appreciated. I've hit a huge wall and I'm sure there's something else I could do without having to move onto other API's. I would love to get that kind of performance at that resolution, but as soon as I start rendering a couple hundred images, the FPS starts sinking dramatically.
 6 Game Development / Game Mechanics / Java2D rendering with BufferedImage RGB data on: 2013-06-18 03:15:38 I was wondering if I could obtain a buffered image and create another "psuedo" image from that by using the first image's color data to construct an image made up of 1 x 1 rectangles, representing the pixels of the buffered image. I'm not too sure if it would be faster than to use just regular buffered images. I figured it would be a different way of rendering and maybe get some performance gains.
 Pages: [1]
 EgonOlsen (37 views) 2018-06-10 19:43:48 EgonOlsen (20 views) 2018-06-10 19:43:44 EgonOlsen (39 views) 2018-06-10 19:43:20 DesertCoockie (186 views) 2018-05-13 18:23:11 nelsongames (122 views) 2018-04-24 18:15:36 nelsongames (121 views) 2018-04-24 18:14:32 ivj94 (861 views) 2018-03-24 14:47:39 ivj94 (122 views) 2018-03-24 14:46:31 ivj94 (758 views) 2018-03-24 14:43:53 Solater (139 views) 2018-03-17 05:04:08
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org