deadteck
Senior Newbie 
|
 |
«
Posted
2012-04-22 00:57:04 » |
|
Anyone know how to make a basic block class and how to size it (blocks like in minecraft). Im also looking for a way to have the blocks selected in the "main" method or wherever it gets selected.
|
The best ideas will come from the weirdest and sometimes most f***'d up places, you just have to realize them.
|
|
|
jonjava
|
 |
«
Reply #1 - Posted
2012-04-22 01:09:56 » |
|
A Class is basically just a collection of data.
What kind of data do you think a "Block" class should have?
|
|
|
|
deadteck
Senior Newbie 
|
 |
«
Reply #2 - Posted
2012-04-22 01:16:50 » |
|
A Class is basically just a collection of data.
What kind of data do you think a "Block" class should have?
I got that, but like I dont know how to set it up and I dont know how to "call" it from my main class
|
The best ideas will come from the weirdest and sometimes most f***'d up places, you just have to realize them.
|
|
|
Games published by our own members! Check 'em out!
|
|
jonjava
|
 |
«
Reply #3 - Posted
2012-04-22 01:31:54 » |
|
Your main class, or the "public static void main(String[] args)" method? The "public static void main(...)" method doesn't have anything to do with the class that it's in, it's just the starting point of a java program. I highly recommend you read the java beginner tutorials http://docs.oracle.com/javase/tutorial/java/index.html. "Setting it up" or Creating a class is fairly simple - this is all explained in the tutorials. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| class Block { int width = 0; int height = 0;
public Block(int width, int height) { this.width = width; this.height = height; System.out.println("My area is: " + getArea() ); }
private getArea() { return width * height; }
public static void main(String[] argv) { new Block(); }
} |
|
|
|
|
deadteck
Senior Newbie 
|
 |
«
Reply #4 - Posted
2012-04-22 01:34:24 » |
|
Your main class, or the "public static void main(String[] args)" method?
The "public static void main(...)" method doesn't have anything to do with the class that it's in, it's just the starting point of a java program.
I know that, its just I want to know how to call the block in rendering or wherever you call it into.
|
The best ideas will come from the weirdest and sometimes most f***'d up places, you just have to realize them.
|
|
|
jonjava
|
 |
«
Reply #5 - Posted
2012-04-22 01:37:29 » |
|
|
|
|
|
deadteck
Senior Newbie 
|
 |
«
Reply #6 - Posted
2012-04-22 01:47:25 » |
|
Thanks, ill look into that, any help was needed  and this will work in a 3d world right?
|
The best ideas will come from the weirdest and sometimes most f***'d up places, you just have to realize them.
|
|
|
jonjava
|
 |
«
Reply #7 - Posted
2012-04-22 02:00:01 » |
|
|
|
|
|
deadteck
Senior Newbie 
|
 |
«
Reply #8 - Posted
2012-04-22 02:18:02 » |
|
Ive looked into that already, its just that I dont know what to do now and Im stuck on block creation.
|
The best ideas will come from the weirdest and sometimes most f***'d up places, you just have to realize them.
|
|
|
jonjava
|
 |
«
Reply #9 - Posted
2012-04-22 02:29:52 » |
|
If I may be blunt. The lack of substance in your questions suggest, to me, that you do not have a good hold on programming basics. Therefore I suggest you start there and in the mean time shelve your current idea. You use the word "block" as if it should mean something. I presume it's a class. Instantiating a class is very easy. You just put the "new" keyword before the class name Ie. Nobody can understand what you're trying to do or how you're attempting to do it and why it's not working considering your vague abstract questions.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
ReBirth
|
 |
«
Reply #10 - Posted
2012-04-22 02:39:14 » |
|
Don't jump to 3D world yet, it's serious bussiness. Make it 2D first.
|
|
|
|
deadteck
Senior Newbie 
|
 |
«
Reply #11 - Posted
2012-04-22 02:46:51 » |
|
Don't jump to 3D world yet, it's serious bussiness. Make it 2D first.
Well if I were to make it 2d first, it would take a long time to transfer it over to 3d when thats done wouldnt it?
|
The best ideas will come from the weirdest and sometimes most f***'d up places, you just have to realize them.
|
|
|
ReBirth
|
 |
