Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (499)
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 ... 69
1  Game Development / Newbie & Debugging Questions / Re: New vector from known angle on: 2014-04-17 10:51:30
What the actual ...?
Normal vectors and dot product? Come on.

Don't fight math. It will help. Especially vector-math is a very valuable tool for games. Inverting the axis is just a shortcut in this special case. Next time you need to calculate your balls movement (nice wording Wink) in another case, you'll need to learn it anyway or fall back to another shortcut for another special case, and on and on and on...

If you limit your solutions to special cases, you limit your game to special cases and therefor limit your creativity to special cases...
2  Game Development / Newbie & Debugging Questions / Re: Advice on a faster way to check every pixel in an image. on: 2014-04-14 17:39:21
Ah ok, so you randomly need to process sprites from your available sheets and it's not a sheet per level or something?
3  Game Development / Newbie & Debugging Questions / Re: New vector from known angle on: 2014-04-14 16:50:53
Learn a bit of vector math. Especially what normal-vectors are and what a dot-product is. Otherwise you will get stuck again. Other than that, google for "2d vector math primer" and "2d vector reflection".
4  Game Development / Newbie & Debugging Questions / Re: Advice on a faster way to check every pixel in an image. on: 2014-04-10 18:15:35
good if it works for you now, but you for sure made a mistake somewhere, because a 1024x512 pixel image is peanuts... Also loading one bigger file is waaaaaaay faster than 300 small properties files - creating pixel-perfect maps for 512 sprites from a single sheet should be doable in millis, not in seconds...
5  Game Development / Newbie & Debugging Questions / Re: Advice on a faster way to check every pixel in an image. on: 2014-04-09 16:01:11
Sadly though, I realized the major issue isnt coming from getColor, it's coming from where getColor has to get it's data. I was pulling the source image from a very large spritesheet and the problem is when .getColor (or any of your methods) are used it has to grab that value off a huge 1024x512 spritesheet, and there in lies the slowdown. I wasn't realizing that even though I am only looking at a 32x32 image I pulled from the sheet, when it has to calculate color values it has to load up the entire sheet into memory. Thus, the major slowdown. Problem with that is, even your guy's methods of snagging the byte array still has similar issues because of that. So your methods are a lot faster, but not fast enough!

Just make sure, you load the image only once at startup and always use the same instance and you should be fine...
6  Discussions / Miscellaneous Topics / Re: C++ standard library is really lacking - good or bad? on: 2014-03-02 23:33:14
I imagine Java is used for much of the front end code in a company. C++ for the powerful back end.
Erm... no Smiley

If you really want to go the C++ route, make sure you fully understand and see the implications of its object model. Especially regarding virtual functions,  virtual destructors,  when and why you need them and how pass by value works for objects.

Also keep in mind that C++ code might look correct,  compiles and even runs,  but could be still be very wrong...
7  Discussions / Miscellaneous Topics / Re: C++ standard library is really lacking - good or bad? on: 2014-02-27 17:48:24
IMO the only low level part of C++ is just C.

Other than that C++ requires you to very much think about what possibly could go wrong beforehand, because with C++ it will go wrong in the end and you will have a hard time to debug it.

Granted, this opinion is based on legacy experience, but I doubt it has changed too much...
8  Games Center / WIP games, tools & toy projects / Re: Synthclipse - GLSL demo development environment based on Eclipse IDE. on: 2014-02-20 09:54:30
You could use java. Smiley  I don't see any reason to use a dynamically typed language, but I don't know what your vision for scripting is.

+1 for java or simply loading class-files and providing a api-jar, so everybody could use any language that compiles to jvm bytecode.
9  Discussions / Miscellaneous Topics / Re: I present to you: the BS-LC ratio! on: 2014-01-24 13:45:07
hmm.  I do the latter,  BUT I contribute... So what am I?   Roll Eyes
10  Discussions / General Discussions / Re: Did you ever cut corners to solve a problem? on: 2013-12-12 12:58:13
edited to fit the usual day job environment:

Most of the time i write some hacky prototypes to try out some new ideas.
After a while it gets really dirty (and unfortunately works), then my boss comes around and releases the solution into production.
11  Game Development / Game Mechanics / Re: 3D perspective correct texture mapping on: 2013-11-21 19:51:37
Quote from: Wikipedia link=http://en.wikipedia.org/wiki/UV_Mapping
The letters "U" and "V" denote the axes of the 2D texture[note 1] because "X", "Y" and "Z" are already used to denote the axes of the 3D object in model space.


Source: Texture Mapping Mania
12  Game Development / Newbie & Debugging Questions / Re: Debugging, i'm doing it wrong? on: 2013-11-21 19:43:23
the problem with anything is that there always might be something that may not work sometimes...  Tongue

