Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (714)
Games in Android Showcase (214)
games submitted by our members
Games in WIP (787)
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] 2 3 ... 50
1  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-03-22 19:02:13
What I'm about to do today: heading to downtown SF where I will meet the project lead of a recently formed game-making team and get set up with a workstation.

Plusses:
(1) will be set up with C++ and Unreal, a chance to learn these without having to layout funds myself for compiler/IDE/etc.,
(2) focus will be audio, my main interest,
(3) excellent position from which to achieve some sort of audio director or music director post as the company grows,
(4) the company is pretty solid in its main line of work (related to supporting VR) and has credible resources to risk branching into creating product as opposed to just supporting it.

Minuses:
(1) have to work with C++, not Java (welcome to the "real world"?),
(2) no pay for several months (pay contingent on our demo being accepted by Sony, at which point there will be back pay--I am mentally adding the word "maybe"),
(3) the audio I have to do initially will be primarily related to analyzing sounds (I have done very little of this), with only a bit of sound design and production added on (more my interest). Sound analysis requires things like getting a better grip on DFT and FFT, and it is going to take some serious cramming to "get" this.
(4) No guarantees the company will succeed.

Once again, am putting off work on Hexara.
 Smiley Huh Sad
2  Java Game APIs & Engines / Java 2D / Re: Particle System without libraries? on: 2017-03-20 01:59:36
I don't know any way (or reason) to use JavaFX and Java2D at the same time in the same stage/window. JavaFX has ways to running Swing controls, I think. I really haven't looked closely into this.

If you want an easy intro to JavaFX, this Java-Gaming tutorial could be helpful.

Otherwise, I recall that others have made particle systems and posted code here before, a few years back.

I tried a search on "particle system Java2D" in the local search box. Several threads came up. Maybe StumpyStrust's tutorial will be a help get you what you want.
3  Game Development / Newbie & Debugging Questions / Re: JavaFX audio not working properly? on: 2017-03-20 01:43:13
I've not used AudioClip yet, myself. I'm puzzled about a couple of things.

For starters, the following from the API seems contradictory.
Quote
Playback behavior is fire and forget: once one of the play methods is called the only operable control is stop(). An AudioClip may also be played multiple times simultaneously.

How do you play an AudioClip concurrently if the only operable method after a play is stop()? Maybe the intention was to say each play() is fire and forget?

Secondly, why test for isPlaying() in your code before executing Play()? Do you get an illegal state exception if you call play and it is already playing? There's no illegal state mentioned in the API. Even if the AudioClip does allow concurrent playback, then this test will definitely prevent it. (And if there is silence at the end of the cue, the point where it actually finishes may be beyond the point where the cue goes silent.)

I'd try losing this test before getting into creating a pool of AudioClips. The pool should not be needed if the second line quoted above was written in plain English. (Pools can help if working with javax.audio.sampled.Clip, as they don't allow concurrent playback.)

Another approach is to stop and restart with each play. Then, when the plays are coming faster than the cue can end, the cue will stop without finishing and restart immediately. This can work reasonably well in a lot of circumstances.

In other words:
1  
2  
3  
4  
5  
    public void play()
    {
       this.sound.stop();  // no need to test isPlaying()
       this.sound.play();
    }


Else, if concurrent playback works, seems like simply this should work:
1  
2  
3  
4  
    public void play()
    {
        this.sound.play();
    }


The only hitch here is if the distance between the play calls is only a couple millis, the two playbacks could cause artifacts resulting from comb-filtering.
4  Java Game APIs & Engines / Java 2D / Re: Particle System without libraries? on: 2017-03-19 03:47:28
This is a nice one.

Okay, it isn't Java2D. It's better than Java2D..it's JavaFX.
JavaFX is standard with Java now. It has many advantages over Jav2D/Swing, including being much more aligned with the functional programming paradigm and many new Java features like lambdas.

The code for this program is worth checking out.
5  Game Development / Newbie & Debugging Questions / Re: JMonkeyEngine on: 2017-03-15 08:51:59
I haven't used it myself, but @FrozenShade has done a nice job with SkullStone.
6  Game Development / Newbie & Debugging Questions / Re: Java 2D on: 2017-03-13 02:06:30
You know about our resource page, right?

http://www.java-gaming.org/index.php?action=resources

The two books listed at the top both use Java2D, as do several of the tutorials. They are a little dated, though. I'm wishing for more JavaFX tutorials myself, as JavaFX is much better than Java2D, from what experience I've had with both, so far.
7  Discussions / General Discussions / Re: JavaFX/Eclipse: Java(TM) Platform SE binary not responding on: 2017-03-08 19:02:23
I think what is going on is that the start() method wants to complete before it will display. Having your game loop as a while() construction delays that moment indefinitely.

