Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
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  Game Development / Game Play & Game Design / Re: RPG Style Weapons + Upgrades + Player Stat Upgrades on: 2012-02-08 05:21:26
I don't think changing a config file to add a new weapon really counts as "modding" IMO Tongue But I do see your point.  Things like NPC (written) dialogue, texture filepaths and other sorts might also belong outside of the code.
2  Game Development / Game Play & Game Design / Re: RPG Style Weapons + Upgrades + Player Stat Upgrades on: 2012-02-08 05:01:15
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public class AutomaticRangedWeapon{
    public static enum AutoWpnType{
        M16, P90
    }

    public AutomaticRangedWeapon(Sprite owner, AutoWpnType type){
        super(owner);
        switch(AutoWpnType)
            case M16:
                this.damage = 3;
                this.accuracy = 10;
                //etc...
...


First of all, enums can have fields and constructors, so if you used them to store the stats, you can store them on the enum itself.  However, you probably want to avoid this approach, because all instances of enums are staticly defined (which is largely the point of enums), so you would have to recompile your app to add a new weapon.  What you're going to want eventually is to read in some kind of config, like xml or json or .ini format, that builds a map of weapon definitions.


Personally I'd prefer keeping it out of config files to prevent users from adding their own weapon definitions, especially for a 'campaign mode' style single player.
3  Game Development / Game Play & Game Design / Re: RPG Style Weapons + Upgrades + Player Stat Upgrades on: 2012-02-07 19:17:14
I think he meant that subclasses of RangedWeapon, like LongBow, CrossBow, Sling, etc aren't useful subclasses.  The behaviors of ranged and melee are different enough that they might deserve to be subclasses of Weapon, but individual cases of them aren't really sufficient.

That brings us back to the "gun with a bayonet" problem though, and the answer is pretty simple: it's two weapons.  The identity of a single object shouldn't be confused with the possibly multiple instances that may constitute its behavior.   Similarly a robe with pouches could be armor and a bag.  Rather than trying to fake multiple inheritance, you just accept that one item may actually be a composite of several objects.  

This has implications for where you put unrelated properties like "sale value" and "durability" for example.  The answer there may be you either create a CompositeItem for such chimeras, or you treat Weapon, Armor, and Bag as behaviors attached to Items, not subclasses of Item.  I prefer the behavior angle, but there's probably no single right answer there, it's mostly a matter of what you're most comfortable with and what tradeoffs you're willing to make.

  


So I think what you might be getting at with the data part of things (though I am rather ignoring your confusing Robe example), is that instead of :

1  
2  
3  
4  
5  
6  
7  
8  
public class M16 extends AutomaticRangedWeapon{
    public M16(Sprite owner){
        super(owner);
        this.damage = 3;
        this.accuracy = 10;
        // etc...
   }
}


Something like this might be more appropriate:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
public class AutomaticRangedWeapon{
    public static enum AutoWpnType{
        M16, P90
    }

    public AutomaticRangedWeapon(Sprite owner, AutoWpnType type){
        super(owner);
        switch(AutoWpnType)
            case M16:
                this.damage = 3;
                this.accuracy = 10;
                //etc...
               break;
            case P90:
                this.damage = 2;
                this.accuracy = 15;
                //etc...
               break;
    }
}


[EDIT] to clarify, the reason that the Automatic part is specified is that upon use, it may have different attack behavior than a pistol (automatic fire, etc...) or a shotgun (shotgun may generate 8 attacks for spray).
4  Game Development / Newbie & Debugging Questions / Re: 2d Lighting Question. Because there aren't enough of them. on: 2012-02-07 18:09:28
Ok great.  But what about this problem:  With colored lights rendered over a white background (eg. snow) that blending function just takes it straight to white.  Render the black quad first? Huh
Yeah you find the problem. But there is easy fix for that. Just use
1  
glBlendFunc( GL_DST_COLOR,GL_SRC_COLOR);

instead.

You really don't want to render your scene per light. Instead just draw light to accum buffer and blend that over the scene. For that you dont even need any shaders.

Using that blend function makes it look really bad, you can see the edges of the triangle fan of the lights instead of the smooth dropoff you get with a src_alpha blend.
5  Game Development / Newbie & Debugging Questions / Re: 2d Lighting Question. Because there aren't enough of them. on: 2012-02-07 01:04:08
I seem to have found a workaround by, before clearing the alpha buffer, blending a colored 'light' onto the scene in the location (with reduced radius) of the future alpha buffered light.

I am next investigating into this approach: http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/dynamic-2d-soft-shadows-r2032?md=viewrev&rva=1&rvb=1#revisions which seems to take the approach of rendering the light into the alpha buffer FIRST, then for each light, rendering the scene.  The emissive pass at the end could be used to render the whole scene in an "ambient" sense under the darkness as well.
6  Game Development / Newbie & Debugging Questions / Re: 2d Lighting Question. Because there aren't enough of them. on: 2012-02-06 23:14:10
Ok great.  But what about this problem:  With colored lights rendered over a white background (eg. snow) that blending function just takes it straight to white.  Render the black quad first? Huh
7  Game Development / Newbie & Debugging Questions / Re: 2d Lighting Question. Because there aren't enough of them. on: 2012-02-06 22:30:50
This may belong in the LWJGL board, but it's an extension of this thread so... yeah.

I'm working on using LWJGL to render a lightmap on top of the 2d scene (using orthographic projection).  Would it work to render the lightmap to an FBO, explored in this tutorial?: http://lwjgl.org/wiki/index.php?title=Render_to_Texture_with_Frame_Buffer_Objects_%28FBO%29

Sincerely,
Knee-deep-in-OpenGL-and-confused

I have two technique for lights.
Fixed pipeline goes like this:

1. Render scene.
2. Clear alpha channel(use color mask for other channels, clear alpha to ambient)
3. Render Lights with blending, alpha channel as intesity. gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
4. Render fullscreen black quad with blending. gl.glBlendFunc(GL10.GL_ONE, GL10.GL_DST_ALPHA);
5. Render UI.


Shaders + FBO's goes like this.

1. Render scene.
2. Render Lights with blending to small size FBO, use alpha channel as intesity. gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
3. Use gaussian blur to FBO.
4. Render FBO over to scene with custom shader that draw lights where intesity is high and shadow where intesity is low.
5. Render UI.

Both techniques are as fast. Shaders give soft lights/shadows but fixed pipeline work everywhere.


Super n00b question: How do I clear the alpha channel?
8  Game Development / Game Play & Game Design / Re: RPG Style Weapons + Upgrades + Player Stat Upgrades on: 2012-02-06 22:11:06
I just said something like this in a previous thread.  What's the difference between two ranged weapon?  Some data...so you could skip on subclassing RangedWeapon.  What's the difference between a MeleeWeapon and a RangedWepon?  Some data...so you could skip on subclass Weapon.  The point to stop with this kind of thinking is (roughly) when a parent and child require different state data.

In my implementation MeleeWeapons and RangedWeapons hold different sorts of data and override methods in different ways, so the subclassing is relevant.
9  Game Development / Newbie & Debugging Questions / Re: 2d Lighting Question. Because there aren't enough of them. on: 2012-02-06 19:28:01
This may belong in the LWJGL board, but it's an extension of this thread so... yeah.

I'm working on using LWJGL to render a lightmap on top of the 2d scene (using orthographic projection).  Would it work to render the lightmap to an FBO, explored in this tutorial?: http://lwjgl.org/wiki/index.php?title=Render_to_Texture_with_Frame_Buffer_Objects_%28FBO%29

Sincerely,
Knee-deep-in-OpenGL-and-confused


be advised that FBO are pretty advanced, and only available using OpenGL 3.0 and later
if you want a lot of people to be able to play your game, don't use it. Alternatives include VBO and such

So... create a VBO, render the lightmap to that, then render the VBO on top of the scene?
10  Game Development / Newbie & Debugging Questions / Re: 2d Lighting Question. Because there aren't enough of them. on: 2012-02-06 18:00:46
This may belong in the LWJGL board, but it's an extension of this thread so... yeah.

I'm working on using LWJGL to render a lightmap on top of the 2d scene (using orthographic projection).  Would it work to render the lightmap to an FBO, explored in this tutorial?: http://lwjgl.org/wiki/index.php?title=Render_to_Texture_with_Frame_Buffer_Objects_%28FBO%29

Sincerely,
Knee-deep-in-OpenGL-and-confused
11  Game Development / Game Mechanics / Re: Ticks vs. FPS on: 2012-02-06 17:55:11
I found this tutorial really useful for separating the idea of updates/ticks from frames: http://www.java-gaming.org/topics/game-loops/24220/view.html

I'm currently running a variable timestep loop in my implementation (seemed preferable to having a 1 frame latency via fixed timestep interpolation)
12  Game Development / Game Play & Game Design / Re: RPG Style Weapons + Upgrades + Player Stat Upgrades on: 2012-02-06 17:44:11
I think it would be "cleaner" to keep weapons and player skill upgrades clearly separated. I'd not have any player skill related variables in my Weapon class, and instead pass the PlayerSkills/UpgradeClass (whatever you call it xd) to the Weapon each fire()/update().

Right.  The idea is that the Player Skills and Upgrades are 2 separate ideas.  IE:

1  
2  
3  
4  
5  
6  
7  
8  
public void dealDamage(Sprite theOneGettingOwned){
    int dmg = 0;
    dmg += this.damage; //base weapon damage
   dmg *= this.upgrade.getDamageBonus(); //damage bonus from weapon upgrades
   dmg *= this.getOwner().getDamageBonus(this); //retrieve damage bonus from player for this weapon class

    theOneGettingOwned.receiveDamage(dmg);
}
13  Game Development / Newbie & Debugging Questions / Re: Shooting Projectiles? on: 2012-02-06 17:39:20
Thats a lot of unnececary work you're doing there MunchGamer! Also instead of using ArrayLists, use lists! they are much easier to use once they are implemented once youve set them up.
also, what does this line of code do?
1  
 t.threaten(getOwner().getWorld(), 0);

Ive never seen it before. threaten

That's a part of the engine I'm making which sends threats to the world, ie when you fire a gun, the "sound" of you firing alerts nearby enemies to your position.
14  Game Development / Game Play & Game Design / Re: RPG Style Weapons + Upgrades + Player Stat Upgrades on: 2012-02-06 06:00:45
The individual weapons are implemented already ie Beretta9mm extends Pistol, which extends RangedWeapon, so on and so forth back up to Item.  The reason for this architecture is to allow a player to have any sort of item, be it a Pistol or a Potion, in their hot bar, and use it by clicking.

The question, or rather more of a implementation proposal since everyone does things their own way, is that I'm suggesting within the class Weapon:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
public abstract class Weapon extends Item {
   protected double damage;
   protected double knockback;
   protected double speed;   //time (in seconds) for a full attack.
  protected double atkTime;
   
   protected double accuracy; //lower is more accurate
  protected double accuracyModifier;
        // etc.. with other attributes, plus:
       protected WeaponUpgrade upgrade;


And when the player stops in at the upgrade shop / other gameplay contrivance, the WeaponUpgrade is retrieved from the weapon, an attribute of it is modified, ex:

1  
2  
3  
public void setAccuracyBonus(double d){
        this.accuracyBonus += d;
}


and off the player goes, now with a more accurate, reliable weapon. 

When the accuracy (or damage, or knockback, or other attribute) of the weapon then needs to be retrieved, it can be grabbed as some calculation performed on:
1. the weapon's base attribute
2. modifiers provided by specific upgrades to that instance of the weapon
3. the player's global benefits for weapons of that class (ie pistols)

If anything, I guess I'm asking if this seems like a reasonable way to go about doing things, or if there's some glaring oversight I'm making.
15  Game Development / Game Play & Game Design / RPG Style Weapons + Upgrades + Player Stat Upgrades on: 2012-02-06 05:36:42
Hey all,

Developing a big RPG style inventory system.  Currently it's organized with class hierarchy:

Inventory (contains items, hotbar for quickselect, etc)

Item
->Weapon
   ->MeleeWeapon
   ->RangedWeapon
      ->Pistol
      ->Shotgun


etc...

So here's what's on my mind-grapes:

If a weapon can be upgraded (ex. purchase silencer for Beretta 9mm) through purchase of upgrades, and also 'upgraded' through player skill trees (ex. '+10% accuracy with pistols'), I was thinking that it might be best, on creation of the item, to poll the player for their skills and adjust the attributes accordingly and then to have an instance reference of a 'WeaponUpgrade' class which holds the internal (and importantly, specific to that instance of that weapon) upgrades, also adjusting the attributes.

Thoughts on this design implementation?
16  Game Development / Newbie & Debugging Questions / Re: 2d Lighting Question. Because there aren't enough of them. on: 2012-02-05 18:19:43
For Libgdx I have made light library that allow pretty much those effect that you see on that video out of the box.
http://code.google.com/p/box2dlights/

That work even on mobile devices and you dont have fiddle with opengl bits at all.




Was trying to install it, but it seems to not mesh with the most recent libgdx download.  What version of libgdx are you using with it?
17  Game Development / Newbie & Debugging Questions / Re: 2d Lighting Question. Because there aren't enough of them. on: 2012-02-05 17:52:06
For Libgdx I have made light library that allow pretty much those effect that you see on that video out of the box.
http://code.google.com/p/box2dlights/

That work even on mobile devices and you dont have fiddle with opengl bits at all.




Cheesy neat.
18  Game Development / Game Mechanics / Re: Simple AI Programming on: 2012-02-05 08:31:48
in 2d space I've been using Math.atan2() to get the angle (from -pi to pi) between 2 points, then multiply the x value by Math.sin(direction) and the y value by Math.sin(direction).  Works like a charm, also for running away from something just use direction + pi.  Ahhhh polar coordinates.
19  Game Development / Newbie & Debugging Questions / Re: 2d Lighting Question. Because there aren't enough of them. on: 2012-02-05 08:20:50
Oh also, for some reason FSEM in Java is extremely slow with D3D turned on.  With 0 game logic it peaks around 80 fps at 1080p.
20  Game Development / Newbie & Debugging Questions / Re: 2d Lighting Question. Because there aren't enough of them. on: 2012-02-05 07:50:49
I am dissapoint.  I'm really not looking forward to learning OpenGl, it's intimidating...!
21  Game Development / Newbie & Debugging Questions / Re: Shooting Projectiles? on: 2012-02-05 07:48:53
Here is some code for guns that shoot I worked up in the last couple of days:

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  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
public abstract class RangedWeapon extends Weapon {
   protected double maxRange;
   protected int clipSize;
   protected int clip;
   protected double projectileVelocity;
   
   protected double coolDown;   //number of seconds to reduce from maximum to minimum bloom
  protected double heatUp;   //number of bullets to reach maximum bloom
 
   protected double reloadtime;
   protected double reload;
   
   protected double direction;
   
   protected HashMap<Attack, ArrayList<Sprite>> hits;
   
   public RangedWeapon(Sprite owner){
      super(owner);
      hits = new HashMap<Attack, ArrayList<Sprite>>();
      this.clip = 0;
   }

   
   
   
   public double getProjectileVelocity(){
      return projectileVelocity;
   }
   
   @Override
   public void use(double mouseX, double mouseY) {
      if(!(atkTime < speed) && clip != 0){
         atkTime = 0;
         direction = Math.atan2(mouseX - getOwner().getAX(), mouseY - getOwner().getAY());
         attack();
         clip -= 1;
         //Send threat
        t.threaten(getOwner().getWorld(), 0);
         
         accuracyModifier += (accuracy/2)/heatUp;
         if(accuracyModifier > accuracy/2){
            accuracyModifier = accuracy/2;
         }
      } else if(clip == 0 && !(reload < reloadtime)){
         getOwner().requestReload(this);
      }

   }
   
   public void attack(){
      attacks.add(new RangedAttack(getOwner().getAX(), getOwner().getAY(), this, direction + (Math.random()*2 -1)*(accuracy/2 + accuracyModifier + getOwner().getMoveAccuPenalty()*accuracy/2)));
   }
   
   @Override
   public void tick(double d){
      if(reload < reloadtime){
         reload += d;
         if(reload >= reloadtime){
            clip = clipSize;
         }
      }
      if(accuracyModifier > 0){
         accuracyModifier -= (accuracy/2)/coolDown*d;
      } else {
         accuracyModifier = 0;
      }
         
      if(atkTime < speed){
         atkTime += d;
      }
//      System.out.println(attacks.size());
     for(Attack a : attacks){
         ((RangedAttack) a).tick(d);
      }
   
      for(Attack a : attacks){
         CollisionReport cr = getOwner().getWorld().getCollisionReportForAttack(a);
         if(!hits.containsKey(a)){
            hits.put(a, new ArrayList<Sprite>());
         }
         for(Sprite s : cr.getCollidees()){
//            System.out.println(s);
           if(!hits.get(a).contains(s)){
               hits.get(a).add(s);
               s.receiveDamage(damage);
               s.receiveKnockBack(knockback, a.getX1(), a.getY1());
            }
         }
      }
   }

   
   public void removeAttack(RangedAttack a) {
//      System.out.println("removing attack");
     hits.remove(a);
      attacks.remove(a);
   }
   
   
   public void setReload(){
      reload = 0;
   }
   
   @Override
   public void reload(){
      getOwner().requestReload(this);
   }
   
   public Item equip(){
      if(reload < reloadtime){
         reload = 0;
      }
      return this;
   }
}


RangedAttacks essentially hold 2 points (origin and vector) and use Line2d.intersects(Rect2d) to test for collision with enemy hit boxes.  Hope this helps you!
22  Game Development / Newbie & Debugging Questions / 2d Lighting Question. Because there aren't enough of them. on: 2012-02-05 07:23:59
Hello!

I'm having trouble with a lighting problem.  I understand the concept of creating a lightmap, and even have a set of pixel blending functions graciously provided by Dx4 in this post: http://www.java-gaming.org/topics/some-new-blendmodes-add-multiply-overlay-etc/24529/view.html.

I'm currently running my prototype in FSEM with a BufferStrategy, Direct3d turned off by runtime options.  Now, I'm wondering, given the Graphics I've been drawing all my lovely (read: horrifyingly primitive) sprites to, how exactly should I access the pixel data for the blending methods?  Keeping a separate BufferedImage and calling out each pixel is EXTREMELY slow (especially in 1080p).  Even having that BufferedImage and not applying a lightmap to it, then drawing it with g.drawImage(im, blah) is slow.  Is there something I'm missing?

Best,
Munch

[EDIT] the end goal is something akin to this: http://www.youtube.com/watch?v=Xmn6zhDJGLE&feature=fvwp&NR=1 though without the bump mapping.
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 (40 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (203 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!