Sep 16, 2014 03:53 PM (This post was last modified: Sep 19, 2014 11:43 PM by ▁▂▃▄▅▆M1kep▆▅▄▃▂▁.)
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.
(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
(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.
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.
(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...
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.
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.
(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
(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
(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!