My answer was a bit coarse.

I just wanted to emphasis that trying to find a bug using a debugger first usually helps in the majority of cases. Depending on the nature of the problem, you sometimes need to log debug output, put in asserts, use conditional breakpoints, create isolated testcases, draw color markers in textures etc.
13  Game Development / Newbie & Debugging Questions / Re: Debugging, i'm doing it wrong? on: 2013-11-21 14:01:48
1. USE THE DEBUGGER
2. USE THE DEBUGGER
3. USE THE DEBUGGER

but seriously.... USE THE DEBUGGER Wink

In all IDEs I know, using the debugger means:

- click in the column between your code and the line numbers to create a breakpoint at an interesting place
- start your program by clicking on the debug button instead of the run button
- your program will halt at the breakpoint, marking that line
- you get a panel with all variables and their values at the bottom

thats it. no need to hold you back. once you've found out about other possibilities like setting values of variables on-the-fly and even hot-exchanging code during your debug session, you'll ask yourself why oh why you ever even bothered writing System.out.println to debug something...
14  Games Center / WIP games, tools & toy projects / Re: 3D Game Engine From Scratch on: 2013-11-21 13:50:52
Oh, matrices suck...
http://www.sjbaker.org/steve/omniv/matrices_can_be_your_friends.html
15  Java Game APIs & Engines / OpenGL Development / Re: Learning LWJGL/JOGL to C++ with OpenGL on: 2013-11-13 14:24:36
Go with LWJGL.  If you use static imports with the GL classes,  your OpenGL code almost looks identical to the C/C++ counterpart.
16  Game Development / Shared Code / Re: 2D normal maps on: 2013-11-03 12:01:35
hmm, would it? I thought of passing the rotated lightsource as vertex attribute. compute it per bone and pass the same for every attached vertex, but you may also rotate it in the vertex shader when you pass the bone matrix. of course this requires that you can pass additional vertex attributes per batched image...
17  Game Development / Shared Code / Re: 2D normal maps on: 2013-11-03 10:28:23
cant you just rotate the lightsource per bone instead to "simulate" the effect you'll get from rotating the normals?  
18  Game Development / Performance Tuning / Re: Concurency in 3d engine. on: 2013-10-18 21:30:31
One frame is 16 miliseconds with 60 fps. Thats really a small amount. So the tearing can remain at most for 16fps. It's almost impossible to see.
I see such things and are really annoyed by them.  Other than that it is only difficult to spot if it happens once in a while,  but as soon as the update thread and the render thread each take more than 50 percent of the frame time,  its probable that it happens every frame!

also if you use locks to solve latency problems, youll effectively synchronize your engine into single threaded performance - also youll hate to debug it.  but as you said,  time will tell  Tongue
19  Game Development / Performance Tuning / Re: Concurency in 3d engine. on: 2013-10-18 15:00:46
actually you might reconsider your opinion on copying renderstates,  because not having a frame completely updated befor drawing results in annoying glitches. your argument that it is only milliseconds does not hold,  because the glitch is at least timeboxed to the frame time. especially in more demanding scenes youll get the 3d equivalent to screen tearing,  but extended to all kinds of attributes - from color to lighting to textures to geometry. and since it can happen that youll have completely different glitches in subsequent frames youll end up with a very poor visual quality.  you need at least something like double buffering for your data.  to reduce data copying you could journal your changes to one buffer and apply the same changes to the second buffer before applying the changes for the next frame.
20  Game Development / Performance Tuning / Re: Does this cause lack of Performance? on: 2013-10-12 16:33:46
should be.  but more importantly it does not create redundant temporary string objects that cause unwanted garbage collector runs. Also see: http://www.odi.ch/prog/design/newbies.php#3
21  Game Development / Performance Tuning / Re: Does this cause lack of Performance? on: 2013-10-12 10:37:43
afaik primitives are autoboxed to be able to call toString on them.  Jeremys answer is best.
22  Game Development / Newbie & Debugging Questions / Re: Saving game data with performance in mind on: 2013-10-11 21:04:51
for the ease of it,  I would try to load/save json through xstream. also try out roquens advice to use compression by wrapping the input and output streams with inflater or gzip streams.  chances are that network/filesystem bandwidth is more limiting than cpu
23  Game Development / Newbie & Debugging Questions / Re: [LWJGL] Use 2 images to create shadows on: 2013-10-10 09:27:00
to answer the OPs initial question, google: FBO render to texture opengl
24  Game Development / Game Mechanics / Re: The 0,1 & 2 conundrum! on: 2013-10-09 22:12:34
you need to xor the incoming edge with 3 beforehand:
1  
2  
3  
x^=3;
op1=x&1;
op2=x&2;