The easiest way to handle a game loop is to use an AnimationTimer(). You can define and start the timer prior to the end of the start() method. You can check out this Java-Gaming tutorial , Section III "Basic Game Loop" for an example.
8  Java Game APIs & Engines / Java Sound & OpenAL / Re: VOSIM on: 2017-03-06 01:56:25
I added a very simple function--when a button is selected, the "gap" (silent) portion of the constructed wave will be filled with a random number of silent frames up to the number specified by the slider. In other words, each iteration of the wave is a different length. This leads to some interesting distortiony noise.

Example--pretty dang gritty, maybe useful as some sort of interior to a fast vehicle making turns (wheels screeching?) The background grit may overshadow the part where the screech happens. It is intense. It could also be too ugly.

http://adonax.com/audio/pfaudio/vosimnoisesqueals.ogg

I should have taken a screen shot while recording. Here's something pretty close for getting the same sounds.


Either 2 or 3 pulses seems to work. Various squeal pitches give or take around 275-300 microseconds for the pulse widths.
To make the squeal in the recording, I manually took the gap width from around 4000 microseconds to 150-250 or so and back.
Various pulse-amp-dropoff percentages affect the sound but I'm not sure how to describe this--it kind of works (or doesn't work) at any spot.

So, what is needed is a 2d controller, a vector for velocity and a vector for turning angle, so as to control more than one parameter at a time. Use a smaller number of pulses or pulse widths for when the vehicle is at a higher velocity, and a lower setting for the gap width for the higher turning angle.

To get the above code to include randomizing the gap width, line 162 was replaced with the following:
1  
2  
      if (noiseOn) gapFrameCtr = random.nextInt(Math.max(1, curGapFrames));
      else gapFrameCtr = curGapFrames;


Of course, you'd have to initialize "random" and add a public setNoiseOn() method as well.
9  Java Game APIs & Engines / Java Sound & OpenAL / VOSIM on: 2017-03-03 03:06:21
jar: javavosim.jar
example audio file: vosimexample.ogg (Two jars playing at same time, same pitch, different number of pulses, etc.)

I just programmed a basic working VOSIM synthesizer, or at least, the bare minimum. I was interested in giving it a try as it might prove to be a "cheap" ways to get interesting sounds, especially procedural sound effects. Code for the main unit follows. Each read() outputs one frame of stereo audio data as PCM in the range [-1..1]. The GUI is just minimal JavaFX. There remains much to do to make this into something useful: e.g., fixing the "zippering" when changing settings, and implemented various modulation/interpolation pieces as described in the main paper, as well as packaging this in a sensible delivery system of some sort. (The authors later used something called MIDIM which I have yet to investigate.)

What is VOSIM?

From the Journal of the Audio Engineering Society, JUNE 1978, vol. 25, no. 6.:
VOSIM--A New Sound Synthesis System by W. Kaegi and S. Templaars.

Quote
VOSIM (VOice SIMulation) sound synthesis is based on the idea that by employing
repeating tone-burst signals of variable pulse duration and variable delay, a sound output of
high linguistic and musical expressive power can be obtained. Conventional means such as
oscillator and filter banks were therefore entirely dispensed with, basically simpler apparatus
being used instead: two tone-burst generators and a mixer. Starting with these rudiments, the
aim is an optimal representation of the input data and a progressive application of logical
calculus to the sound-synthesis process.

The audio output is derived from iterating through a series of N "pulses" decreasing in amplitude, followed by a short duration of silence. Together, the pulses and silence constitute a single wave, and the frequency is determined by their combined duration. The "pulses" are made from a sine2 function. Instead of calculating the sine and squaring the value during the playback, I create a cursor that progresses through a LUT of 1024 values. (Only 0..Math.PI radians are needed as input to the sin2 function creating the pulse, and all the audio values are positive.)

I'm not great on the details of the rationale, but it seems having this shape as a pulse creates a fair number of overtones, and the width of this pulse (and the factor by which the pulses decrease in amplitude) determine what they call a "formant"--a region in the spectrum where any waves in it are boosted relative to other frequency components.

AFAIK (guessing) a true pulse would be too rich, probably leading to aliasing or some other problem, and a sine "pulse" wouldn't have enough harmonics for the "formant" to matter. Will have to experiment to learn more.

The setting I have as the default in the jar is the first one described in the linked article: the vowel /a/ (or at least, a tone with the first format of this vowel).

If you vary the "gap width" (the article refers to this a M), the frequency will change but the formant area will remain at the same frequency region. If you vary the amplitude dropoff factor (the article refers to this as "b"), you can hear the formant area change in frequency. I'm still figuring this out. Changing the pulse count or width (T) also seems to affect the formant frequency location but alters the main pitch at the same time. So for either to be used as a timbre control, a compensating change has to be made with the silent gap width to maintain the wave's period.

Vowels are said to be recognizable when one can hear the first two formants. This indicates that at least two of these VOSIM generators would be needed to work in tandem to duplicate a vowel. The authors claim musical instruments can be synthesized with three generators (three formants) but I regard this as somewhat dubious. I suspect you might be able to get sounds that "sound like" they have qualities of a particular musical instrument, but nothing that anyone would mistake for the real thing.

