0

Using Pulpcore properly in your own project!

Posted by samson on May 28, 2010 in PulpCore

Proper coding practises dictates that we classify our code according to the nature and function of the class, making it as descriptive as possible. However, using Pulpcore Module for Netbeans, we cannot do that.

By default, we are prompted for a new project name, which is used only as the directory name, while the rest of the generated files are simply copied over and dump into the directory. When starting a new Pulpcore full project, we will be presented with the following listing for files.

After you have converted the pulpcore libaries to the latest release, you are still stuck with a group of files that would compiled to display ‘Hello World’, with a program title called ‘Hello World’ and a class called ‘Hello World’!

My method of changing this with little to no headaches is using Netbean’s refractor.

The following window will then pop up, change the class name to whatever you want.

Remember to check ‘Apply Renmae on comments’ as that will make your JavaDoc making more sense should you refer to the class that you are changing name for.

Now, if you attempt a build, it will actually compile. However, if you launch it, the player will state that it can’t find the class ‘HelloWorld.jar’. So to fix that we have a few more steps to take.

Next, navigate to and change the two ‘HelloWorld’ to ‘MovingText’ or whatever you name your former ‘HelloWorld’ class.

Then, let’s navigate to and change all the ‘HelloWorld’ to ‘MovingText’ or whatever you name your former ‘HelloWorld’ class.

Lastly, navigate to your Netbean’s project folder and find a file called ‘build.properties’, open it notepad or other simple text editor. Replace all ‘HelloWorld’ with the new name of the class file.

Now, you can go back to NetBeans and have the system ‘Clean and build’ again. All files in the ‘build’ folder will now be regenerated and linked properly to launch ‘MovingText’ instead of ‘HelloWorld’

Tags: , , ,

 
0

Pulpcore continued…

Posted by samson on May 26, 2010 in PulpCore

After publishing my previous post on Pulpcore, I realized that I have forgotten one of the major part I intended for that post, how to update your NetBeans Pulpcore libaries to the latest release. At the time of writing, Pulpcore is on Version 0.11.5.

How do I know which version of Pulpcore Libaries I am using?

That is actually really difficult to answer, as I don’t recall seeing any ‘Pulpcore version’ indication in the compiled code, the only way you can tell is from the console within the Pulpcore player itself. However, as we are all Java Adicts, we have a better way of finding that out from the code, we look for deplicated methods in the Library!

In class Pulpcore.sprite, there is a method called ‘setAnchor(int anchor)’

It was originally designed to allow users to set the anchor point on a sprite allowing for a easier point of reference. In the original pulpcore libraries, the method setAnchor would take in an interger presenting one of nine points, which looks like this:

        NW     N     NE
          +----+----+
          |         |
        W +    *    + E
          |         |
          +----+----+
        SW     S     SE

With a predefined list of integers in the Sprite class in the form of Sprite.NORTH, Sprite.NORTH_EAST, etc…

However, this method is now deplicated in Pulpcore 0.11.5, the new setAnchor accepts two double, AnchorX and AnchorY.

setAnchor(double anchorX, double anchorY)

        (0.0,0.0)  (0.5,0.0)  (1.0,0.0)
            +----------+----------+
            |                     |
            |                     |
            |                     |
            |      (0.5,0.5)      |
  (0.0,0.5) +          *          + (1.0,0.5)
            |                     |
            |                     |
            |                     |
            |                     |
            +----------+----------+
        (0.0,1.0)  (0.5,1.0)  (1.0,1.0)

With this as our weapon, we can easily find out whether we are using the newer Pulpcore Libaries or not.

NetBeans upgrade proceedures

