Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (581)
Games in Android Showcase (162)
games submitted by our members
Games in WIP (632)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3 ... 6
1  Game Development / Networking & Multiplayer / Re: NitroNet - New, High-Level Networking Library on: 2015-05-17 10:35:59
I quite like it. It is similar to kryonet but simpler, good for beginners!
2  Game Development / Newbie & Debugging Questions / [LWJGL] Shaders, implementing? on: 2015-04-15 09:32:44
So i am trying to implement shaders on my own with lwjgl.
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  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
package necro.graphical;

import static org.lwjgl.opengl.GL11.GL_FALSE;
import static org.lwjgl.opengl.GL20.GL_COMPILE_STATUS;
import static org.lwjgl.opengl.GL20.GL_FRAGMENT_SHADER;
import static org.lwjgl.opengl.GL20.GL_VERTEX_SHADER;
import static org.lwjgl.opengl.GL20.glAttachShader;
import static org.lwjgl.opengl.GL20.glCompileShader;
import static org.lwjgl.opengl.GL20.glCreateProgram;
import static org.lwjgl.opengl.GL20.glCreateShader;
import static org.lwjgl.opengl.GL20.glGetShader;
import static org.lwjgl.opengl.GL20.glLinkProgram;
import static org.lwjgl.opengl.GL20.glShaderSource;
import static org.lwjgl.opengl.GL20.glUseProgram;
import static org.lwjgl.opengl.GL20.glValidateProgram;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import org.lwjgl.opengl.Display;

public class ShaderProgram {

   private int shaderProgram, verShader, fragShader;

   private String vertexShader, fragmentShader;

   private StringBuilder vertexShaderSource;
   private StringBuilder fragmentShaderSource;

   /**
    * !!! THIS MUST BE IN THE INIT METHOD!!! initializes shader program. Use
    * load to load and then create() to create!
    *
    * @param verShader
    * @param fragShader
    */

   public ShaderProgram(String verShader, String fragShader) {
      vertexShader = verShader;
      fragmentShader = fragShader;
   }
   /**
    * Load the shaders!
    */

   public void load() {
      shaderProgram = glCreateProgram();
      verShader = glCreateShader(GL_VERTEX_SHADER);
      fragShader = glCreateShader(GL_FRAGMENT_SHADER);

      vertexShaderSource = new StringBuilder();
      fragmentShaderSource = new StringBuilder();

      BufferedReader reader = null;
      try {
         reader = new BufferedReader(new FileReader(vertexShader));
         String line;

         while ((line = reader.readLine()) != null) {
            vertexShaderSource.append(line).append('\n');
         }

      } catch (IOException e) {
         System.err.println("Can not load vertex shader! There is no :" + vertexShader);
         e.printStackTrace();
         Display.destroy();
         System.exit(1);
      } finally {
         if (reader != null) {
            try {
               reader.close();
            } catch (IOException e) {
               e.printStackTrace();
            }
         }
      }
      BufferedReader reader1 = null;
      try {
         reader1 = new BufferedReader(new FileReader(fragmentShader));
         String line;

         while ((line = reader1.readLine()) != null) {
            fragmentShaderSource.append(line).append('\n');
         }

      } catch (IOException e) {
         System.err.println("Can not load fragment shader! There is no :" + fragmentShader);
         e.printStackTrace();
         Display.destroy();
         System.exit(1);
      } finally {
         if (reader1 != null) {
            try {
               reader1.close();
            } catch (IOException e) {
               e.printStackTrace();
            }
         }
      }

   }

   @SuppressWarnings("deprecation")
   /**
    * Create and compile shaders!
    */

   public void create() {
      glShaderSource(verShader, vertexShaderSource);
      glCompileShader(verShader);
      if (glGetShader(verShader, GL_COMPILE_STATUS) == GL_FALSE) {
         System.err.println("Vertex shader could not comple!");
         Display.destroy();
         System.exit(1);
      }

      glShaderSource(fragShader, fragmentShaderSource);
      glCompileShader(fragShader);
      if (glGetShader(fragShader, GL_COMPILE_STATUS) == GL_FALSE) {
         System.err.println("Fragment shader could not comple!");
         Display.destroy();
         System.exit(1);
      }
      glAttachShader(shaderProgram, verShader);
      glAttachShader(shaderProgram, fragShader);
      glLinkProgram(shaderProgram);
      glValidateProgram(shaderProgram);

   }
   /**
    * Start using shader program!
    */

   public void startShader() {
      glUseProgram(shaderProgram);
   }
   /**
    * Stop using shader program!
    */

   public void stopShader() {
      glUseProgram(0);
   }

}

and using them
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  
public class Game extends State {

   ShaderProgram sp;
   Texture grass;
   MyGame mg;

