Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
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  Game Development / Newbie & Debugging Questions / Re: How to correctly load a state? on: 2013-06-01 01:13:27
From the looks of it, you are using Slick2D's StateBasedGame approach. If that's the case, the BasicGameState class has two classes:

enter(GameContainer gc, StateBasedGame sbg) throws SlickException
leave(GameContainer gc, StateBasedGame sbg) throws SlickException

that can optionally be overwritten. As the names suggest, enter runs when a state is transitioned into, and leave runs when exiting the state.

I did
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
public void enter(GameContainer gc, StateBasedGame sbg) throws SlickException {
     
      // Images
      map = new Image("resources/Maps/chinatown.png");
      tileManager = new TileManager(map);
      tileManager.addSolidTile(0, 0);

      // Music
      backGroundMusic = new Sound("resources/Music/BGM/eerie.wav");
      backGroundMusic.loop();
      // HUD BLOCK START
      hudGUI = new HUD();

      healthGUI = new Health();
      healthGUI.init(gc);

      inventoryGUI = new Inventory();
      inventoryGUI.init(gc);
      // HUD BLOCK END

      mainPlayer.getWeapon().init(gc);
      magnum = new Magnum(null);
      magnum.init(gc);
      assault = new LE9AR(null);
      assault.init(gc);
     
   }


and it works!

Only plays the Play's music and the heartbeat sound once you go ingame!

Thanks a lot man Smiley
2  Game Development / Newbie & Debugging Questions / Re: How to correctly load a state? on: 2013-05-31 02:03:49
Oh awesome! Thanks, I'll be sure to reply with my results Smiley
3  Game Development / Newbie & Debugging Questions / Re: How to correctly load a state? on: 2013-05-30 17:35:00
There is no "enter()" method nor is there a "leave()" method.

Unless you're referring to enter() as the init() method.

If so, it is in that method.
4  Game Development / Newbie & Debugging Questions / How to correctly load a state? [SOLVED] on: 2013-05-30 04:12:20
So game progress has been going quite nicely:

<a href="http://www.youtube.com/v/LzLgQsTy0V0?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/LzLgQsTy0V0?version=3&amp;hl=en_US&amp;start=</a>

But I've noticed something -- the actual game's backgroundmusic and the heartbeat sound plays in the menu state.

So I've tried to make all the stuff for the actual game (such as the backgroundmusic and the heartbeat) init only if the game is in the play(actual game) state (which is 2).

Play.java:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
if(sbg.getCurrentStateID() == 2){
         
         // Images
         map = new Image("resources/Images/Backgrounds/backGround_two.png");

         // Music
         backGroundMusic = new Sound("resources/Music/BGM/eerie.wav");
         backGroundMusic.loop();
         // HUD BLOCK START
         hudGUI = new HUD();

         healthGUI = new Health();
         healthGUI.init(gc);

         inventoryGUI = new Inventory();
         inventoryGUI.init(gc);
         // HUD BLOCK END

         mainPlayer.getWeapon().init(gc);
         
      }


But that doesn't work.

So I've made a breakpoint in the Menu's update method, and a breakpoint for that if statement in the play class -- debugged -- the play class' if statement is met first
and THEN the update method is met.

Quite strange.

Here's how the "main game" (not the "actual game state", which is Play.java, sorry if all these names are confusing :S) class is setup:

Game.java:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
public void initStatesList(GameContainer container) throws SlickException {

      // 0
      ResourcesState rs = new ResourcesState();
      states.add(rs);
      addState(rs);

      // 1
      Menu menu = new Menu();
      states.add(menu);
      addState(menu);
     
      // 2
      Play play = new Play();
      states.add(play);
      addState(play);
     
      // 3
      Credit credits = new Credit();
      states.add(credits);
      addState(credits);
     
   }


Any suggestions?
5  Game Development / Newbie & Debugging Questions / Re: How to properly make a runnable jar/exec? on: 2013-05-26 19:19:46
Haha sorry guys, but I found the problem and it was the stupidest problem ever.