Very intriguing is the idea of randomly varying the silent-portion width (M) to create noise with a formant. I haven't experimented with this yet. This could be a computationally cheap way to get some nice percussion effects or noise-based sound effects. But I could also see that if you go to this much trouble, you might ask yourself: Why not just use a software filter that is easier to understand and control?

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  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
import com.adonax.pfaudio.core.PFMixerTrack;
import com.adonax.pfaudio.core.PFPeekable;
import com.adonax.pfaudio.functions.VolumeMap;
import com.adonax.pfaudio.functions.VolumeMapMaker;
import com.adonax.pfaudio.synthParts.SineSquaredTable;

public class VosimPlayer implements PFMixerTrack, PFPeekable
{
   private boolean running;

   @Override
   public boolean isRunning() { return running; }

   @Override
   public void setRunning(boolean running)
   {
      if (running)
      {
         resetVariables();
         this.running = true;
      }
      else
      {
         this.running = false;
      }
   }
   
   private float[] synthBuffer;
   
   private int nPulses, curNPulses;  
   private int gapFrames, curGapFrames;
   private int gapFrameCtr;
   
   private float topPulseAmplitude, curTopPulseAmplitude;
   private float amplitudeDropoff, curAmplitudeDropoff;
   
   private float pulseIncr;
   private float idx;
   private boolean inPulses;
   
   private float masterVolume;
   private VolumeMap volumeMap;
   
   private boolean updateRequired;
   private float[] ampValues;
   private int ampValuesIdx;
   
   public void setNPulses(int nPulses)
   {
      this.nPulses = nPulses;
      updateRequired = true;
   }

   public void setPulseWidth(double pulseWidthMicroseconds)
   {
      // Convert microsecond amount to a pulse width
      // Table is 1024 increments for a single cycle
      // 44100 (fps) comes to 44.1 frames per millisecond.
      pulseIncr = (float)(1024 / (0.0441 * pulseWidthMicroseconds));      
      updateRequired = true;
   }

   public void setMGapWidth(double mGapMicroseconds)
   {
      gapFrames = (int)Math.round(mGapMicroseconds * 0.0441);
      updateRequired = true;
   }
   
   public void setTopPulseAmplitude(double topPulseAmplitude)
   {
      this.topPulseAmplitude = (float)topPulseAmplitude;
      updateRequired = true;
   }
   
   public void setAmplitudeDropoff(double amplitudeDropoff)
   {
      this.amplitudeDropoff = (float)amplitudeDropoff;
      updateRequired = true;
   }
   
   protected volatile float volIncr;
   protected volatile int volTargetSteps;  
   
   public void setMasterVolume(double targetVolume)
   {
      volIncr = (volumeMap.get(targetVolume) - masterVolume) / 1024;
      volTargetSteps = 1024;
   }
   
   public VosimPlayer()
   {
      synthBuffer = new float[2];
      volumeMap = new VolumeMap(VolumeMapMaker.makeX3VolumeMap());
   }
   
   @Override
   public float[] read()
   {
      if (inPulses)
      {
         idx += pulseIncr;
         // set up for next pulse?
         if (idx >= 1024)
         {
            idx -= 1024;
            ampValuesIdx++;
            if (ampValuesIdx >= curNPulses)
            {
               inPulses = false;
               curGapFrames = gapFrames;
               synthBuffer[0] = 0;
               synthBuffer[1] = 0;
               return synthBuffer;
            }
         }    
      }
      else // in silent gap portion
      {
         if (gapFrameCtr-- > 0)
         {
            synthBuffer[0] = 0;
            synthBuffer[1] = 0;
            return synthBuffer;
         }
         else
         {
            resetVariables();
         }
      }  
         
      if (volTargetSteps > 0)
      {
         volTargetSteps--;
         masterVolume += volIncr;
      }
     
      synthBuffer[0] = SineSquaredTable.get(idx) * ampValues[ampValuesIdx];
      synthBuffer[0] *= masterVolume;
      // no panning implemented yet
      synthBuffer[1] = synthBuffer[0];
     
      return synthBuffer;
   }

   private void resetVariables()
   {
      if (updateRequired)
      {
         updateRequired = false;
         curNPulses = nPulses;
         curGapFrames = gapFrames;
         curTopPulseAmplitude = topPulseAmplitude;
         curAmplitudeDropoff = amplitudeDropoff;

         ampValues = new float[curNPulses];
         for (int i = 0; i < curNPulses; i++)
         {
            ampValues[i] = curTopPulseAmplitude *
                  (float)Math.pow(curAmplitudeDropoff, i);
         }
      }
      gapFrameCtr = curGapFrames;
      ampValuesIdx = 0;      
      inPulses = true;
   }

   @Override
   public float[] peek()
   {
      return synthBuffer;
   }
}