«
Reply #12 - Posted
2012-04-22 02:49:09 » |
|
That's the road. Of course it's good to have speed progress but if we're not really ready for this, you'll spend more looooong time to debug and make it work.
|
|
|
|
deadteck
Senior Newbie 
|
 |
«
Reply #13 - Posted
2012-04-22 02:53:56 » |
|
I suppose that is true, but its going well except that I am only having problems on specifying a block type and all, and Im also having problems sending the different blocks to the rendering class that I have setup.
|
The best ideas will come from the weirdest and sometimes most f***'d up places, you just have to realize them.
|
|
|
ReBirth
|
 |
«
Reply #14 - Posted
2012-04-22 02:58:43 » |
|
The block class can be modiifed so they're rendering themselves. It'll encapsuled complex function to draw various kind of block. So you just need to pass what they need to draw.
|
|
|
|
deadteck
Senior Newbie 
|
 |
«
Reply #15 - Posted
2012-04-22 03:09:28 » |
|
What do you mean by that? 
|
The best ideas will come from the weirdest and sometimes most f***'d up places, you just have to realize them.
|
|
|
StumpyStrust
|
 |
«
Reply #16 - Posted
2012-04-22 04:31:58 » |
|
Example method that most "renderable" things should have in java 2d 1 2 3 4 5 6 7 8 9 10 11
| public void render(Graphics g) { render stuff here . . . g.fillrect(x1,y1,x2,y2); . . . } |
You should look at the api for the graphics and Graphics2D objects and then look at how to setup your own custom canvas, Frame, or JPanel to do the rendering. If you know how to do that then rendering a simple square/block is trivial.  Going from 2D to 3D is rather difficult early on. Get good at 2D then go to 3D. Its not that hard to switch it just takes practice....lots of it....and an ungodly amount of tutorial reading....I still suck at 3D  But I will get better as long as I keep working at it. So don't be discouraged by asking nooby questions but I would do a quick google search before posting because what you seem to be asking is done many times in tutorials that you can find via google. Hope this helps.
|
|
|
|
Longarmx
|
 |
«
Reply #17 - Posted
2012-04-22 04:40:27 » |
|
You could have a 3d array with your blocks stored in it. You can change one of the blocks' type, and the rendering code will be able to recognize that the one block is different and be able to render that block different.
You could also pass the rendering function a different type for that one block, and it will be rendered different.
If you want to be able to select a certain block, you will have to set up a coordinate system. As for rendering the actual blocks, you will have to know OpenGL and a bit of math in order to render at a certain angle and position.
I do agree with jonjava and StumpyStreet; know 2d cold, and then start getting into 3d.
Bye the way, what 3d engine are you using?
~Longarmx
|
|
|
|
deadteck
Senior Newbie 
|
 |
«
Reply #18 - Posted
2012-04-22 05:28:06 » |
|
You could have a 3d array with your blocks stored in it. You can change one of the blocks' type, and the rendering code will be able to recognize that the one block is different and be able to render that block different.
You could also pass the rendering function a different type for that one block, and it will be rendered different.
If you want to be able to select a certain block, you will have to set up a coordinate system. As for rendering the actual blocks, you will have to know OpenGL and a bit of math in order to render at a certain angle and position.
I do agree with jonjava and StumpyStreet; know 2d cold, and then start getting into 3d.
Bye the way, what 3d engine are you using?
~Longarmx
Oh, i get it, I think, and Im using LWJGL right now but if needed I could switch I guess. And how would you even go about setting up a coordiante system? Im looking into that but I cant find anything 
|
The best ideas will come from the weirdest and sometimes most f***'d up places, you just have to realize them.
|
|
|
deadteck
Senior Newbie 
|
 |
«
Reply #19 - Posted
2012-04-22 05:40:20 » |
|
So don't be discouraged by asking nooby questions but I would do a quick google search before posting because what you seem to be asking is done many times in tutorials that you can find via google.
thanks a lot, I really appreciate it 
|
The best ideas will come from the weirdest and sometimes most f***'d up places, you just have to realize them.
|
|
|
|