User avatar
malakai
Posts: 1382
Joined: Sat Sep 15, 2012 10:35 am
Contact: Website

Re: Not Minecraft, but Blocky

Fri Nov 09, 2012 7:57 pm

Thank you this is looking so fantastic.

Still having problems on the Windows side :(

Import looks like it's going well but at the end I get.

2 warnings

Code: Select all

Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment. 
I can change it to other environments but get same error.

100 errors

Code: Select all

BufferedImageUtil cannot be resolved 
on TextOverlay.java

GL20Renderer.java etc.. All similar errors where am I going wrong?
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)

User avatar
jackjt8
Posts: 31
Joined: Wed Oct 17, 2012 5:16 pm

Re: Not Minecraft, but Blocky

Fri Nov 09, 2012 8:05 pm

When I get home, I'll try this.
As you said, it's not minecraft, but I want to play it, looks nice :D
Beep Boop

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Fri Nov 09, 2012 9:38 pm

I am sorry. I used a user library in Eclipse to hold the LWJGL jars for the projects, but that sits in the Eclipse workspace (with is not portable) instead of with the projects, so it did not go into the repository. I have fixed it so that the projects now share the LWJGL jars between themselves without needing a separate library. Please refresh from the repository. Those 100 errors will now be resolved.

As to the other problem, it is a warning that the JVM does not exactly match the projects requirements, but is OK as long as the JVM is at least 1.6 compatible. To take the warnings away, right click on each project, select Properties, select Java Build Path, select Libraries, double click on the JRE System Library entry and select the JVM that matches what you are using.

User avatar
malakai
Posts: 1382
Joined: Sat Sep 15, 2012 10:35 am
Contact: Website

Re: Not Minecraft, but Blocky

Sat Nov 10, 2012 1:48 am

You are fantastic I thank you so much got it going in Windows needed to update my laptop driver to support OpenGL

Youtube video I just hurried and made this so it is not fantastic gives you the idea about Blocky though..


http://www.youtube.com/watch?v=urteCF7n ... e=youtu.be


I have a tutorial on what is needed to get started with editing this in Windows if anyone is interested.

http://www.raspians.com/blocky-not-mine ... pberry-pi/

Thanks again my kids are besides themselves with excitement.
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Sat Nov 10, 2012 6:10 pm

Here are a couple of easy to do things that could just get kids excited. I find it works best if I have my son do the typing while we figure out what to do together.

Things to do #1: change the background color
In Blocky.java the background color of the scene is set in this line:

Code: Select all

renderer.setBackgroundColor(new Color(0.6f, 0.6f, 1.0f, 1.0f));
The color parameters are in order: red, green, blue and alpha (transparency). Values range from 0.0 (darkest) to 1.0 (lightest) for red, green and blue. You can create an alien looking world by making the sky orange or purple for example.

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Sat Nov 10, 2012 6:18 pm

Things to do #2: change the FOV (field of view)
The FOV defines how much of the world is shown in the view frustum (the visible area seen by the camera). Making the FOV larger makes it look like you have zoomed out and making the FOV smaller looks like you have zoomed in. You can get something that looks like a sniper view by making FOV around 15.

Here is the line in Blocky.java:

Code: Select all

camera.setFieldOfView(45.0f);
If you like the Minecraft style view then you can set the FOV to 70 to get the same effect.

If you use really large numbers for FOV (180 and larger) then you get really strange, and sometimes funny, effects.
Last edited by spsn on Sat Nov 10, 2012 6:29 pm, edited 1 time in total.

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Sat Nov 10, 2012 6:29 pm

Things to do #3: set the (mood of the) environment
The environment of the scene can be changed to give it a different mood or feel.

In Blocky.java this line defines 3 environment types we have so far:

Code: Select all

private int environmenType = 0;
Type 0 is the default day time, type 1 is for a gloomy, foggy feel you get on a rainy day, and type 2 is for night time where you can play with the torches.

Scan the code for where environmenType is used and you will see that you can play around with which shader is selected to do the rendering, what background color is selected and what value is used for the world light (i.e. sun light).

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Sat Nov 10, 2012 6:38 pm