I'm curious if anyone has played around with this. I think that it has been implemented on various synth systems that are more involved.

As always, any suggestions on code improvements are welcome.
10  Discussions / Java Gaming Wiki / Re: SF/X Libraries on: 2017-03-01 20:20:24
I thought it worthwhile to start this list when the Yellowstone Park audio library was announced. It is probably worth putting up favorite paid sound effects services, too. Feel free to add more categories as well.
11  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-03-01 01:11:30
Quote
Got a good start on the cover for my next concept album of instrumentals.

Nice concept! It reminds me of a cover I was working on for a project that never got completed. I had a person sleeping on a mattress on the floor with a "thought balloon" of a dream of a person sleeping on a mattress on a floor with a "thought balloon" of a person sleeping on a mattress on a floor, etc. In one of the deeper layers, the sleeper has a single eye open. Derived from an actual multi-layer dream occurrence.

One of these days, maybe.
12  Discussions / Miscellaneous Topics / Re: Programming in schools - opinions? on: 2017-02-26 22:21:42
There is an old adage... those who can, do, and those who can't, teach. Anyone with any serious skill or ability in computer science will be doing computer science, and being paid 3x as much. This leaves a rather small pool of actually talented people altruistically prepared to sacrifice their financial status to teach kids programming.

Cas Smiley

Times change. There are a lot of very talented people unable to get work in their fields these days, as well as people who are dedicated to "giving back" or helping the next generation. There are many good reasons to teach, not just monetary ones.
13  Games Center / WIP games, tools & toy projects / Re: Hexara rewrite with Java 8 & JavaFX on: 2017-02-26 22:12:49
Added a glow animation to the capabilities. Jar is here: testglow.jar

The "glow" is a graphic that is made with a tool I wrote called an OvalBandGradient. This is basically a radial gradient, but where you can specify a uniform center region. Thus, the taper can start at a point that is certain distance from the center, rather than exactly at the center.

I'm animating it with an envelope from the audio envelopes I wrote for my synths. The envelope value is being used to update the ImageView.setOpacity() method.

In this jar, I set the envelope to first "flash" and then do a gradual fade-in and fade-out. The only reason for this is to show the envelope can loop and have multiple stages (6 levels/rates in this case).



I'm not totally convinced. Not sure what is bugging me about it. Will have to play with it some more but am also open to comments.

The lighting is kind of "domelike" at the max levels that I use. I'm wondering if instead of a linear gradient in the oval band I should do something like with the smoke particles and have the slope of the gradient be exponential, e.g., a function of the square of the distance from the top edge rather than just a linear calculation. Also wondering about adding some sort of randomization or disruption to the effect, so it isn't quite so uniform.

I just overlay the glow and change the alpha. Maybe more needs to be done, such as adding another color transform limited directly to the pot, to make this more effective. But I don't plan to actually glow the pots in the game. This is intended more for the Hex and glyph icons.

In any event, this accounts for most of the "presentation" layer at this point. I need to start focusing on the model and control layers now.

As usual, there are interruptions and distractions. This time, the possibility has opened up that I might be able to join a team working on a demo/proposal (bringing sound/audio expertise to the party) for a VR contract for a classic SciFi story (has been done as film and computer game but not 3D/VR). As a result, am putting energy into audio research: reading up on 3D audio issues, investigating some older voice-simulation tech (e.g., VOSIM), designing some speculative "useful" sounds with my FM synth and "box-filter-noise" tools. (Also: rereading the novel, have watched the film/tv-series anew checking out the use of sound, and need to check out the already existing games.)
14  Game Development / Newbie & Debugging Questions / Re: rectangle getBounds() method not available on: 2017-02-26 02:26:27
Does your Asteroid class extend java.awt.Shape? java.awt.Polygon? There are a few other classes that also have a getBounds().

If it does, then your code should be able to find the method .getBounds().

Also, it should find the method if it were explicitly defined within the Asteroid class.

15  Discussions / Miscellaneous Topics / Re: Programming in schools - opinions? on: 2017-02-23 02:42:36
My brother is a programmer and immigrated to Germany, He had met a German national in SF and married her--they decided to make Germany their home. They decided to not expose their daughter to computers until into her teenage years. Instead she spent her extracurricular time learning things like origami, juggling, playing flute, horse-back riding, gymnastics. This year, though, I received a pretty slick Calendar she made herself, presumably with the assistance of a computer graphics program. AFAIK, waiting until she was into the equivalent of Junior High before getting into computers and the Internet has worked out just fine. I don't know if this is common in Germany or not, to limit exposure to computers until after social and intellectual skills have had a chance to develop.

I wouldn't be so strict about the no-computers rule if I were a parent. (They also severely limited TV time.) But in her case, it certainly seems no harm was done by waiting.

I don't know that trying to teach "logic" at an early age is necessarily going to take. "Logical thinking" may have requirements that don't develop right away, kind of like trying to teach a kid about "object permanence" before they've recognized that Peek-a-Boo is a playable game.