but i dont know, if the ^= translates to two bytecode instructions eating up the savings in op1 and op2...
25  Discussions / Business and Project Discussions / Re: "Chunk Engine" - Upcoming Voxel-Based 3D Sandbox Game Engine on: 2013-10-09 21:07:41
Your site shows:
Error establishing a database connection

How will you compare to the likes of Voxelfarm or Atomontage?
26  Discussions / Miscellaneous Topics / Re: ISS for "Hacking" and Strange Depression... on: 2013-10-08 09:59:18
@depression:
Do sports
( or sex  Wink )
No really, you need to do something body related, so you're moving your focus away from your thoughts towards physical  self-awareness. Coding (alone) does not help. Force yourself to socializing may also not work, because you need some kind of openess to get something out of it.
27  Discussions / General Discussions / Re: Is the WIP Section supposed to be used as some sort of development blog? on: 2013-10-07 09:46:18
If you spell it correctly, my bots will detect your posts about me (...)
Shocked Oh my... err... this is satire, isn't it? Roll Eyes
28  Games Center / WIP games, tools & toy projects / Re: SF Citybuilder- Buildings/Concept Art on: 2013-10-03 11:15:04
http://www.opengl.org/wiki/Texture%5FCombiners
29  Game Development / Newbie & Debugging Questions / Re: is it possible to manipulate with BufferedReader and BufferedWriter on: 2013-09-30 13:36:21
what you are trying ro achieve is an inplace edit of a file, which is not possible. you first need to read all lines into memory and replace the values while writing the lines back to disk.
30  Game Development / Newbie & Debugging Questions / Re: Better HashMap keys on: 2013-09-30 10:13:19
Normally I have something like. String key = x + "." + y + "." + z; to make sure every object have it's own key.

Actually I would call it good enough, if it doesn't create a problem for you. You may use a StringBuilder to reduce created temporary Strings when doing String concatenation with +
1  
2  
3  
StringBuilder keyBuilder=new StringBuilder();
keyBuilder.append(x).append('.').append(y).append('.').append(z);
String key=keyBuilder.toString();


If you are sure you are using the StringBuilder from the same thread only, then you can even cache and reuse it when calling setLength(0) before:
1  
2  
3  
4  
5  
static final StringBuilder keyBuilder=new StringBuilder();
(...)
keyBuilder.setLength(0);
keyBuilder.append(x).append('.').append(y).append('.').append(z);
String key=keyBuilder.toString();


1  
2  
int locationKey = x << y << z;
int recoloredSpriteKey = img.hashCode() << color.hashCode();


Using primitives as keys is a bad idea, because it will lead to a lot of autoboxing while using the hashmap (the java buildin Map implemtations need Objects as keys, so they will convert ints to Integers and back as needed, causing a lot of short lived objects and therefore garbage collection runs)

Other than that, the << operator shifts the left argument bitwise by the value of the right argument wrapping around, so what you listed above probably won't work, since e.g 64 shifted by 40 would result in the same key like 128 shifted by 39 etc.

So if you want to use this approachm you would need to go for something like
1  
2  
int locationKey = x*MAXIMUM_Y + y*MAXIMUM_Z + z;
int recoloredSpriteKey = img.someId * (256^3) + color.r*(256^2) + color.g*256 + color.b;


As you can see, your img-ids are limited to 256 values now and if you want to get the alpha value into the key, you are screwed anyway (or need to switch to long).

Now here comes, why lukasz1985 don't get your question. You didn't explain the use-case for which you need this key and the hashmap. If you want them for managing your objects, then you will probably be better of by just using names to identify them, because using the coordinates would mean the keys will constantly change when you move your object around the screen. If you don't need the keys for fast retrieval, then there is no point in storing the objects in a HashMap at all...

If you really need to and you want to avoid String keys, then a custom key object like Grunnt posted above would do the trick.

EDIT: And actually overriding the built in Object.hashCode() is a very bad idea - that solution will require that the elements stored is HashSet for example will have to immutable. Actually it's really evil idea....

Maybe this statement is out of context, but overriding the built in Object.hashCode() method (along with the equals() method) is exactly what you need to do when creating custom keys...

DO NOT MAKE UP YOUR OWN.  TOSSING FUNCTIONS OF PRIME NUMBERS TOGETHER WILL SUCK.

Actually I would think it doesn't matter at all, because the amount of objects will be so small in the end that using an array and a brute-force search would be good enough anyway Wink
Pages: [1] 2 3 ... 69
 

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 (30 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

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