   public Game(MyGame myGame) {
      mg = myGame;
   }

   @Override
   public void init() {
      grass = Loader.getTexture("img/grass.png");
      sp = new ShaderProgram("shader.ver", "shader.frag");
      sp.load();
      sp.create();
   }

   @Override
   public void render() {
      sp.startShader();
         Render.drawTexture(grass, 100, 100, 64, 64);
      sp.stopShader();
   }

   @Override
   public void update() {

   }

}

And there is nothing i can do with them now...... xD
how do i pass the values (exp. color) to the shader and use it?
3  Games Center / WIP games, tools & toy projects / Re: 2D Terrarian engine on: 2015-04-13 20:25:09
It looks so niceeee! Cheesy
4  Game Development / Networking & Multiplayer / Re: Kryonet How to update sprite animation in client/server on: 2015-03-28 11:38:17
just save previous x and y and compare it to the new x and y if it changes just update the animation or something....
5  Games Center / WIP games, tools & toy projects / Re: Bit Siege - 2D Competitive Multiplayer PvP Game. (Patch v1.4.2 out now!) on: 2015-02-21 12:27:52
The game looks nice, but why don't you make the "bullets"/"Abilities" go 360 degrees instead locking them to 0,90,180 and 270. I think it would be better and more fun. Maybe?
6  Games Center / Showcase / Re: Spaceport Hope on: 2015-02-21 12:20:55
It is AWESOME!!! Love the pixel art! Gameplay looks nice. I think it could be big! When did you start developing it and when will it be finished?
7  Game Development / Newbie & Debugging Questions / Re: Adding chunks to world for large maps? on: 2015-02-21 12:03:40
Well i made something that is working BUT i load all of the chunks and if i have a lot my ram usage goes over 1 Gb.... and i dont want that

my world class

https://github.com/GNecro1/RPG/blob/master/src/net/world/World.java

and my Chunk class

https://github.com/GNecro1/RPG/blob/master/src/net/world/Chunk.java

I was thinking to just have an a 2D array of 3x3 chunks and as the player moves i make the previus chunk = new chunk.... and i don't really know how.....
8  Game Development / Newbie & Debugging Questions / Re: Adding chunks to world for large maps? on: 2015-02-17 21:39:37
I dont realy know what that means.... a tree structure?
9  Game Development / Newbie & Debugging Questions / Re: Adding chunks to world for large maps? on: 2015-02-17 20:52:06
How would i do this for infinite terrain?
10  Game Development / Newbie & Debugging Questions / Adding chunks to world for large maps? on: 2015-02-17 13:07:19
I really don't know how do i implement large maps(over worlds), but i split it into smaller maps, like chunks, and update them only... If you know any tutorial or something, please don't hesitate to share! Thanks in advance!
11  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [Slick2D] Why the F is it so slow? [SOLVED] on: 2015-01-12 08:39:04
Well it is better than what i did. I just did all of that in my game.
12  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [Slick2D] Why the F is it so slow? on: 2015-01-10 12:22:51
I solved it, i just get the image from the animation. YAy
13  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [Slick2D] Why the F is it so slow? on: 2015-01-10 10:02:49
Yea i am doing that, one more problem i am using only one spritesheet for everything and how do i draw animation it only has draw? And when i draw it it goes to the 0,0 no matter what!
14  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [Slick2D] Why the F is it so slow? on: 2015-01-09 21:50:52
Thx it runs very fast! <3
15  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [Slick2D] Why the F is it so slow? on: 2015-01-09 12:13:09
I dont think so......
16  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [Slick2D] Why the F is it so slow? on: 2015-01-09 12:01:29
When i use start() and end() my game brakes.... ? It does not show the player (Animation) and it only shows some of the sprites.....
17  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [Slick2D] Why the F is it so slow? on: 2015-01-09 11:41:22
Here you go the whole project https://www.mediafire.com/?9h7o6mmy97919di
18  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [Slick2D] Why the F is it so slow? on: 2015-01-09 11:10:11
Nope that is not the problem i checked that first when i saw the FPS.
19  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [Slick2D] Why the F is it so slow? on: 2015-01-09 11:03:57
I did i draw one tile and it still slows down... when i dont draw tiles the FPS goes to 60 (target FPS 60) and when i draw one it goes to 57 FPS
20  Game Development / Newbie & Debugging Questions / Re: Kryonet Connection ID Safety on: 2015-01-09 10:51:37
Well you can have the client send an packet that will have the id (login packet) and the server would have a txt file where the id will be stored and if it has that id the server will send a packet (conform login packet) and if not server would disconnect the client. Simple.
21  Java Game APIs & Engines / Engines, Libraries and Tools / [Slick2D] Why the F is it so slow? [SOLVED] on: 2015-01-09 10:35:27
I am recreating my previous project https://github.com/GNecro1/TROTMGRO, it was java2D no libs nothing, pure java. Now i am using Slick2D and it is crap. In Java2D i was creating a world 128x128 tiles(300+ FPS), now i am creating (in Slick2D) a world 32x32 tiles (9 FPS). So wtf is wrong?
How I do the rendering:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
 // Only 1 chunk, rendering