Efforts were made to make Mathematics more about abstract principles and higher thinking ("new Math") and success was definitely mixed at best. Since computers are everywhere, a certain amount of computer literacy and ability makes perfect sense. There's nothing like running experiments, trying different teaching strategies and seeing what actually works, as opposed to getting stuck on an ideal or notion of what is best and pushing that on everyone.
16  Games Center / WIP games, tools & toy projects / Re: Hexara rewrite with Java 8 & JavaFX on: 2017-02-16 00:03:27
Some progress made this week to post. Continuing to work on "presentation layer." Worked on the glyphs or beads or whatever these piece tokens are. Below is a set testing some colors. I won't use all the combos, and might tweak them some more. But am trying not to get too nit-picky, as they are in the ball park.

The glyphs themselves are pngs, where the data in them is being used as a stencil. They were inspired by some religious and mystical symbols as well as scientific symbols and icons. I have this notion that each corresponds to a part of life--and the puzzle is to get all of them to fit together.

The colors and shapes are procedurally made. I took a Photoshop tutorial on how to make "gems" and tried to implement it in Java, putting in things like edge darkening, a top-down whitening (Y-axis), and an "inner glow" (made from an oval-band-gradient tool I made). Was able to come up with some significant improvements on the code I originally wrote. For one thing, I only load the "glyphs" once now instead of every time a new bead is made. For another, making the oval-band and the edge-darkening cutout for the hex, I realized that it was possible to take advantage of horizontal and vertical symmetry, and only calculate 1/4 of the area values.

Also, added to the "Pavilion", including animated incense/smoke pots. Can be seen in the latest in-progress jar on the first post. But here is a graphic.

Was pleased to get what were previously rectangular supporting beams to be round columns. I don't know why that defied me originally. Then again, I've already forgotten how I did it. Would have to read the code to see how the shading and angles of the contact points (roof, floor) were done.
The smoke is a simple particle system. The particles are 40x40, ranging from 1 to 0 over distance = 20. I originally was using a simple linear interpolation, where the value from 1 to 0 was directly proportional to the distance. These values are used as the alpha track on the smoke color that fills the rectangle. But it looks better (I think) when squaring the values. This makes the taper fade better at the transparent end. Again, figured out I could use quadrilateral symmetry and only calculate 1/4th of the rectangle.  Also, the base array (a double[][]) is only made once. The 72 or so (haven't entirely settled on the count yet) progressive images make use of ImageView, and scale the base array, by giving each a gradually diminishing overall alpha and by compressing the early particles on the x-axis and widening them progressively on the X-axis for the later stage particles. The "smoke-genies" have some real time controls for how much they wobble and how high they go. It is possible to introduce a leftward or rightward "wind". I plan to make the smoke pots get more "active" as the user gets closer to solving the puzzle.

A lot of little touches that really have nothing to do with the puzzle mechanic itself, I know. But my idea is that the puzzle-game is as much about the setting, creating an appealing/peaceful/mysterious place that also supports mental concentration.

I have a bit more to do on the presentation basics: the panels and the hex grid. Then move on to working on the "model" layer, and "controller" layer. There remains implementing some glow sequences, as well.

[EDIT: Not sure if there are limits on the number of posts I can put in a row, and this is a minor update. Managed to finish some work on the "presentation layer" : the hex grid and the panels/scrolls. The blank forms are shown below. In the puzzle game, the icons will populate these structures. I also finished working on a glow-animation. That might be worth an example--will post in a bit.]

17  Game Development / Newbie & Debugging Questions / Re: External class error on: 2017-02-15 05:37:15
OK, I see the init (line 57). Not clear to me when Slick calls Init (I don't know slick very well, haven't used it in a long time), but it seems to me that the root of your question is elsewhere.

Is there a particular reason you want to create MyClass instead of just having card2 be an Image?

If your goal is to create a "wrapper" class for Image, following are two approaches. The problem I am seeing is that your original MyClass combines the two approaches in a way that isn't working.

1) MyClass 'contains' an Image.

In this case, do not Extend Image. Just hold a copy of the Image and provide a means for populating MyClass with the desired Image (either hardcode in constructor, or pass an argument in the constructor or a set() method) and a draw method that calls the draw method of the image.

For example:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
public class MyClass
{
   Image cardImage;

   public MyClass() throws SlickException
   {  
      cardImage = new Image("img/card.png");
   }

   // alternative constructor for allowing different images to be specified
   public MyClass(String imgAddr) throws SlickException
   {  
      cardImage = new Image(imgAddr);
   }

   public void draw(int x, int y)
   {
      cardImage.draw(x, y);  // I'm guessing this is the Slick syntax for an image draw method.
   }

   // Additional code that provides functionality that is not part of slick.Image

}


2) MyClass extends Image.

In this case, you will want super(cardImage); in the MyClass constructor. As for drawing, if you don't override the draw method of Image, you can call it directly on MyClass.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
public class MyClass extends Image
{