Things to do #4: change the size of the world
In Blocky.java this line defines the size of the world:

Code: Select all

private int xs = 128, ys = 128, zs = 128;
The X (left to right) and Z (front to back) directions define the horizontal size of the world. You can set these to any multiple of 16 (the region size) up to the maximum for your platform.

On the RasPi the maximum is 256, any larger and you run out GPU memory (I am sure the mesh data can be optimised to get some more free memory for more meshes).

On PC with a 1GB card we have done a 1024 world before.

Just remember that the larger you make the world, the lower the FPS will be.

You can get a really silly world by making the size very small, like 32.

The Y direction (up and down) defines the height of the world. It is currently linked to the terrain generation code, so funny things are bound to happen when you set the value to something other than 128. :)
Last edited by spsn on Sat Nov 10, 2012 6:58 pm, edited 1 time in total.

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Sat Nov 10, 2012 6:42 pm

Things to do #5: make the player move faster
In Blocky.java this line controls the speed of the player:

Code: Select all

private float gspeed = 0.001f;
You can double the value to make the player move 2x as fast, or make the value 20x faster to get superman mode. Just watch out, you might fly into a mountain and get stuck on the inside.

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Sat Nov 10, 2012 6:45 pm

Things to do #6: change gravity
In Blocky.java this line controls the strength of gravity:

Code: Select all

private float gspeed = 0.001f;
Make the value 2x bigger and you will have to double jump to get up a block. Make the value 10x smaller and you will get super jumping ability.

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Sat Nov 10, 2012 6:55 pm

Things to do #7: add a new kind of block
In the res folder you will find terrain.png, the texture atlas for all the possible blocks that can be make. We have just included a few in Blocky for us to play with, but you can add some more. Adding code for a new block and then being able to see it work in Blocky is sure to get an excited giggle from the kids.

In Blocky.java this method is where the materials are create for the different textures in the texture atlas:

Code: Select all

public void createMaterials()
For a new material you need to tell it the coordinates of the texture in the texture atlas to use. The coordinates start from 0,0 in the top left corner of the texture atlas.

In Blocky.java this method is where the different types of block are created:

Code: Select all

public void createBlocks()
For each block you need to tell it which materials to use for the different sides.

Once you have your new block added, run Blocky and the new block will appear when you cycle around in the block selector with the 1 and 2 keys, and you will be able to place and destroy your new block.

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Sat Nov 10, 2012 7:03 pm

Things to do #8: add more trees to the world
In Generator.java the following method generates the terrain, with the sand, water, grass, trees, clouds etc:

Code: Select all

public void generateTerrain(
	final Renderer renderer,
	final ProgressBarOverlay s2)
This line is where the number of tree is defined:

Code: Select all

// Tree
for (int i = 0; i < 100f * factor; i++)
Make the 100f value 2x larger for double the number of trees, or 10x larger if you want to get a dense forest effect.

You can do the same for the tall grass, flowers, roses, clouds etc. More clouds give you more shadows over your world.

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Sat Nov 10, 2012 7:11 pm

Things to do #9: change the shadows
In Generator.java, this method defines how much sun light is absorbed by water, leaves and clouds:

Code: Select all

public void setLighting(
	final int x,
	final int z,
	final byte worldLight)
Absorb more light for darker shadows, or absorb less light for lighter shadows.

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Sat Nov 10, 2012 7:19 pm

Things to do #10: make a crazy camera
In GLES20Renderer.java (for RasPi) or GL20Renderer.java (for PC) these lines define how the world is oriented when the camera view is moved around with the mouse:

Code: Select all

// Rotate view to camera orientation
Matrix.glRotatef(camera.getYaw(), 1.0f, 0.0f, 0.0f);
Matrix.glRotatef(camera.getPitch(), 0.0f, 1.0f, 0.0f);
Change the 1.0f values to -1.0f (negative) values to reverse the direction in which the world is oriented and make the camera go crazy when you move the mouse around.

There you have 10 things to do with Blocky with your kids and hopefully get them all excited about programming. :D

