Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (690)
Games in Android Showcase (201)
games submitted by our members
Games in WIP (764)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 2 [3] 4 5 ... 10
 21 
 on: 2016-09-27 05:04:57 
Started by dylanignis - Last post by Hydroque
One thing I learned from my time on jgo is when you are faced with doing a project and you want it done in a semi timely manor, you need to pick up dependencies and ignore any downsides to using them.

If you are going to write a game engine, be able to read in XML and JSON, etc then your time is wasted and better spent on the actual game.

 22 
 on: 2016-09-27 04:59:52 
Started by Hydroque - Last post by Hydroque
Neat project.

A lot of my bullet points are about the GUI. Although, the real meat lays in editing using effects. I'd be happy with any app that allows for editing brightness of pixels from x to y.

If you got that down, then that would be amazing to release to the community.

 23 
 on: 2016-09-27 04:22:37 
Started by xTheGamerPlayz - Last post by Phased
1  
public Cell(Point location)


Java passes references, and Point is a mutable type.
Any changes (outside this class) made to the Point instance that you pass into the constructor will alter the value returned by Entity#getLocation().

Java actually passes by value, it never passes by reference.

It may look like it passes by reference but it is actually by value.

This doesn't change the answer though.

 24 
 on: 2016-09-26 23:25:27 
Started by xTheGamerPlayz - Last post by Abuse
1  
public Cell(Point location)

Java passes references, and Point is a mutable type.
Any changes (outside this class) made to the Point instance that you pass into the constructor will alter the value returned by Entity#getLocation().

A superficial way of fixing this would be to replace:
1  
super.location = location;

with:
1  
super.location = new Point(location)


There's a 2nd problem with your code; your Entity class has a protected member:
1  
protected Celltype cellType

while your Cell subclass has a private member of the same name.

So the assignment in your Cell constructor:
1  
cellType = MasterGame.cellTypes.get(random.nextInt(MasterGame.cellTypes.size()));

...is assigning a value to the member Cell#cellType.

While the Entity method:
1  
2  
3  
   public CellType getCellType() {
      return cellType;
   }

...will be returning Entity#cellType.

I doubt this is what you intend.

 25 
 on: 2016-09-26 21:27:30 
Started by xTheGamerPlayz - Last post by xTheGamerPlayz
I am creating a 2d game and want to add a feature so that the "cell" kinda floats around in the area from where it spawned. I am trying to get the original location from where it was spawned, but it keeps changing. I have nothing mentioning it or setting it other than when I set it's spawn in the constructor. Does anyone see why it is changing?

Cell Class:
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  
public class Cell extends Entity{
   
   private Random random;
   
   private CellType cellType;
   private Point spawn;
   
   private int angle;
   private float xVelocity, yVelocity;
   private float maxVelocity = .2f;
   
   public Cell(Point location) {
      random = new Random();
     
      cellType = MasterGame.cellTypes.get(random.nextInt(MasterGame.cellTypes.size()));
      width = MasterGame.cellSizes.get(cellType);
      height = width;
      this.spawn = location;
      super.location = location;
   }
   
   int ticks = 0;
   public void tick() {
      if(ticks == 15) {
         angle = random.nextInt(360);
         xVelocity = (float) (maxVelocity * Math.cos(angle));
         yVelocity = (float) (maxVelocity * Math.sin(angle));
         ticks = 0;
      }
      if(ticks % 3 == 0){
         System.out.println(spawn);
         location.x += xVelocity;
         location.y += yVelocity;
      }
      ticks++;
   }
   
   public void render(Graphics g) {
      g.drawImage(Assets.cell, location.x, location.y, width, height, null);
   }
   
}


And here is the Entity Class that Cell extends
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
public abstract class Entity {
   
   protected int width, height;
   
   protected Point location;
   protected CellType cellType;

   abstract void tick();
   abstract void render(Graphics g);
   
   public int getWidth() {
      return width;
   }
   public int getHeight() {
      return height;
   }
   public Point getLocation() {
      return location;
   }
   public CellType getCellType() {
      return cellType;
   }
   
}

 26 
 on: 2016-09-26 20:31:54 