   public MyClass() throws SlickException
   {
      super("img/card.png");
   }

   // alternate constructor, allowing you to specify different cards
   public MyClass(String imgAddr) throws SlickException
   {
       super(imgAddr);  
   }

   // Additional code that provides functionality that is not part of slick.Image

}



18  Game Development / Newbie & Debugging Questions / Re: External class error on: 2017-02-13 03:13:06
Did you instantiate card2? I don't see this happening.

The error message refers to an NPE on line 47, which is why I am asking about the card2 variable.
19  Discussions / General Discussions / Re: Steam Greenlight to be replaced with Steam Direct on: 2017-02-12 02:02:17
I read and commented on the article on GamaSutra.

Taking the stated goal at face value (to improve quality of submitted games), it seems to me it would be good to get some data on the distribution of how many games sell in a fixed period (say, three or four months--time enough for comments to affect sales) and what the comment rating average is and how it correlates to sales.

IF there is some sort of correlation, poorly rated games selling poorly, then they could make the deposit that corresponds to that magic number of games just beyond where the majority of poorly rated games peter out. Maybe it is 100 units?

Take that 100 and multiply it by the selling price of the game. Then, a $1 game would require a $100 deposit and a $50 game would require a $5000 deposit. These figures just happen to correspond to the range of deposits they are discussing. And I suspect there is a general correlation of game price with the resources of the team making the game and their ability to cover the deposit.

Some games are made with a minimum of creativity or effort, e.g., quick or easy variations on an existing mechanic requiring some surface graphics or programming changes. If there is a risk/reward ratio that can inhibit people that post things with the idea "nothing to lose" then maybe that would help fulfill the goal of reducing the massive number of games being entered.

I am not in a position to advance more than a couple hundred dollars at this point for an entry. I'm thinking about Hexara as being perhaps my first effort going to Steam. It is going to appeal to a subset (puzzle game players) and as I have no previous entries or track record, I don't expect to sell a whole lot of units. Putting up more than a couple hundred dollars would be a considerable strain and risk. I will probably go to other venues rather than try to sell Hexara at Steam.

Anyway, these were my first reactions. I'm not sure if the intended consequences would play out as hoped.
20  Discussions / Miscellaneous Topics / Re: Saving, loading—oh no! Semi-tutorial? on: 2017-02-09 03:02:28
When I think about implementing saving and loading, I am also including things like figuring out how to set and update a default file folder. Is it so obvious how to do this? I would include this aspect in a tutorial. The short answer is that this can be provided via util.Properties, but I probably overthought it and got a little complicated with coding the default to be updated whenever a new file folder is used. Also, tutorial would include how to set up a MenuBar correctly with a save/load and import/export. Making space for a MenuBar on a game screen (if you use one) can be annoying. Also, little things like tracking high scores or other user properties for different users might also require management and all this is separate from storing the state of a game.