texy
Forum Moderator
Forum Moderator
Posts: 5155
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Not Minecraft, but Blocky

Tue Nov 13, 2012 3:46 pm

I,m still getting to grips with linux, github,etc, etc.
Do you have precise instructions on how to install and run it on the Pi?
Cheers,
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Tue Nov 13, 2012 6:53 pm

To get Blocky running on your Raspberry Pi, please follow the steps below:

Step 1: Install JAVA (if you do not already have it)
Install OpenJDK Zero:

Code: Select all

sudo apt-get install openjdk-7-jre
In addition, you may also install JamVM which is quite a bit faster than Zero:

Code: Select all

sudo apt-get install icedtea-7-jre-jamvm
Step 2: Get Blocky
Point your browser to the github repository for Blocky:

Code: Select all

https://github.com/spsn/blocky
There are 4 archive (.tgz) files to choose from.

If you just want to run Blocky, on a softfloat image like Wheezy, click on this file:

Code: Select all

blocky-run-pi-armel.tgz
If you just want to run Blocky, on a hardfloat image like Raspbian, click on this file:

Code: Select all

blocky-run-pi-armhf.tgz
If you want to do development on Blocky, on a softfloat image like Wheezy, click on this file:

Code: Select all

blocky-dev-pi-armel.tgz
If you want to do development on Blocky, on a hardfloat image like Raspbian, click on this file:

Code: Select all

blocky-dev-pi-armhf.tgz
Click on the "Raw" button, in the middle of the screen to the right, to download your chosen file.

If you have downloaded the file for Blocky to your PC, then you need to copy the file over to your
Raspberry Pi. I find it easiest to put the file in a share on my PC and then to mount the share on my
Raspberry Pi to copy the file.

To mount a Windows share on the Raspberry Pi you may use a command like this, just replace your own values:

Code: Select all

sudo mount -t cifs -ousername=spsn 10.0.0.1:Public /mnt
Then to copy the file over to the Raspberry Pi, into the /home/pi directory:

Code: Select all

cp /mnt/blocky-run-pi-armhf.tgz /home/pi/
Step 3: Install Blocky
It is not really an install, we just need to extract the contents of the archive (.tgz) file we downloaded from the github repository.

For example, if the file blocky-run-pi-armhf.tgz is in the /home/pi directory:

Code: Select all

cd /home/pi
tar -xzvf blocky-run-pi-armhf.tgz
Step 4: Run Blocky
Blocky needs X to be running, so start X first.

If you have downloaded the -run- version of Blocky, use the following to run Blocky:

Code: Select all

cd blocky
./blocky
Or, if you have JamVM installed:

Code: Select all

cd blocky
./blocky-jamvm
If you have downloaded the -dev- version of Blocky, use the following to build and run Blocky. The build
step takes about 1.5 minutes or so:

Code: Select all

cd blocky-dev
./build
./blocky
Or, if you have JamVM installed:

Code: Select all

cd blocky-dev
./build
./blocky-jamvm

User avatar
raspberrypiguy1
Posts: 379
Joined: Sun Sep 02, 2012 7:01 pm

Re: Not Minecraft, but Blocky

Wed Nov 14, 2012 10:35 am

Hi! May I say that your work on Blocky looks amazing! If I can get it to work I might do a tutorial on it...

I am running through your steps and have downloaded blocky-run-pi-armhf.tgz as I am running Raspbian... However when I try to extract the .tgz file with the command: tar -xzvf blocky-run-pi-armhf.tgz I get a error (I presume it is a error?) saying this:

Code: Select all

gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now 
What am I doing wrong? I have no idea? What should I do now? I am running a BRAND NEW version of Raspbian.... As in 'downloaded today' new!

Please help me it looks awesome! I am a minecraft lover as well!

The Raspberry Pi Guy ;)
Matt, The Raspberry Pi Guy YouTube channel, author of Learn Robotics with Raspberry Pi, available now: http://mybook.to/raspirobots, Computer Science & Electronics Undergraduate at The University of Edinburgh

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Wed Nov 14, 2012 5:06 pm