One of our guys that quit a while ago made a deferredResourceLoader or w/e, and he had a dedicated jar for the resources so that the method could work, but most of us weren't really fond of that system so we decided to go with the basic way to load in images/sounds
1  
super.weaponCharacter = new Image("resources/Sprites/WeaponSprites/LE901/LE901_sprite_use.png");

but whenever I tried to jarsplice, it said there were duplicates, so I unknowingly deleted the resources that we ACTUALLY needed -- which caused the problem.

But yeah, now it works Cheesy

Thanks for all the help Smiley
6  Game Development / Newbie & Debugging Questions / Re: How to properly make a runnable jar/exec? on: 2013-05-26 18:51:08
Thanks a lot dude!

So apparently it can't find my resources :\


These are the contents of the .jar file:


I think it may have been how I jarspliced it.

Anyone have any suggestions as to how I should do it?
7  Game Development / Newbie & Debugging Questions / Re: How to properly make a runnable jar/exec? on: 2013-05-26 18:13:18
'java' is not recognized as an internal or external command, operable program or batch file.
8  Game Development / Newbie & Debugging Questions / Re: How to properly make a runnable jar/exec? on: 2013-05-26 14:50:48
How exactly should I get to the directory? (something to do with dir I'm guessing?)
I'm not quite familiar with cmd :S
9  Game Development / Newbie & Debugging Questions / How to properly make a runnable jar/exec? [Solved] on: 2013-05-26 14:39:14
My current process was to export the java project as a jar file from eclipse:
(Said that there were some compile warnings)
Then I used Jarsplice:
Added all the necessary Jars -
Added all the natives -
Added the main class and made a fat jar from all of that...

The problem is that it goes to the login screen fine, but when I click login or play offline, it goes to the loading screen window, but abruptly closes.

I have no clue what the problem is :S

(Works fine from eclipse: <a href="http://www.youtube.com/v/yIS7NsAtWxo?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/yIS7NsAtWxo?version=3&amp;hl=en_US&amp;start=</a>
10  Game Development / Newbie & Debugging Questions / Re: Making a bullet, inventory + weapon system for a top down shooter? on: 2013-05-23 21:37:57
Ok so, I've been wanting to make a runnable jar and/or an executable of the game so far -- so how exactly should I go about doing that?

I've tried exporting the java project (in eclipse) as a runnable jar and then packaging required libraries into the generated JAR but the jar doesn't load the actual game (Launches the login screen and once I click play, it closes the login screen and doesn't do anything else. Yet the javaw.exe is still running in my processes)

We also have an ant script to build a resources.jar, but I'm guessing when I try to run the jar, it's not properly accessing the resource files.

Any suggestions?

[EDIT]

Also, how exactly would I get state the game is currently in?
I tried doing StateBasedGame.getCurrentStateID(); but it gave me a "cannot make static reference to a non-static method" :S
11  Game Development / Newbie & Debugging Questions / Re: Making a bullet, inventory + weapon system for a top down shooter? on: 2013-05-21 16:27:06
Here's another update!
<a href="http://www.youtube.com/v/BjhqQyTxPJY?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/BjhqQyTxPJY?version=3&amp;hl=en_US&amp;start=</a>

Update:
Hitbox calculation method for the player's sprite has been created

And more progress on the inventory/weaponTemplate classes

[EDIT]
The reason why the hitbox is bigger than the player's actual image, is because we had to make the image's center right over the gun so the bullet will shoot out nicely.
Otherwise, I haven't a clue how we would give the player a perfectly cropped sprite, whilst having nice bullet direction.
12  Game Development / Newbie & Debugging Questions / Re: Making a bullet, inventory + weapon system for a top down shooter? on: 2013-05-20 21:23:58
I actually noticed that mistake right after I posted the code haha, don't worry it's all been fixed.

And thanks for the tip, appropriate methods would be using getters and setters, correct?
13  Game Development / Newbie & Debugging Questions / Re: Making a bullet, inventory + weapon system for a top down shooter? on: 2013-05-20 18:26:15
Alrighty, and yep I've made an inventory class (that's how the inventory image works right now)
But I forgot to mention the code snippets from said class:

Snippet_1
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public class Inventory implements KeyListener, MouseListener{
   
   private Image inventoryImage;
   
   private boolean inventOpen = false;
   
   public static float inventoryGUIX = 0;
   public static float inventoryGUIY = 0;
   
   Play play;
   Player mainPlayer;


Snippet_2
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
public void update(GameContainer gc, int delta) throws SlickException {
     
      try {
      } catch (Exception e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
      }
      Input input = gc.getInput();
     
      if(inventOpen == false)
      {
         if (input.isKeyPressed(Input.KEY_E))
         {
            inventOpen = true;
            System.out.println("inventory is now open");
         }
      }
      if(inventOpen == true)
      {
         if (input.isKeyPressed(Input.KEY_E))
         {
            inventOpen = false;
            System.out.println("inventory is now closed");
         }
      }
     
      mainPlayer.update(gc, delta);
     
   }


So my friend and I have decided to just start with the Halo inventory idea, having at least 3 weapons that can be swapped out by using the top-row keys and then once we have that down we can change it later on to fit our initial idea. Why exactly we've decided to do this is because the Alpha phase for this project is due in nine days, and we're really time restricted due to other school projects. (In short the thick of this game is for a computer science project, but after it's handed I'm planning on making it a full-fledged game ;P)

I'll keep posting updates Smiley
14  Game Development / Newbie & Debugging Questions / Re: Making a bullet, inventory + weapon system for a top down shooter? on: 2013-05-20 15:11:41
Thanks for all the info guys!

@Quew8
This is our Inventory in-game so far:
Sadly, it's just an image that pops up when you press E. (Toggleable)

So let me explain how it's supposed to work, the main row at the bottom is the hot bar, and all the other rows surrounding the player are for carrying any item/weapon.
And it's supposed to function like Minecraft's inventory where you can drag stuff and what not.

But for now, my friend told me to start off simple and make it so it works like a First Person Shooter's inventory (Array of 5, top-row number keys access indexes 0 to 4)

So, I understand that concept, and I've been following this game's code for the weapon-manager (https://www.dropbox.com/s/7p2jazq587h5ecx/Enigma.7z)

Here's a snippet of code from the gunManager class and abstractWeapon class (basically a template for a weapon Object, so each weapon Object will extend from this class) I've been making:

- abstractWeapon snippet_1
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
boolean bulletFired = false;
   boolean triggerPulled = false;
   
   public Timer fireRate = new Timer(0100);
   
   private ShootType shootType;
   //Shoot code block
   
   Sound singleFire;
   Sound autoFire;
   Sound reloadFull;
   Sound reloadEmpty;
   
   public static double magSize;
   public static double currentMagSize;
   public static double currentRemainingAmmo;
   public static double ammoCarryLimit;
   public static double damage;
   public static double recoil;
   public static double maxRecoil;
   
   double spawnX;
   double spawnY;
   
   Timer spawnRate;


- abstractWeapon snippet_2
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
public static double getMagSize() {
      return magSize;
   }
   public static double getCurrentMagSize() {
      return damage;
   }
   public static double getCurrentRemainingAmmo() {
      return currentRemainingAmmo;
   }
   public static double getAmmoCarryLimit() {
      return ammoCarryLimit;
   }
   public static double getDamage() {
      return damage;
   }
   public static double getRecoil() {
      return recoil;
   }
   public static double getMaxRecoil() {
      return maxRecoil;
   }
   public static double getRecoilReduction() {
      return recoilReduction;
   }


- gunManager snippet_1 (code has been ripped from Enigma, so it's more so a reference than a straight copy from the game and it hasn't been optimized to fit our game's design pattern yet)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
public double getCurrentRemainingAmmo() {
            if (this.currentWeapon.equals("Pistol"))
               return Pistol.getCurrentRemainingAmmo();
            if (this.currentWeapon.equals("ShotGun"))
               return ShotGun.getCurrentRemainingAmmo();
            if (this.currentWeapon.equals("LE9AR"))
               return LE9AR.getCurrentRemainingAmmo();
            if (this.currentWeapon.equals("MP5"))
               return MP5.getCurrentRemainingAmmo();
            if (this.currentWeapon.equals("Barrett")) {
               return Barrett.getCurrentRemainingAmmo();
            }
            return 0;
         }
         public double getMagSize() {
            if (this.currentWeapon.equals("Pistol"))
               return Pistol.getMagSize();
            if (this.currentWeapon.equals("ShotGun"))
               return ShotGun.getMagSize();
            if (this.currentWeapon.equals("LE9AR"))
               return LE9AR.getMagSize();
            if (this.currentWeapon.equals("MP5"))
               return MP5.getMagSize();
            if (this.currentWeapon.equals("Barrett")) {
               return Barrett.getMagSize();
            }
            return 0;
         }
         public double getCurrentMagSize() {
            if (this.currentWeapon.equals("Pistol"))
               return Pistol.getCurrentMagSize();
            if (this.currentWeapon.equals("ShotGun"))
               return ShotGun.getCurrentMagSize();
            if (this.currentWeapon.equals("LE9AR"))
               return LE9AR.getCurrentMagSize();
            if (this.currentWeapon.equals("MP5"))
               return MP5.getCurrentMagSize();
            if (this.currentWeapon.equals("Barrett")) {
               return Barrett.getCurrentMagSize();
            }
            return 0;
         }
         public double getGunRecoilReduction() {
            if (this.currentWeapon.equals("Pistol"))
               return Pistol.getRecoilReduction();
            if (this.currentWeapon.equals("ShotGun"))
               return ShotGun.getRecoilReduction();
            if (this.currentWeapon.equals("LE9AR"))
               return LE9AR.getRecoilReduction();
            if (this.currentWeapon.equals("MP5"))
               return MP5.getRecoilReduction();
            if (this.currentWeapon.equals("Barrett")) {
               return Barrett.getRecoilReduction();
            }
            return 0.0D;
         }


So, would you guys suggest that I should start on our initial idea of the inventory (basically your idea of an RPG styled inventory, quew8), or should I start off slow with a Halo/FPS type inventory and then once I get that working -- change it so it fits the initial idea?

And I'll be sure to check out the source code for that game, dime26.
15  Game Development / Newbie & Debugging Questions / Making a bullet, inventory + weapon system for a top down shooter[Kinda solved?] on: 2013-05-20 06:27:40
Hey guys, I've been working on a 2D top-down shooter for about 4 months now with a couple of friends. I've recently been working on the GUI (finished implementing Slick's spritesheet system -- showcase is the health meter) and now I'm onto making the placeholder bullet (which is just a yellow line, haha) an actual "bullet" which has damage and velocity and what not. Which means making weapon Objects -- which leads into making an Inventory system. But I've been having some trouble with wrapping my head around certain concepts such as making an Array within the inventory class to contain the weapon Objects which will then set player sprite and assign the correct fields such as magSize, damage, ammoCarryLimit and what not.

Some help would be appreciated.  Smiley

<a href="http://www.youtube.com/v/hBwL6cX7EaE?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/hBwL6cX7EaE?version=3&amp;hl=en_US&amp;start=</a>
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.

toopeicgaming1999 (32 views)
2014-11-26 15:22:04

toopeicgaming1999 (28 views)
2014-11-26 15:20:36

toopeicgaming1999 (7 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (25 views)
2014-11-25 11:26:43

Gibbo3771 (23 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (75 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!