So, continuing from yesterday’s post, now you have your first ‘Hello World’ program in pulpcore, let’s convert it to Pulpcore 0.11.5!

  1. Expand the file browser tree under projects like so…
  2. Double click on HelloWorld.java
  3. Navigate till you find something that looks like this

    If this code compiled fine as it is, then you are not using 0.11.5 or later.
  4. To ensure we are indeed not using 0.11.5, change the code from (Sprite.CENTER) to (0.5, 0.5), Netbean’s compiler errors should immediately light up like a christmas tree like how we have here.
  5. Open your favorite file explorer and navigate to your NetBeans files. (eg: c:\NetBeansProjects\Hello World\pulpcore_dependencies\)
  6. Open your favorite file explorer and navigate to where you have extracted the Pulpcore 0.11.5 files, if you don’t have it, obtain it here!
  7. Navgate, in your Pulpcore folder, to the build folder. (eg: C:\pulpcore-0.11.5\build\)
  8. Select all of those JAR files and copy them over to your NetBeans Project folder’s pupcore_dependencies folder, replacing everything.
  9. Go back to NetBeans and click on the ‘Clean and build’ button , you should see compile error gone, replaced by 18 warnings saying that the setAnchor method is deplicated.
  10. At this point, your Pulpcore library is 0.11.5, to remove the warnings, simply go over all the setAnchor methods and replace them with the newer style instead of the older setAnchor method style.

Tags: , , , , , ,

 
0

Using Pulpcore with NetBeans

Posted by samson on May 25, 2010 in PulpCore

After talking about Pulpcore in a previous post and another post on Netbeans IDE, let’s talk about using them together to create our first ‘Hello World’ Pulpcore game.

Please have Pulpcore Libraries Extracted to a location on your local hard drive and Netbeans IDE properly installed before you begin the following.

Navigate to the Netbeans Module for Pulpcore page using this link. Follow the installation instructions by the author of the netbeans Module.

I have duplicated the instructions here for easy access, it is simply 9 Steps.

  1. Download the Netbeans Module (nbm) file.
  2. Open Netbeans
  3. Navigate to “Tools” -> “Plugins”
  4. Click on the “Downloaded” tab.
  5. Click “Add Plugins”.
  6. Find your downloaded nbm file.
  7. Click “Open”.
  8. Click “Install”.
  9. Follow on-screen instructions.

Now you are ready to create the Hello World program. Follow these steps:

  1. Create a New Project
  2. Expand ‘Samples’
  3. Select ‘Java’
  4. Select ‘PulpCore Full Template’
  5. Click Next
  6. Type in ‘Hello World’ where it saids ‘Full’
  7. Copy down the Project Location, this is usually your ‘NetBeansProjects’ folder within your ‘My Documents’ folder.
  8. Click on ‘Finish’
  9. Press ‘Shift+F11′ to ‘Clean and build’

This will actually build your Pulpcore program already and if you click on Netbean’s build-in ‘Run Project’ buttons, it will launch the program. However, I don’t suggest this method for testing your code as the player doesn’t exit properly in Netbeans yet. It would be more ideal to launch the program directly with a browser. So, navigate to the Project Location you copied from Step 7 above and find the NetBeansProject folder. The folder structure should be like this:

‘NetBeansProject’ -> ‘Hello World’ -> ‘build’ -> ‘applet’

Find index.html and launch it using your browser.

If all goes right, you should see something like this.

Tags: , , , , , , , ,

 
0

Pulpcore

Posted by samson on Apr 7, 2010 in PulpCore

Recently I came across an OpenSource project designed to make java more updated with simple 2D game programming. Flash, Silverlight and other secondary tools have long since dominate this client side, interactive coding portion of the web. HTML 5 is still in its infancy, and ultimately painful to implement. Of course, to some, Java is as painful to learn. But for most people who have been taking advantage of Java’s server side power, it would be relatively fun to go back to GUI programming.

Pulpcore is really not a brand new idea. Java’s applet attempts back in the mid ninties was a complete failure, yet super foresight on Sun’s part. Java Applet’s failure is actually due to the limitation in computing power back in the 90s. The Java VM is not light to load and run, yet most computers back then would have been under 100 mhz! That is like a joke compared to today’s cpu speed, measured in GHz instead!

So if there is a way to load the applet code without all the annoying java protection, java can actually be more efficient then flash!

Click here to take a look at Pulpcore’s main page!

Tags: , ,

Copyright © 2012 Pleasant Lifestyle All rights reserved. Theme by Laptop Geek.