Slick Forums

Discuss the Slick 2D Library
It is currently Fri May 24, 2013 6:30 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Eclipse plugin
PostPosted: Wed Jun 30, 2010 3:20 pm 
Offline
Regular
User avatar

Joined: Thu May 21, 2009 10:25 am
Posts: 161
Location: France
Hi all !

When creating a project to use Slick, there are always the same things to do:

- Link the wanted jars to the classpath
- Link the native to lwjgl
- (optional but useful) Create a StateBasedGame and a load resources state

To make all that things in only 3 clicks I created an Eclipse plugin. With it I can transform a standard Java Project into a "Slick project".

What do the plugin ?

- Create needed directory.
- Put lwjgl and slick jars and lwjgl natives into the project + automatically link them to classpath and natives to lwjgl.
- Add Kryo/Twl/Phys2D or sound jars if needed to classpath.
- Generate a small game framework with a statebasedgame, 2 states (resources and ingame) and a resources system with an ant script.

I create a small video (sorry low quality but you can see the interest of such plugin). In this video I create a standard Java project and transform in with 3 click into a Slick project. I also show the small resources framework.

The video: http://www.vin789.fr/wordpress/?page_id=262

So if this plugin or the source code interest someone, feed back here and I will make them available :). I used it with Eclipse 3.6 Helios on Windows XP 32 Bits and Ubuntu 64 bits. There is not a lot of code in the plugin so you can reuse the code to make your own generation code plugin :wink:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2010 3:37 pm 
Offline
Regular
User avatar

Joined: Thu May 07, 2009 5:09 pm
Posts: 143
Location: Okanagan, BC, Canadia
That is *very* handy. That would especially be very handy for new users. I'd be interested in having that plugin and seeing how it was done.

_________________
Linux and free software enthusiast.
Image


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2010 3:53 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1313
Location: Italy
just curious:
* how do you plan to keep synchronized slick+lwjgl releases?
* why not have a new slick project directly?
* where can i download it? :D
* Eclipse Helios works fine?
* your plugin works with Eclipse Galileo ?

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2010 4:15 pm 
Offline
Regular
User avatar

Joined: Thu May 21, 2009 10:25 am
Posts: 161
Location: France
Wow :shock:

That's was quick answers.

Gornova81 wrote:
just curious:
* why not have a new slick project directly?
* Eclipse Helios works fine?
* your plugin works with Eclipse Galileo ?