As for storing game state, for the simple stuff I am doing, XML is working. I went through a bit of a quandary before deciding what forms to use for incoming and outgoing. I got scared off of using Serialization, in part because of a nightmare story from a friend working on a contract on a Java project with faulty Serialization that was crashing the program, and not wanting to maintain or upgrade "older version" save files. (At least with XML, you can always inspect the contents easily, even if you can't load the files.) But from what princec says, a lot of the fears about Serialization are overstated, and it actually works fine.
21  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-02-09 02:45:50
I finished and submitted a web article. It's about the physics of the oboe, a sort of intro level thing, discussing the basics. If it gets posted, it will be on a site called HyperPhysics. I was invited to submit something when I pointed out a few corrections, a couple months ago, to statements on their oboe page. Couldn't resist the opportunity, but writing sure is difficult! It is especially so when your knowledge is more geared to working with the ideas, not knowing who came up with what and when, and how this theory is different from that, and providing citations for all assertions. I hope it turns out to be interesting and useful to at least a few people, and not just a glorified "book report."

Am going to get back to working on Hexara, now, and hopefully this time won't allow myself to get derailed with any other projects.
22  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-02-03 20:42:52
I was working on saving and loading for my game—it turns out I’m not capable of such a simple thing. Here is absolute proof that years of experience doesn’t help you in your dragon-slayer-kill-them-now-epic-stuff quest to ultimate game development mastery! Pointing

I know what you mean. (I think.) It was a significant chore figuring out how save/load settings for the simple sound apps I've been working on. I'm happy to share what I figured out if you start a new thread on this question.
23  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-02-03 20:38:34
Thanks everyone!  Smiley  Smiley  Smiley
@philfrei great work not dying so far!
Seriously. Knock on wood.
24  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-02-03 07:46:37
Turned 60. Shocked
25  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-02-02 01:17:59

Maybe I should have said "nice song" since that is what you called your new musical piece. I tend to think of songs as having singing. I just meant "by the way" for the btw.
26  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-02-01 23:33:58
..whups..
27  Discussions / Miscellaneous Topics / Re: Retrieve random point inside regions of Perlin noise? on: 2017-02-01 19:11:30
I'm not sure if I understand the scenario.

Perlin returns [-1..1], and you wish for noise values > 0.2 to be of a certain special type.
A variable number of contiguous tiles generated this way, forming blobs or islands.
On each island, there should be one "special" tile, which I will call the X tile.
Given the goal of "infinite world" it would be good to be able to identify the X tile procedure based upon the region itself, rather than maintaining some sort of list.

It occurs to me that some of the islands will be quite large, and some will be as small as a single tile. I'm thinking you will want a minimum number of tiles to be fulfilled before you include the X tile, e.g., there must be at least 10 tiles in the island if there is going to also be an X tile.

One could work with the geometry of the shape itself: using a floodfill algorithm to determine the complete extent of the island when you come across it. Then apply a hash function to the shape.

I like the idea of a hash giving 13 possible outcomes. With 13, one could have a "clock" of 12 regions and a central area. Then, place the X tile in the center of the hash-derived sector. Or, if one wants more variety, give the hash more possibilities, and break the island into corresponding sectors.

What would be a good hash? I don't know. Maybe use the number of tiles in the island, but also add in the number of corners or the side lengths, and then do a mod division? How divide the varied island shapes into sectors? I'd have to think about that, as well. The main requirement is that it is a function of the shape that is found.
28  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-02-01 08:10:56
I’ve been here before. It feels good to recognize almost everybody here with the exception of nobody recognizing me! Appreciation given to anyone who can figure out who I really am. Cool

My guesses are as follows:
97% confidence: Icecore (clues: Swedish connection, lots of emoticons, Icecore has not posted since Nov or so)
2% confidence: Huh
1% confidence: Notch impersonating Icecore.

Quote
Do any of you produce music?
Yes. But lately I've gotten more interested in using Java to generate music.
Nice cue, btw.
29  Games Center / WIP games, tools & toy projects / Re: RainThunder on: 2017-01-31 22:43:13
Quote
Would there be any possibility of you bundling up just the important classes into a jar? I’ll make sure to put you in my game’s credits!

Sure. A mention would be great! We can also go back and let the recordists at FreeSound.org know as well. There is no fee--these are free--but the recordists like to hear when something has been used in an app. I've got links to the original files.

Actually, you can try running the jar as is, if you link it into your project. The main "excess" is the GUI class which is pretty lightweight and can just be ignored, probably.

I was noticing the other night that if I have two or three sound-playing jars open at the same time, this one starts experiencing dropouts. It runs fine, otherwise, and has low cpu usage afaik. But for sure, test it before making it a go for your game. I have been planning to investigate as to what the bottleneck might be but haven't had a chance to follow through, yet. If it is happening in your game, please let me know and maybe we can look into it further.

Also--I can probably hone it down if you want to lose either the wind or rain parts or really do need to get rid of the GUI. The animation timer isn't needed for the thunder, just the wind/rain.

Below is the "SoundHandler.java" class that is used to control the app. Are you able figure out how to use the jar via the public methods here? I apologize for some laziness in the coding that might cause confusion, e.g., should have renamed updateVolume() to updateParameter() since it was expanded to do more than just set volumes.

So, make an instance of SoundHandler, and call soundHandler.start() to get the audio engine rolling. Then use the other start/stops to turn things on/off, and updateVolume, using the enum of parameters, for the aspect you wish to control. The parameters updates are set to respond to normals (0..1) for the ranges.

Be sure and include the stop() method when shutting down, or else the thread pool executor in EventSchedulingThreadPool will keep running.

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  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
package com.adonax.weather;

import java.io.IOException;
import java.io.InputStream;

import javax.sound.sampled.UnsupportedAudioFileException;

import com.adonax.pfaudio.cliptools.SuperSlicer;
import com.adonax.pfaudio.core.CoreMixer;
import com.adonax.pfaudio.core.JavaWrapper;
import com.adonax.pfaudio.events.EventSchedulingThreadPool;
import com.adonax.pfaudio.io.PFClipData;

import converter.OggVorbisToPCMFloats;
import javafx.animation.AnimationTimer;

public class SoundHandler {
   private CoreMixer mixer;
   private JavaWrapper jw;
     
   private SuperSlicer windSlicer, rainSlicer;
   private float baseWindVol, baseRainVol;
   private float turbulence;
   
   private ThunderAmbience thunder;
   
   public enum Attribute { WIND_VOLUME, RAIN_VOLUME, TURBULENCE, THUNDER_VOLUME, THUNDER_INTENSITY,
      THUNDER_FIXED_PAUSE, THUNDER_RANDOM_PAUSE};
   
   public SoundHandler() throws UnsupportedAudioFileException, IOException
   {
      mixer = new CoreMixer();
      jw = new JavaWrapper(mixer);  
      new EventSchedulingThreadPool(10);
     
      float[] pcmFloats;
      PFClipData clipData;
      InputStream inputStream = null;

      // * * * * * * * *
      //   Forest Wind in Trees
      // * * * * * * * *
      inputStream = this.getClass().getResourceAsStream(
            "../wind/audio/25945__inchadney__owl__WIND_IN_TREES.ogg");
     
      if (inputStream == null) System.out.println("inputStream not found");
     
     
      pcmFloats = OggVorbisToPCMFloats.makePCMFloats(inputStream, 141_324);
      clipData = new PFClipData("wind in trees ogg", pcmFloats);
      windSlicer = new SuperSlicer(clipData, 44100 / 2, 1024 * 8);
     
      mixer.addTrack(windSlicer);
     
      // rain
      inputStream = this.getClass().getResourceAsStream(
            "../wind/audio/244053__lennyboy__thunder_rainclip.ogg");
     
      if (inputStream == null) System.out.println("inputStream not found");
     
     
      pcmFloats = OggVorbisToPCMFloats.makePCMFloats(inputStream, 93_904);
      clipData = new PFClipData("rain ogg", pcmFloats);
      rainSlicer = new SuperSlicer(clipData, 44100 / 2, 1024 * 4);
     
      mixer.addTrack(rainSlicer);
     
      // thunder
      thunder = new ThunderAmbience();
      mixer.addTrack(thunder);
     
      LFPeriodicNoise wave = new LFPeriodicNoise(30);
     
      AnimationTimer timer = new AnimationTimer()
      {
         final int TUBE_LEN = 24; // 60 = 1 second delay
         float[] delayTube = new float[TUBE_LEN];
         int iWrite, iRead;
         
         void updateDelayTube()
         {
            iWrite++;
            iRead++;
            if (iWrite >= TUBE_LEN) iWrite = 0;
            if (iRead >= TUBE_LEN) iRead = 0;
         }
         
         @Override
         public void handle(long arg0)
         {
            wave.setPeriod((int)((1 - turbulence) * 60) + 30 );
   
            float flt = wave.tick() * (turbulence/3);
            delayTube[iWrite] = flt;
            rainSlicer.setVolume( baseRainVol * (1 + delayTube[iRead]) );
            windSlicer.setVolume( baseWindVol * (1 + flt/2) );
           
            updateDelayTube();
         }

      };
      timer.start();
   }
   
   // *************************
   //    INTERFACE METHODS
   // *************************
   
   public void start()
   {            
      jw.start(null);
   }  
   
   public void stop()
   {
      jw.stop();
      EventSchedulingThreadPool.shutdown();
   }
   
   // Inputs should be normalized [0, 1]
   public void updateVolume(Attribute attribute, float value)
   {
      switch(attribute)
      {
      case WIND_VOLUME:
         baseWindVol = value / 8;
         
         break;

      case RAIN_VOLUME:
         baseRainVol = value / 6;
         
         break;

      case TURBULENCE:
         turbulence = value;
         break;
         
      case THUNDER_INTENSITY:
         thunder.setIntensity(value);
         break;
     
      case THUNDER_VOLUME:
         thunder.setMasterVolume(value);
         break;

      case THUNDER_FIXED_PAUSE:
         thunder.setFixedPausePart(value);
         break;
      case THUNDER_RANDOM_PAUSE:
         thunder.setRandomPausePart(value);
         break;

      default:
         break;
         
      }
   }  
   
   public void startWind()
   {
      windSlicer.play(0, 0);
   }
   
   public void stopWind()
   {
      windSlicer.stop();
   }
   
   public void startRain()
   {
      rainSlicer.play(0, 0);
   }
   
   public void stopRain()
   {
      rainSlicer.stop();
   }
   
   public void startThunder()
   {
      thunder.start();
   }
   
   public void stopThunder()
   {
      thunder.stop();
   }
}
30  Discussions / General Discussions / Re: How do you Guys manage it? on: 2017-01-27 06:27:44
I mostly leverage things like perlin textures, particle generation effects with maybe a little pixel art. Understanding perspective and anti-aliasing can lead to a surprising amount. Also learning a bit about visual composition. There's a fair bit you can do with basic shapes.

Haven't managed to snag a artist as a collaborator yet. Am hoping that finishing Hexara will add to my credibility on that front.
Pages: [1] 2 3 ... 50
 
CopyableCougar4 (92 views)
2017-03-24 15:39:42

theagentd (76 views)
2017-03-24 15:32:08

Rule (137 views)
2017-03-19 12:43:22

Rule (124 views)
2017-03-19 12:42:17

Rule (129 views)
2017-03-19 12:36:21

theagentd (142 views)
2017-03-16 05:07:07

theagentd (140 views)
2017-03-15 22:37:06

theagentd (123 views)
2017-03-15 22:32:18

theagentd (117 views)
2017-03-15 22:31:11

ral0r2 (153 views)
2017-03-03 11:52:41
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!