public void render(GameContainer c, StateBasedGame game, Graphics g) throws SlickException {
   for (int i = 0; i < tile.length; i++) {
      for (int j = 0; j < tile[0].length; j++) {
         tile[i][j].render(c, game, g);
      }
   }
}
// tile rendering

public void render(GameContainer c, StateBasedGame game, Graphics g) throws SlickException {
   img.draw(x, y,2);
}


And how i did it in Java2D :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
// world
public void render(Graphics2D g) {
   for (int i = 0; i < tiles.length; i++) {
      for (int j = 0; j < tiles[0].length; j++) {
         tiles[i][j].render(g);
      }
   }
}
//tile

public void render(Graphics2D g) {
   g.drawImage(RL.grass, x, y, width, height, null);
}


So anyone care to explain?
22  Game Development / Newbie & Debugging Questions / Re: A little problem..... (Rendering) on: 2015-01-06 21:48:20
I need an a explenation i really don't understand how would i port that? xD
23  Game Development / Newbie & Debugging Questions / A little problem..... (Rendering) on: 2015-01-06 21:36:24
So I am playing around, testing stuff etc... And I saw this :

First one is like okey, but i walk down and WTF?
I am using slick2D, Code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
private Player p;
private StrangeMan sm;

public void init(GameContainer c, StateBasedGame game) throws SlickException {
   sm = new StrangeMan(300,300);
   p = new Player(100, 100,AnimationHandler.Player);
}


public void render(GameContainer c, StateBasedGame game, Graphics g) throws SlickException {
   g.translate(-p.getX()+c.getWidth()/2-p.getWidth()/2,-p.getY()+c.getHeight()/2-p.getHeight()/2);
   p.render(c, game, g);
   sm.render(c, game, g);
}


The question : How can i make my player, when walks in front of the man, render/draw/whatever in front?
24  Game Development / Newbie & Debugging Questions / Re: 2D Game image rendering alternatives? on: 2015-01-04 17:25:56
You should use openGL..... It is way faster and very good i suggest using slick2D for start. Or libGDX it is way better... Using JFrame to do the rendering is not good for a game, it is for aplications buttons a
nd stuff xD !
25  Game Development / Newbie & Debugging Questions / Re: Copying jar files? on: 2015-01-02 14:01:52
My jar file game.jar and i want to copy it to lets say appdata but how do i do it? So how do i get my jars location and how do i copy it to appdata? And must do it in java + i don't know its location!
26  Game Development / Newbie & Debugging Questions / Copying jar files? on: 2015-01-02 13:53:52
I want to copy my jar file to another location.... How do i do that?
27  Game Development / Newbie & Debugging Questions / Dynamic lighting, ray casting soft shadow etc in slick2D. on: 2014-11-16 12:26:02
I want to make lighting in my game and get results like with box2dlights. I don't want to use libgx and box2dlights that is the last option. So are there any libs that i can use with slick2D to make lights like that? Do i use some kind of a shader? I really don't have a clue.......
28  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Slick2D not drawing Images? on: 2014-08-23 16:01:51
I just did -.-'
My image is corupted omg ! thx
29  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Slick2D not drawing Images? on: 2014-08-23 15:52:16
It is it works when the image has no transparent pixels! hhmmmmm
30  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Slick2D not drawing Images? on: 2014-08-23 15:46:29
Slick PNGDecoder Error - java.lang.UnsupportedOperationException: Unsupported format for this image
I got this error........ omg and it doesnt show in the console, when i have no transparent pixels i can see the image and get this error and when i have transparent pixels no error no image showing! NO LD FOR ME!e
Pages: [1] 2 3 ... 6
 
MrMapcom (16 views)
2015-05-23 20:26:16

MrMapcom (22 views)
2015-05-23 20:23:34

Waterwolf (29 views)
2015-05-20 15:01:45

chrislo27 (35 views)
2015-05-20 03:42:21

BurntPizza (70 views)
2015-05-10 15:53:18

FrozenShade (56 views)
2015-05-07 09:11:21

TheLopais (218 views)
2015-05-06 13:36:48

TheLopais (202 views)
2015-05-06 13:35:14

TheLopais (207 views)
2015-05-06 13:33:39

TheLopais (227 views)
2015-05-06 13:32:48
List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00
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!