I did this plugin in my last internship 2 days (because I haven't any work to do... :oops: ). So I do something simple, make a complete slick project would be maybe harder to do, and need more time. Sorry I compiled the plugin for Eclpse 3.6 Helios. You can maybe compile it to make it work with Galileo but I thing than go to Helios is better.

kdnewton wrote:
That is *very* handy. That would especially be very handy for new users. I'd be interested in having that plugin and seeing how it was done.


The plugin and the project source code are here:

http://www.vin789.fr/wordpress/games/plugin_slick.zip

To use the project with Ecplise, you must have the framework associated to plugin development (Help -> install new Feature -> Eclipse Platform SDK and Eclipse Platform, didn't remember well but you must have plugin development environment).

The project is of type: Plug-in Project

Now about the other directory (plugins) it contain the plugin jar and the resources (slick_plugin_resources). Both should be copy into your Eclipse plugins directory and Eclipse should be launched with the -clean command to install the plugin.

Example: C:\Program Files\Eclipse\eclipse.exe -clean

When transform a Java standard project into a Slick project the plugin is looking into the slick_plugin_resources, himself into your plugins directory. So to update lwjgl release or others jar you just need to replace them into the good directory in slick_plugin_resources.

That's also mean that you can add your own jar. The plugin catch all the file in the directory. The same thing for the generated directory, the plugin catch all file in core/states and utils directory, so you can add your own class, they will be added when using the plugin.

Pfiou lot of word :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2010 5:11 pm 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
Very cool.

I find it strange to build resources into a jar to use in your game when developing. What benefits are there from doing that than just keeping your resources folder in the classpath? Maybe when you release the game you'd have your resources in a jar, but not when developing :\

Maven archetypes is also possible.

Or what about adding a new project type in Eclipse, e.g. "Slick Java Project"?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2010 5:22 pm 
Offline
Regular
User avatar

Joined: Thu May 21, 2009 10:25 am
Posts: 161
Location: France
appel wrote:
Very cool.

I find it strange to build resources into a jar to use in your game when developing. What benefits are there from doing that than just keeping your resources folder in the classpath? Maybe when you release the game you'd have your resources in a jar, but not when developing :\

Maven archetypes is also possible.

Or what about adding a new project type in Eclipse, e.g. "Slick Java Project"?


That's for release yes, and WebStart deployment. There is a part that I didn't make in the plugin. A special directory that I used when launching script, the script prepare the game to be used with WebStart (means regrouping jar + manifest + jar signer).

That's my first Eclipse plugin. I still don't know how to create a kind of "Slick Java Project". Maybe I can find how to do that but now, it's not my priority :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 06, 2010 10:02 am 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1313
Location: Italy
I would like to point attention to a really useful piece of code into your project, Timer class!!
I like it, simple and clean :D

Code:


package utils;

/**
* This class represent a timer.
*
* It can be used to wait between two actions.
*
* Use:
*
* Timer t = new Timer(5000);
*
* In update method:
*
* //Don't forget to update the timer t.update(delta); if(t.isTimeComplete()){
* //5 seconds are passed, we can do something //reset the timer or not
* t.resetTime(); }
*
* @author Vincent PIRAULT
*
*/
public class Timer {

   private float eventTime;
   private float deltaStock;
   private int limit;
   private int limitCounter;

   /**
    * A simple timer, would be complete after the event time.
    *
    * @param eventTime
    *            Time in ms before the complete state of the timer.
    */
   public Timer(int eventTime) {
      this.eventTime = eventTime;
   }

   /**
    * A timer with a limit.
    *
    * @param eventTime
    *            Time in ms before the complete state of the timer.
    * @param limit
    *            Number of time the timer could be reset before being totally
    *            complete.
    */
   public Timer(int eventTime, int limit) {
      this(eventTime);
      this.limit = limit;
   }

   /**
    * The classic update method.
    *
    * You must call this method, if not the timer will not be updated.
    *
    * @param delta
    *            the delta parameter.
    */
   public void update(int delta) {
      deltaStock += delta;
      if (deltaStock >= eventTime && !(limit != 0 && limitCounter == limit)) {
         deltaStock = eventTime;
         limitCounter++;
      }
   }

   /**
    * Check if the timer is complete, means the limit timer is complete.
    *
    * A simple timer with no limit is never complete.
    *
    * @return true if the timer is complete, false otherwise.
    */
   public boolean isComplete() {
      return (limitCounter == limit && limit != 0);
   }

   /**
    * Check if the time of the timer is passed.
    *
    * @return true if the timer is passed, false otherwise.
    */
   public boolean isTimeComplete() {
      return deltaStock >= eventTime;
   }

   /**
    * Reset the time of the timer.
    */
   public void resetTime() {
      deltaStock = 0;
   }

   /**
    * CHeck if the timer time is reset.
    *
    * @return true if the time is reset,false otherwise.
    */
   public boolean isTimeReset() {
      return deltaStock == 0;
   }

   /**
    * Reset the time and the limit counter of the timer.
    */
   public void reset() {
      limitCounter = 0;
      resetTime();
   }

   /**
    * Set the counter time of the timer to the same value of the time passed.
    */
   public void setTimeComplete() {
      deltaStock = eventTime;
   }

   /**
    * Get the advancement of the timer before the next time complete.
    *
    * @return the percentage in float ( 0 - 1 )
    */
   public float getPercentage() {
      return deltaStock / eventTime;
   }

}

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group