I have downloaded all 4 of the archive (.tgz) files from the github repository to check them and I was able to successfully extract the contents of each on my Raspberry Pis, so I think the archive files are ok.

After some google-fu I found that the most common reasons for the above error have been reported as: the file being only partly downloaded, or the file being corrupted.

Can you please download the archive (.tgz) file from the repository again, check that its size on the RasPi is similar to what is reported on github, and then try to extract the contents again?

User avatar
Bigcat123
Posts: 230
Joined: Thu Aug 23, 2012 2:41 pm

Re: Not Minecraft, but Blocky

Wed Nov 14, 2012 5:28 pm

I got the same problems as The Raspberry Pi Guy...

Are we just meant to do this threw Midori? How long do those files take to download? Thanks
Just a beginner sharing his experiences on his way to geek nirvana...

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Wed Nov 14, 2012 5:34 pm

How are you downloading the file? On PC, or on the RasPi? Which browser are you using? And how are you getting the file onto the RasPI?

User avatar
Bigcat123
Posts: 230
Joined: Thu Aug 23, 2012 2:41 pm

Re: Not Minecraft, but Blocky

Wed Nov 14, 2012 6:26 pm

I was doing this on the RasPi.... Through Midori... When I did the command ls it looked like everything was in the tgz file
Just a beginner sharing his experiences on his way to geek nirvana...

texy
Forum Moderator
Forum Moderator
Posts: 5155
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Not Minecraft, but Blocky

Wed Nov 14, 2012 6:42 pm

Thanks for the instructions.
I,ve downloaded and extracted, but can't run it :

Code: Select all

[email protected] /home $ cd shares/
[email protected] /home/shares $ cd public/
[email protected] /home/shares/public $ cd blocky/
[email protected] /home/shares/public/blocky $ ./blocky
bash: ./blocky: Permission denied
[email protected] /home/shares/public/blocky $ sudo ./blocky
sudo: ./blocky: command not found
[email protected] /home/shares/public/blocky $ sudo blocky
sudo: blocky: command not found
[email protected] /home/shares/public/blocky $ ./blocky-jarmvm
bash: ./blocky-jarmvm: No such file or directory
[email protected] /home/shares/public/blocky $ ./blocky-javmvm
bash: ./blocky-javmvm: No such file or directory
[email protected] /home/shares/public/blocky $ dir
blocky	blocky-jamvm  ge-demo.jar  ge-framework.jar  lwjgl  res  slick-util.jar
[email protected] /home/shares/public/blocky $ ./blocky-jamvm
bash: ./blocky-jamvm: Permission denied
[email protected] /home/shares/public/blocky $ sudo ./blocky-jamvm
sudo: ./blocky-jamvm: command not found
[email protected] /home/shares/public/blocky $
Any idea's ??
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Wed Nov 14, 2012 6:57 pm

Is the /home/shares/public directory actually on the RasPi, or is it a share mounted from a PC? Did you use sudo when extracting the contents? If sudo was used then the file will belong to user "root" instead of to user "pi" and then user "pi" will not be able to run the files. It is best to extract as user "pi" on the RasPi itself.

texy
Forum Moderator
Forum Moderator
Posts: 5155
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Not Minecraft, but Blocky

Wed Nov 14, 2012 7:14 pm

The directory is on the Pi and the public folder is accessable by my laptop. I used windows on the laptop to download the file and used Winrar to extract it to the Pi's directory. I did it that way because midori on the Pi didn't download it correctly.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

User avatar
spsn
Posts: 72
Joined: Wed Nov 07, 2012 6:33 pm

Re: Not Minecraft, but Blocky

Wed Nov 14, 2012 7:29 pm

Ok. When you are in your "public" directory and you do a "ls -l" you will probably see that the "blocky" directory belongs to "root root". That is because the extract was done from the PC side.

To change the ownership to user "pi" use the following command in the "public" directory:

Code: Select all

sudo chown -R pi:pi blocky
Then you should be able to run the scripts to start Blocky.

Return to “Gaming”