Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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]
1  Games Center / Cube World Projects / Re: Why doesnt it render anything! on: 2014-01-16 17:40:52
Well the whole program goes together fine here the main class

package com.voxel.engine.core;

import com.voxel.engine.core.Block.Block;
import com.voxel.engine.core.Camera.FPCameraController;
import com.voxel.engine.core.Chunk.ChunkManager;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.*;
import org.lwjgl.util.glu.GLU;

import java.util.Random;

import static org.lwjgl.opengl.GL11.*;

/**
 * Created with IntelliJ IDEA.
 * User: Toby's PC
 * Date: 06/01/14
 * Time: 15:47
 */
public class Core {

    public static final int WORLD_WIDTH = 8;
    public static final int WORLD_HEIGHT = 1;
    public static final int BLOCK_WIDTH = 16;
    public static final int BLOCK_HEIGHT = 16;

    private Cube cube = new Cube();
    private Block.BlockType blockType = Block.BlockType.BLOCK_TYPE_STONE;

    FPCameraController camera = FPCameraController.getInstance();

    public static final int SCREEN_WIDTH = 640;
    public static final int SCREEN_HEIGHT = 480;
    public static final String TITLE = "Voxel Engine V0.01";

    private float playerX, playerY, playerZ;

    /**
     * Method that is run at the start
     */
    public void start(){
        try{
            createWindow(SCREEN_WIDTH, SCREEN_HEIGHT, TITLE);

            PixelFormat pixelFormat = new PixelFormat();
            ContextAttribs contextAttribs = new ContextAttribs(3, 0);

            Display.create(pixelFormat, contextAttribs);
            glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());

            if(GLContext.getCapabilities().OpenGL21){
                System.out.println("OpenGL21 Supported");
            }

            Random random = new Random();
            for(int x = 0;x < 16;x++){
                for (int z = 0;z < 16;z++){
                    ChunkManager.getInstance().addChunk(ChunkManager.ChunkType.CHUNK_TYPE_RANDOM, x, 0, z);
                }
            }

            initGL();
            run();
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    /**
     * Creates our window based on values given
     *
     * @param width, Width of our screen
     * @param height, Height of our screen
     * @param title, The title of the game
     */
    public void createWindow(int width, int height, String title){
        try {
            Display.setFullscreen(false);
            Display.setDisplayMode(new DisplayMode(width, height));
            Display.setTitle(title);
            Display.setVSyncEnabled(true);
        } catch (LWJGLException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }

    /**
     * Init all the graphics components
     */
    public void initGL(){
        GL11.glMatrixMode(GL_PROJECTION);
        GL11.glLoadIdentity();
        GLU.gluPerspective(45.0f, (float) Display.getDisplayMode().getWidth() / (float) Display.getDisplayMode().getHeight(), 0.1f, 300.0f);
        GL11.glEnable(GL11.GL_FOG);

        GL11.glTranslatef(0, -1f, 0f);
        GL11.glRotatef(180.0f, 0, 1.0f, 0);
        GL11.glMatrixMode(GL_MODELVIEW);
        GL11.glLoadIdentity();
        GL11.glShadeModel(GL_LINE_SMOOTH);
        GL11.glClearColor(0.1f, 0.5f, 0.7f, 0.0f);
        GL11.glClearDepth(1.0);
        GL11.glEnable(GL_DEPTH_TEST);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
        GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
        GL11.glCullFace(GL11.GL_BACK);
        GL11.glEnable(GL11.GL_CULL_FACE);
    }



    public void run(){
        float rotateYaw = 1;
        while(!Display.isCloseRequested()){
            try{
                inputManager();
                GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
                GL11.glLoadIdentity();
                GL11.glTranslatef(-30f + playerX, -40f + playerY, -160f + playerZ);
                GL11.glRotatef(45f, 0.4f, 1.0f, 0.1f);
                GL11.glRotatef(45f, 0f, 1.0f, 0f);
                rotateYaw += 1;
                render();

                Display.update();
                Display.sync(60);
            }catch(Exception e){
                e.printStackTrace();
            }
        }
        Display.destroy();
    }

    public void inputManager() {
        if(Keyboard.isKeyDown(Keyboard.KEY_W)){
            playerY--;
        }
        if(Keyboard.isKeyDown(Keyboard.KEY_S)){
            playerY++;
        }
        if(Keyboard.isKeyDown(Keyboard.KEY_A)){
            playerX++;
        }
        if(Keyboard.isKeyDown(Keyboard.KEY_D)){
            playerX--;
        }
        if(Keyboard.isKeyDown(Keyboard.KEY_E)){
            playerZ--;
        }
        if(Keyboard.isKeyDown(Keyboard.KEY_Q)){
            playerZ++;
        }
    }

    public void render(){
        ChunkManager.getInstance().render();
    }

    public static void main(String[] args){
        Core core = new Core();
        core.start();
    }
}
2  Games Center / Cube World Projects / Re: Why doesnt it render anything! on: 2014-01-16 17:30:15
Core Class - http://pastebin.com/8WN7jSYi
Cube Class - http://pastebin.com/enjSxxi0
Frustum - http://pastebin.com/ehTdy3rZ
Simplex Noise - http://pastebin.com/4L4icJMG
Chunk - http://pastebin.com/6XCFG7Ch
Chunk Manager - http://pastebin.com/etXbZQNn
Chunk Protocol - http://pastebin.com/2BmfXKjv
Camera - http://pastebin.com/WbnhYcaD
FPCameraController - http://pastebin.com/L5cEVcLK
Block - http://pastebin.com/8rZwhL3q

It didnt let me paste the code directly into the post so heres the paste bin instead
3  Games Center / Cube World Projects / Why doesnt it render anything! on: 2014-01-15 20:41:32
I have this code here https://www.dropbox.com/s/eo3ramkukk71ahu/src.rar and i was wandering why doesnt it render anything, can someone please help me thanks!
4  Games Center / Cube World Projects / Re: How to add noise on: 2014-01-09 20:33:15
Whats the game map array I havent got that
5  Games Center / Cube World Projects / Re: How to add noise on: 2014-01-09 20:18:17
Ok have no idea but what the hell
6  Games Center / Cube World Projects / Re: How to add noise on: 2014-01-09 18:55:07
These help a bit but i need some help on how to add these to my code
7  Games Center / Cube World Projects / How to add noise on: 2014-01-09 17:34:46
Hi this is my voxel engine so far...

This is my chunk class - http://pastebin.com/W64LSh07
This is my main game class - http://pastebin.com/axULjzRt

Could someone please tell me how to add random noise to this engine, so my voxels have different heights thus making random generation, I have looked a simplex noise i just dont know how to add it to my engine

Thanks Toby
8  Game Development / Newbie & Debugging Questions / Re: Problem in Game Engine on: 2013-08-23 16:03:00
Well it is a game engine for home use and I have looked at the javahub but I would then need to change all my code and add more classes but I dont have time. So I would rather do the small changes as a temporary solutions then come back to the problem.
9  Game Development / Newbie & Debugging Questions / Re: Problem in Game Engine on: 2013-08-23 13:22:55
Thats what I do i check the buferedImage 2 first time create it second time print the err message.
10  Game Development / Newbie & Debugging Questions / Re: Problem in Game Engine on: 2013-08-23 12:40:19
Ha anybody got a idea yet I have been working on this for hours and still cant find the bug. It needs to done by 1
11  Game Development / Newbie & Debugging Questions / Problem in Game Engine on: 2013-08-23 11:47:03
I Have this problem in my game engine where I am trying to create a double buffering image and it keeps saying null. I have tryed to debug but still cant get this to work. I only have today to get it to work so I would love it if you fix it thanks Toby.

Code here https://www.dropbox.com/s/25wm2wcaz77awkg/Eclispe%20Workspace.zip
12  Discussions / Community & Volunteer Projects / Re: Need A Artist on: 2013-07-01 08:14:03
I know but I am bored of making 2d mincraft. And anyway a remake of minecraft isn't going to go anywhere. People don't want to play the same but 2d. My idea is a sidescroller game with adventure and a bit of RPG in it.
13  Discussions / Community & Volunteer Projects / Need A Artist on: 2013-06-30 16:26:15
Hi guys this it Toby here. A little background into me. I have been programming for 1 and a bit years now. I am only 14 but have intermediate experience in Java. I have been testing and learning new things to expand my Java knowledge ready to build a nice looking game. This is now the chance to make this game. I am looking for a artist who can make good looking 2d and 2d sprites and also walk animations. If you have any experience in Java that would help a lot as well. If you would like the opportunity I would love it and can you please email me at tobydrane@btinternet.com

Thanks Toby. I will send you my ideas if you email me.
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (64 views)
2014-04-15 18:08:23

BurntPizza (62 views)
2014-04-15 03:46:01

UprightPath (75 views)
2014-04-14 17:39:50

UprightPath (58 views)
2014-04-14 17:35:47

Porlus (76 views)
2014-04-14 15:48:38

tom_mai78101 (101 views)
2014-04-10 04:04:31

BurntPizza (161 views)
2014-04-08 23:06:04

tom_mai78101 (256 views)
2014-04-05 13:34:39

trollwarrior1 (209 views)
2014-04-04 12:06:45

CJLetsGame (216 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!