Show Posts
|
|
Pages: [1] 2 3 ... 25
|
|
1
|
Game Development / Newbie & Debugging Questions / Re: Algorithms for Image Shapes
|
on: 2013-04-18 10:41:38
|
I don't fully understand the question, and may be clueless as to what you are asking, but when you write: "Or, do people generally just use the pixel colors directly to check for overlap?" it gets me wondering, why make colors serve two purposes? Will you be putting constraints on future graphics decisions if the color data is being used for collision checking? A second array, representing each pixel location of the screen is not that large. Fill it with bytes that are pointers to the objects occupying the space, instead of colors. I did this on a kind of loony experiment where I had about 500 threads going, each at its own sleep loop, and all the objects checking against this representation for collisions. It worked. The "interesting" concurrency issues can be avoided by moving all objects in turn rather than having them in independent loops, which should make it even more performant. It is a little cumbersome to set up, but it scales linearly  as you add more objects for collision checking. A crazy idea perhaps, but I'd like to go back to it and explore some more, look for possible optimizations.
|
|
|
|
|
2
|
Game Development / Newbie & Debugging Questions / Re: Rotate player in relation to mouse position
|
on: 2013-04-15 21:43:40
|
|
If you have a process that starts but does not stop, I can think of two general approaches. Either (1) the method stops itself, or (2) something external to the method tells it to stop.
(1) Create a variable that iterates with each increment of the rotation. Test against a maximum value or another condition that lets you know it is time to stop. For example, perhaps you "know" it takes 20 rotating steps to reach the final position--just have a counter test for 20. Or you know the final angle should be N radians. Again, test for N radians with every iteration.
(2) Create a "state" boolean, such as 'isRotating'. Consult this boolean each increment before deciding whether to rotate or not. An external method communicates with the rotating method by setting isRotating to true or false.
The second idea makes sense if you are using something like mousePressed() to start the rotation. If so, perhaps using mouseReleased() is the desired way to stop it? This is possible if mouseReleased() changes the isRotating boolean to false and the rotating method is consulting this boolean every iteration.
BTW, if you do this second method, it helps to make isRotating volatile.
|
|
|
|
|
3
|
Game Development / Newbie & Debugging Questions / Re: Finding the time at which intersection takes place.
|
on: 2013-04-15 21:26:25
|
Doesn't checking collisions multiple times cause slowing in game? Best answer I can think of: try it and see. I am constantly being surprised by what consumes time and what doesn't. How many collisions are there per second? If you have one or two, and are animating at 60fps, that's 58 game loops which are unaffected. A few extra tests won't make much difference. How many nanos or microseconds per test? Also, collision testing is just one of the things that happens in a game cycle, so as a percentage of time consumption, it could be very minor.
|
|
|
|
|
4
|
Game Development / Newbie & Debugging Questions / Re: Finding the time at which intersection takes place.
|
on: 2013-04-15 11:01:47
|
|
There are other folks probably more experienced with this than me, but I will offer a couple ideas and hope that they aren't too impractical. (It is either that or go back to doing my last-minute tax returns.)
(1) If, when you get the collision indication you know the velocity, you could try a binary successive approximation: try half the move--collided or not? try 1/4 move or 3/4 move depending upon the first answer, etc. Continue until the fraction is equal to a move of one pixel.
(2) If, when you get a collision indication, you could go back to the previous point and do a successive sweep, 1 pixel velocity at a time, until you hit. (Also possible to do a backwards moving sweep test, I would think.)
(3) Whether there is a geometrical solution, that would depend on the shapes, I would guess. It would be cool if there was a way to return the intersection of the two shapes and calculate the width at the angle of the impact. I don't know if there is such a thing, though, or if this would be any less computationally intensive than just doing one of the above series of collision tests.
(4) I'm trying to recall what I did for the simple case of bouncing off of a wall...drawing a blank. Maybe it was a matter of taking the destination and placing the object on the symmetric point on the correct side of the wall. Seems like there might be a geometric calculation available from that to find the point of collision, but the odd shapes you have make it trickier.
(5) Ah, found a start of an old game of mine with falling objects of various shapes. I just had the object stop/lose it's momentum at the position before overlap. It would settle down (using gravity) from there. Looks a little funky though. It will be interesting to see if anyone else has a better solution.
The sweep or "binary search" might not be so bad, though. If the speed is only a few pixels per frame, that's only a couple extra collision tests on the occasion of an overlap state arising.
|
|
|
|
|
6
|
Game Development / Game Play & Game Design / Re: Simplex noise, experiments towards procedural generation
|
on: 2013-04-09 23:41:39
|
I've just posted a big revision of the Simplex noise 2D texture editor. http://www.hexara.com/SimplexBuilder.html(Link is also on first post) The interface is a lot better than it was, but there's always room for improvement, and the code is more "functionally" written. I'm hoping it now provides a better foundation for collaboration. The GitHub project name is "SiVi". Is that enough to locate and join in? I am a GitHub newbie. There is a nice long "issues" wish list. But to start, I need to fix the "settings panel" which crashes in the applet form. It allows (when it works) you to specify the size of the graphic and the number of octaves. The tutorial works as a separate window, so the Settings window should be able to do so too. But my specifying "on top" seems to be causing problems. Or maybe it should just be a submenu.
I wonder if the gradient or colorbar editing windows work...dang. Bloody hell.
AccessControlException: access denied ("java.awt.AWTPermission" "setWindowAlwaysOnTop")
Any suggested quick fixes for this? [Edit: made the various submenus modal and took off the "alwaysOnTop" setting, for now.] The tutorial is going to be rewritten. But you CAN page through it and click on the top graphic to bring it into the editor as a template. improvements: Specify size of graphic. Specify number of octaves. Drag & drop color maps (helps if you want to tinker with the mapping, to have copies). Specify three gradient types to be "modulated" by the noise. To recap: the point of the tool is to be able to try out and tinker with Simplex noise settings. Much easier to do it with this interface than by rewriting code. The settings will then be transferable to code (either via provided templates, or via code-generation). Hah! From last post, I said one week, and it took two months. A programmer friend of mine says make an estimate, double it, then go to the next level of units. He was right this time.
|
|
|
|
|
9
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound.
|
on: 2013-04-06 01:06:44
|
My apologies, esp to Cubus! I was extrapolating from what I know about Java's two playback mechanisms, not from direct usage of TinySound. EDIT: I was just taking a refresher look at the api and code, and it seems to me that if you want to stream instead of loading data into memory, use this form: loadMusic(file-or-url, true); loadSound(file-or-url, true); where true is for the boolean he calls "streamFromFile". And...it appears you are already doing so.  OK, I will go away now. Sorry for adding to any confusion.
|
|
|
|
|
10
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound.
|
on: 2013-04-06 00:59:14
|
|
Cubus, I'm wondering if the info you are giving is correct. Usually it is a "Clip" type structure that has the position reset feature, not a streaming structure (e.g. SourceDataLine in java audio terms).
I would like to suggest changing .loadMusic() in your updated example to .streamMusic().
I *think* that loadMusic() functions like a Clip, loading the entire file to memory, and allowing looping and position setting. And streamMusic() functions like a SourceDataLine, allowing streaming without loading any more than a single buffer's worth of sound data from the file at a time.
I could be wrong but it is worth a test, I think.
|
|
|
|
|
13
|
Game Development / Newbie & Debugging Questions / Re: web start persistance
|
on: 2013-04-02 22:10:10
|
Drag. I still don't understand the game you are making. Two web clients communicating via WebStart programs and a server? In real time? I found an example program using persistent store, a single line of text that lets you set the "title" of a little calculator app which reappears with each use of the app. You can get a copy here: http://horstmann.com/corejava.htmlI have the 8th edition. The example program is 10.2 "WebStartCalculator". Code downloads are near the bottom of the web page, under "Further Information". A cookie might be able to hold the amount of info you require, as well.
|
|
|
|
|
14
|
Game Development / Newbie & Debugging Questions / Re: web start persistance
|
on: 2013-04-01 20:50:57
|
I haven't tried this myself. I've only run Applets and gone through the hoop of asking permission for saves & loads. However, I suspect you don't want to be dealing with the PersistenceService. You just want to save/load on the client, without having to deal with permissions, yes? Did you see this page? It compares Applets and WebStarts. http://docs.oracle.com/javase/tutorial/deployment/_riaDecisionGuide.htmlIf I read it correctly, a WebStart should allow you access to the client file system, but will have limited internet access. If you want to have both web access and client access, I don't know that the client access part is possible without using signing or at least without asking permissions, or via bumping up a level in technology to run a multi-client server (which I also have not done yet). Did you see the example program called "Notepad" in the WebStart demos? I ran it and it has a File/Save and File/Load in the menu bar, but these haven't been implemented. In my mind, their existence in the menu bar suggests these capabilities are possible but were just not included. Is the source code posted? (There is a code examples area in the tutorial.) Maybe there are comments in the code which say something about how these would be implemented. Or, try plugging in the standard Swing file service to their code and see if it runs. Or maybe you will get a reply from someone who has actually done this and knows the answer!
|
|
|
|
|
17
|
Game Development / Newbie & Debugging Questions / Re: What have been/are your learning techniques?
|
on: 2013-03-31 08:25:12
|
- Why did you want to start programming? (What was your motivation?)In the blood? My father worked for IBM and programmed the Mormon geneology database in the 1960's. There was a lot of encouragement from him around things like math, probability and games. - Why did you choose to begin with the language you begun with? And if applicable, why are you using the language you are using now?BASIC was what was available in a classroom at the time. But it really didn't inspire me that much. I like Java because it is a language that performs at a high level enough level where I can dabble in sound synthesis, because it is free, and because it makes sense to me as a language. Built-in support for multi-threading seemed to indicate there is still a future for the language. We'll see. - How long ago did you get started? And where are you at now? Got started with Java 3 years ago. I am close to qualifying for a Java Associate--my last practice test was a score of 73. Am pretty good with 2D and sound and getting better with aspects of functional programming and multithreading techniques. The Java Associate test has been a HARD challenge, maybe due to being over-reliant on Eclipse, maybe because I don't tend to "think like that"--am more attuned to patterns than rules of syntax. - What learning methods did you employ personally to help you develop your skills in programming?1. There is too much to learn. Period. So I try to put on blinders and only learn what is directly needed for a specific goal on a game or project I am working on. Hasn't really worked, as I still am having trouble finishing things. (Related: agile programming philosophy--don't put in capabilities into the code until there is a clearly demonstrated need.) 2. Simply reading or observing doesn't work for me. Unless I run test programs and try to break things and find out their tolerances, I will forget 90% of what I read if it pertains to syntax or abstractions. - What advice could you give to other programmers who might be feeling a little lost in what direction to take?I will limit myself to advice for YOU based on the little I've learned reading this thread. And I may be "projecting" like crazy. That said, given that you have lots of ideas rather than a dearth, I'd suggest consider pursuing aspects of programming where brainstorming is a plus--e.g. something with a design element. Also, you have artistic talent and enjoy using it, you have some right-brain skills (just demonstrated!), so it makes sense to me that you might gravitate towards roles that provide a bridge between artists and programmers. In this sense, working on game engines, or game-art tools might be a good fit. But I don't know enough about larger game programming companies to know if there is hiring for such a role or exactly what that would look like. - Is there anything you believe should be a "Rite of Passage" for programmers (such as the need to create hello world, or a snake program, etc etc).I like to make a bouncing ball.  With gravity. Finishing a game is a good rite of passage, probably, especially if the finishing is to the level of marketability. There is a world of difference between something that works and is fun to play personally and something which can be sold. I did this as a Basic programmer and a FORTH programmer back in the 1980's (I split my time between database contract work and musical composition now). But I'm still working to complete my first Java game ("Hexara") and got side-tracked working on a texture generating tool to help with procedural graphics, and another side track is an audio tool (FM synthesis) that is half-way there for use in generating sound cues dynamically. These topics are passion-fueled for me, so I've let the "finish a frigging game already" advice slide. I'm also NOT employed in the game field, yet. But when I do get there, I want it to involve an aspect that I am passionate about, not just ANY game programming job. We've had some comments from folks working IN the game industry that are kind of strapped down, and dabble here with Java games, as independents, in order to keep their creativity alive.
|
|
|
|
|
18
|
Game Development / Newbie & Debugging Questions / Re: getRGB() on an image
|
on: 2013-03-27 02:38:18
|
|
I think Gamerulf is onto the answer. The getRGB() is going to return a value in the default color model. So, chances are the alpha value will be included as well, and I'm not sure of the order, for example, if alpha is first or last. But you should be able to do a bit-shift operation to get just the RGB and lose the A, rather than go to the trouble of instantiating a new color.
What you are doing is an interesting idea, but rarely done. Part of the problem is that now this color is serving two purposes--visual appearance and collision detection. If for any reason you decide you want a different color, or to use the same color for anything else, then you are opening yourself up to collision detection bugs.
However, I think it's an interesting idea to have a second "screen" (memory array) that stores indexes to the object occupying that space (instead of pixels). The second screen can be smaller because you may only need a byte or at worst a short to track all your objects, and because blocks of 4 or 9 or 16 pixels (actually you can pick any shape) may accurately represent positions. (Important, a block of pixels can only hold one object at any time.)
(If you allow a block to hold more than one object, then you effectively are using the "bin" method of collision detection.)
Downside: when you move, you have to update this second screen as well as print your image. But it makes collision detection pretty much a linear rather than an exponentially expanding problem as you add more items to the check.
Anyway, most folks will say this idea is nuts and overkill, especially if you are only dealing with a few dozen objects, in which case brute force collision detection is a simple and adequate solution.
|
|
|
|
|
19
|
Game Development / Newbie & Debugging Questions / Re: translate and animate simultaneously
|
on: 2013-03-27 02:11:48
|
|
For the Zombies -- I'm guessing that you keep restarting loopImage() over and over until "locx = target", after which the routine finally gets a chance to play out.
Probably the same thing with Ninja. And it doesn't move because there is no locx change included outside of the loopImage() as there is with the Zombie.
|
|
|
|
|
20
|
Discussions / General Discussions / Re: Hello!
|
on: 2013-03-25 06:25:28
|
I'm glad I joined up before the current activation form was put in place. I keep hearing stories about it being pretty tough. I got my start here by posting an applet captcha that displayed letters via XOR mode (animated) on a random b&w field--thus invisible via a screen shot. But it was cracked within a matter of hours. Now that you are in, welcome! Lot's of great resources and helpful people here. Looking forward to seeing what you come up with! 
|
|
|
|
|
21
|
Discussions / General Discussions / Re: java book recommendations
|
on: 2013-03-25 06:12:38
|
|
I've been studying for the Java Associate Certification test, using some software by Enthuware. One of the chapters they linked to, for background help with a topic, was "Java in a Nutshell."
I was impressed. I like that it is no frills, no cuteness, no drama, just succinct and well written explanations. It seems like it will make a good reference, too.
And it doesn't weigh 15 pounds and cost 150$ (both numbers are exaggerations) like the two volume "Core Java" by Horstmann, my other recommendation--but books that size just make me want to go back to reading online. It would be nice if someone invented a book spine with detachable segments so you could just take the chapter you are interested in.
|
|
|
|
|
22
|
Java Game APIs & Engines / OpenGL Development / Re: Suggestions for a really nice sun effect in OpenGL/Slick2D?
|
on: 2013-03-23 05:57:54
|
I've been experimenting with Perlin noise (Simplex noise, actually), and came up with these images using a tool that I have in development. I'm having a little trouble getting my 2D output to map to a nice sphere. However, they should animate pretty readily. Perhaps there is a way to blend an animation of something like one of these with another graphic to get something really sweet. (The graphics data is generated and used as a source for a BufferedImage. Nothing else from Java2D was used.)  For this one, it works well if you put a well-aliased black disc in front to make an eclipse-type of effect.   I don't know what this is, just messing with the settings of the tool.  Playing around with the radial gradient setting, it is possible to compress the color transitions to a point that is rounder, but the body of the sun looks kind of flat to me. But it might look nice with the edges animating. Yes, easy to scale to a smaller size.  Well, that was fun!  [EDIT: Simplex noise algorithms can be used for 3D, and animated via a 4th dimension. It has been used to make some outstanding planets, as can be seen in Ken Perlin's slide presentation: http://www.noisemachine.com/talk1/19.html]
|
|
|
|
|
23
|
Java Game APIs & Engines / Java 2D / Re: Rotating images, fast?
|
on: 2013-03-22 07:43:56
|
|
I can only see two solutions. Maybe there is a better one.
a) rotate based on the coordinates of the shadow, draw shadow, then rotate on the coordinates of the turret and draw the turret.
b) work out the trig to compensate for the angle of the rotation and add it to the draw position of the shadow (hurts my head at this late hour, but I know it is solvable). Don't know if it is faster or slower doing a bit of trig compared to a second rotate.
However, none of this matters if you are managing a pair of good sprite sheets for the turret and shadow.
|
|
|
|
|
25
|
Game Development / Newbie & Debugging Questions / Re: Resizing JPanels
|
on: 2013-03-15 20:46:25
|
Thank you!!  So, .revalidate() is called on the component that had its property changed, not the container. I was having trouble finding this method because I was stuck on the notion that the "reformatting" activity centered on the container.
|
|
|
|
|
26
|
Game Development / Newbie & Debugging Questions / Re: Resizing JPanels
|
on: 2013-03-14 23:47:19
|
|
Thanks for the suggestions!
@HeroesGraveDev - I had just gone through a lot of trouble getting my rather elaborate JPanel to use an actual layout rather than null layout, and I really didn't want to "go backwards"! Otherwise, it was a reasonable suggestion, especially for simpler screen layouts.
.reSize(int, int) did work for the JApplet! I found that .reSize(int, int) also works for JFrame, but it is deprecated in favor of .setSize(int, int). So I may end up using .setSize(int, int) for both.
The nice thing is that both take into consideration the new .preferredSize property and do all the messy calculating needed to revise/compensate the other components in the display.
|
|
|
|
|
27
|
Game Development / Newbie & Debugging Questions / Resizing JPanels
|
on: 2013-03-13 21:41:23
|
|
I have a program that can be run as both an application (uses JFrame) and an applet (uses JApplet).
Both display a JPanel that I call TopPanel which has several sub-components and a Border layout. Both display a JMenuBar (attached to the JFrame for the application, and to the JApplet for the applet).
One of the items in the menu bar allows a change of a configuration element and that would ideally include a resizing of the subpanel on TopPanel which hosts that element.
As far as I can tell, removing and adding that subpanel (also a JPanel) doesn't result in a new display, even when the new subpanel has a new preferredSize(). The only way I've figured out to get the display to respond to the changes is to execute a pack() method at the JFrame.
pack(), however, is a method of Window, and JApplet is not a subclass. Is there an equivalent method to pack() that can be used for the applet form of this program?
Is there a better way to get the TopPanel (fills entire JFrame or JApplet) to redisplay?
I'm considering the possibility that there IS a simpler way but that I executed it incorrectly...
Thanks for help!
|
|
|
|
|
28
|
Game Development / Newbie & Debugging Questions / Re: When to start trying?
|
on: 2013-03-11 00:45:11
|
|
"How is that looking?"
Depends how deep you plan to go into Java2D. Seems to me just getting a game loop working is a very important step. I'm not so sure the other graphics APIs always build directly on AWT & Java2D. Some rely on their own native code. Deciding on what graphics to use can be put off for now. (I still haven't decided.)
A game loop is not a game engine. All that a simple game loop requires of graphics is a drawRect(xpos, ypos, width, height) or similar drawOval or drawImage method, and a place to draw (JComponent or JPanel for starters is fine).
But if you want to poke around with other things for a while, I guess that is fine, too. As you are noticing, there are a lot of details to fill in along the way, even with something that "should" be simple like loading an image to display it (and likely would be in a game engine). That's part of why I recommend bouncing a box first.
|
|
|
|
|
29
|
Game Development / Newbie & Debugging Questions / Re: When to start trying?
|
on: 2013-03-10 22:58:15
|
|
Game loop with bouncing ball or box. That is a very simple and useful start, as it gets the most important thing happening: animation via a game loop.
A lot of textbooks on Java don't cover this simple case! But we have some good tutorials here.
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|