Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

LWJGL "Game" follow along! Updated often[September 19] and taking/want suggestions

As the title says I'd love to get some pointers on my code so far, my idea for this "game" is pretty much just having players that I will hopefully be able to switch between and just testing general physics eventually and lighting etc.

So far I just have the very base started but I'd appreciate if any of you could give me some pointers/tips/suggestions. I tried to comment alot of the code.

Thanks to anybody who gives it a look :D

https://github.com/M1kep/RandomCodeProje...0World/src
Looks good but please put your classes in a package.
Oh and I would prefer creating getters and setters in your Entity class.

Looking other otherwise.
(Sep 17, 2014 02:28 AM)MrOrang Wrote:  Looks good but please put your classes in a package.
Oh and I would prefer creating getters and setters in your Entity class.

Looking other otherwise.

Haha, ok ill add the classes to a package, and ya I don't know why I hadn't done the getters/setters yet :/ although I feel like the only use would be Teleportation....

This evening I am working on multiple players and mouse/keyboard input
Your code looks nice.

Here are some pointers:

int ptr = malloc(sizeof(int) 5);
char *cstring = "well these are some pointers, hope it helped!";
(Sep 17, 2014 08:21 PM)Shellow5 Wrote:  Your code looks nice.

Here are some pointers:

int ptr = malloc(sizeof(int) 5);
char *cstring = "well these are some pointers, hope it helped!";

Haha thanks ;P I had a feeling somebody would do that :P

Also have once again updated the project!

Changes:
Added support for multiple players(Switch between "players" with 'P')
Added an axis for spatial reference.
Changed how position of an entity is stored.
Moved code to a package.
Keyboard input and mouse input added.
Movement is based off of viewing angle and rotation.

https://github.com/M1kep/RandomCodeProje...m1kep/game
Just from quickly looking at it, here is a little bug:

[Image: MfOb9Ap.png]
you have to use this(...) instead to call the other constructor
https://github.com/M1kep/RandomCodeProje.../cube.java

The class should be called "Cube" not "cube". Also, it'd probably be better to write a proper VBO/VAO renderer, as well as making a totally separate renderer class so that you're not rewriting all your render calls a million times.

https://github.com/M1kep/RandomCodeProje...ntity.java

Why not make the fields private?

https://github.com/M1kep/RandomCodeProje...layer.java

Some stuff here can probably be moved into Entity.java

Those are just things that bothered me; you don't necessarily hafta fix them all.
Awesome thanks for the tips :D

And Godshawk the reason they aren't private is because then my player class couldn't access them

I also took the suggestions and implemented them!

Also what exactly should the"renderer" class do? Would it have the cube code in it or....?

Also taKing suggestions and tips all the time!
(Sep 19, 2014 12:18 AM)▁▂▃▄▅▆M1kep▆▅▄▃▂▁ Wrote:  Awesome thanks for the tips :D

And Godshawk the reason they aren't private is because then my player class couldn't access them

I also took the suggestions and implemented them!

Also what exactly should the"renderer" class do? Would it have the cube code in it or....?

Also taKing suggestions and tips all the time!

Don't access the fields directly; use getters and setters. I personally prefer to do it that way, but you don't hafta.

For a renderer, I meant something like this:

PHP Code

<?php 
public class Renderer {
  public 
void startDrawing(int drawMode) {}
  public 
void draw() {}
  public 
void addVertex(float x, float y, float z) {}
  public 
void color(int color) {}
} 

Only with method bodies and all filled out. I'm pretty sure I have one around here somewhere, but don't have it on-hand right now...
(Sep 18, 2014 02:03 AM)How bout using your brain Wrote:  Just from quickly looking at it, here is a little bug:

[Image: MfOb9Ap.png]
you have to use this(...) instead to call the other constructor

Also wanted to thank you for this :P Helped me out quite a bit, can you explain why that needs to be that way?

(Sep 18, 2014 07:43 PM)audrey Wrote:  https://github.com/M1kep/RandomCodeProje.../cube.java

The class should be called "Cube" not "cube". Also, it'd probably be better to write a proper VBO/VAO renderer, as well as making a totally separate renderer class so that you're not rewriting all your render calls a million times.

https://github.com/M1kep/RandomCodeProje...ntity.java

Why not make the fields private?

https://github.com/M1kep/RandomCodeProje...layer.java

Some stuff here can probably be moved into Entity.java

Those are just things that bothered me; you don't necessarily hafta fix them all.

I have made the fields private now and set up getters and setters and updated the code to use them accordingly :)

Thank you for the criticism/suggestion :D

Always open to that

(Sep 19, 2014 12:06 PM)audrey Wrote:  For a renderer, I meant something like this:

PHP Code

<?php 
public class Renderer {
  public 
void startDrawing(int drawMode) {}
  public 
void draw() {}
  public 
void addVertex(float x, float y, float z) {}
  public 
void color(int color) {}
} 

Only with method bodies and all filled out. I'm pretty sure I have one around here somewhere, but don't have it on-hand right now...

Ah ok, I will look into that whole VBO rendering stuff, i've read a LITTLE about it, but don't have a understanding for it yet.
(Sep 19, 2014 11:44 PM)▁▂▃▄▅▆M1kep▆▅▄▃▂▁ Wrote:  Also wanted to thank you for this :P Helped me out quite a bit, can you explain why that needs to be that way?


Because otherwise you are constructing two Player objects when you call that constructor. Simply put anyway.

Im stalking you.
(Sep 19, 2014 11:48 PM)๖ۣۜSerendipity Wrote:  Because otherwise you are constructing two Player objects when you call that constructor. Simply put anyway.

Im stalking you.

Welll..... while your stalking me you should stalk my code :P I've added some more documentation and multiple players and stuffs :P

Here's a change log:
https://github.com/M1kep/RandomCodeProje...its/master

And here's a link to the repository:
https://github.com/M1kep/RandomCodeProje...m1kep/game
(Sep 19, 2014 11:50 PM)▁▂▃▄▅▆M1kep▆▅▄▃▂▁ Wrote:  Welll..... while your stalking me you should stalk my code :P I've added some more documentation and multiple players and stuffs :P

Here's a change log:
https://github.com/M1kep/RandomCodeProje...its/master

And here's a link to the repository:
https://github.com/M1kep/RandomCodeProje...m1kep/game

I have been stalking that a little, from the shadows of course. 😝
Everything I could have commented on has already been mentioned.

As for VBO's though there is a nice tutorial on Youtube about them, its more of an introduction as to why to use them vs immediate mode and so on.


Looks like you learned a shitload from getting help from here. I'm thinking of making my project public now too :P
[Image: 7nxcR3j.png]

Ascended Master
BTC: 16tc4dNEj59Zsv5TsiL6vRG8tYtCYDevnZ


(Sep 20, 2014 10:19 AM)Vᴇᴀxᴏʀᴇ Wrote:  Looks like you learned a shitload from getting help from here. I'm thinking of making my project public now too :P

Haha, ya I personally like open source especially while I'm still learning much easier for people to read too!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by WomasFeb 4, 2018 06:16 AM 1 89 Feb 4, 2018 06:16 AM
Last Post: Sogomn
[Java] by aRuHZoNaDec 5, 2016 06:48 AM 4 256 Dec 5, 2016 06:48 AM
Last Post: CAFEEFAC
[C] by Recycle Bin.Nov 6, 2015 09:36 PM 61 6,285 Nov 6, 2015 09:36 PM
Last Post: TheUnCola