Started by pixinator - Last post by pixinator
Ok here are some of the devices (I will add some more information later):
[1] WIN7
GeForce GTX670
version 372.70

[2] WIN8
GeForce

 27 
 on: 2016-09-26 18:57:14 
Started by Scourge - Last post by theagentd
It all depends on what you're doing .


First of all, the choice between many shaders and a few uber-shaders depends on where your bottleneck is. Each shader bind has a fairly big CPU cost, so if you have 1000 shader switches per frame this could easily be your bottleneck. In this case, switching to an uber-shader will improve performance as it reduces the CPU load by a lot for some GPU overhead instead. If your GPU is already the bottleneck, then increasing the GPU cost to eliminate a couple of shader switches will just pile on more stuff on the GPU, reducing performance.


Some shader tips:
 - An if-statement is not inherently slow in shaders. It all depends on divergence and the size of the if/else blocks. If all shader invocations in a group (= all vertex shader invocations in a certain batch or all fragment shader invocations in a certain pixel area) take the same path in the if-statement (either all true or all false), then the if-statement will be cheap and only one of the two paths will be executed. If the shader invocations diverge, both sides will have to be executed for all invocations as the group runs in lockstep. In the end, this just doesn't matter if both the if and/or else blocks don't contain a lot of code.

 - Simple conditional assignments, like
x = condition ? a : b;
generally compile to conditional assignment instructions that don't require any branching at all. You can use this to your advantage.

 28 
 on: 2016-09-26 18:31:53 
Started by Scourge - Last post by Scourge
Hello,

I currently thinking whether to reducing the amount of shaders or not. As example: I have one for single textured objects and one for objects having blend maps (to represent simple dirt/blood on objects or for terrain). Sticking to this example, I could reduce these two shaders to one by having another boolean uniform and an if statement in the fragment shader or by simply using the blend map shader and load a 1x1 px blend map for single textured objects (do I need 1x1 px images for the other images as well or doesn't opengl care if theres no target for the sampler2d?).

I would like to know from people with more 3d experience if they would merge such similar shaders and if yes which approach should be preferred due to which reasons and if there are other ways.

 29 
 on: 2016-09-26 17:41:28 
Started by FabulousFellini - Last post by theagentd
In addition to the points that people have brought up here, you should never place disk access in your game loop. Disk access is both slow and unpredictable. For normal hard drives, the access time is in the order of 10ms. In addition, they're a shared with all the other processes in your computer, so if your anti-virus software decides that there's no better time than right now to start a full virus scan, a 0.25 second sound effect can now take 1 second to load.

 30 
 on: 2016-09-26 16:25:23 
Started by FabulousFellini - Last post by FabulousFellini
Thanks guys.  I am using javax.sound.sampled, and I wrote the audioHandler class to load and play the audio, as well as keep track of variables for it.  In psudo code it looks like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
public class AudioHandler {

  //load all audio here, yada yada

  public void handleAudio(){
      switch(LEVEL){
            case 1:
                // play whatever audio or sound effects need to be played for level 1
                break;
      }

  }

}


Then in the main game loop I call AudioHandler.handleAudio.  I am going to go ahead and put it in it's own thread since I'm not doing anything with volume or panning, strictly just playing.  Thanks @philfrei and @ags1 !


Pages: 1 2 [3] 4 5 ... 10
 
xTheGamerPlayz (85 views)
2016-09-26 21:26:27

Wave Propagation (281 views)
2016-09-20 13:29:55

steveyg90 (395 views)
2016-09-15 20:41:23

steveyg90 (395 views)
2016-09-15 20:13:52

steveyg90 (435 views)
2016-09-14 14:44:42

steveyg90 (459 views)
2016-09-14 14:42:13

theagentd (469 views)
2016-09-12 16:57:14

theagentd (402 views)
2016-09-12 14:18:31

theagentd (303 views)
2016-09-12 14:14:46

Nihilhis (737 views)
2016-09-01 13:36:54
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!