Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 31 Dec 2010
Offline Last Active Apr 25 2016 03:45 AM

Posts I've Made

In Topic: Total Begginer needs lot of advice

25 April 2016 - 03:42 AM

... but whats your thoughts on going with java? is the language capable of such things and run them smoothly and get a good end result? I dunno, im worried about what ever I learn handling the animation smoothly, (I have no foundations for such concerns but there ya go LOL) is java harder to code games and more to the point games like im looking to do point&click / visual novel....



Ofc. Java is capable of it, e.g. take a look at this


I like your down-to earth approach, you seem to pay respect to learning a programming language and don't take it too lightly.

Reading through your posts, it almost seems like you overanalyze and respect/fear it too much.


The thing with programming languages is - its not like you learn just one language and thats it, its over, you wont take a look at any other language.

Java IS one of the best languages to start with imho.

Once you master the language, which in itself is not that hard, there are just a few concepts you need to understand and learn the grammar of the language, all that is left to do is polish your design and problem solving skills, which is language agnostic.


Once you learn and become fluent in any programming language, it takes little to no time to learn another one. The concepts stay the same. The only thing that changes are miniscule (like grammar - takes one max 1 week to learn and max 3 weeks with a simple project to master).

Then there are few different programming paradigms but they wont concern you any time soon. I'd even say if you embark on a professional route, you will be fine.


Take a look at tiobe index, java is #1- For many years now java has either been #1 or at least top 5. So, in a few years, if you lose interest in gamedev you will have aquired a tool (programming language java) which you can use and earn money with.

Anytime I think of java, all that comes to my mind is that: its an easy language, its clean, its object oriented, its platform independent. Sure, its an interpreted language (instead of native [machine code]) and therefore a bit slower but there is JIT for that.

If you are not working on realtime systems where micro/nano seconds matter, you practically wont have any issues with java. And once you run into issues, you will be at a stage in your development, where you will easily pickup any other language.

Transitioning or picking up C / C++ after java will be very easy. Language wise they differe here and there and some concepts are different but overall, it will be easy, Id say. Well, Im only talking about my experience here.


Java, C++, Python - they rule!

In Topic: Efficient click detection design

19 April 2016 - 10:49 PM

For simple & lightweight GUI, your approach is ok.


More complex GUIs are usually managed hierarchically as in there are containers/views, which clip down recursively and so on.

Ascii drawing to clarify:

|V1     |

|-----+ |

|V2   | |

|-----+ |

|       |


V2 gets clipped by V1 and in a more complex setup, v1 could contain many more sub views and those in turn can contain some too.. You get the point I think.


One optimization that is being done is to check whether (x, y) is in the clipping rect of a node (e.g. ctrl or V1).

If its not, then you can skip recursively checking which it actually hit - with this, you can potentially skip thousands of controls.

Thats usually enough, I have never personally experienced a bottleneck on GUI systems.

In Topic: 2D Line Intersection Math

21 July 2015 - 11:18 PM

1. here

2. Even though there are numerous sources online Ill provide a solution just to refresh my maths.. by thinking about it.. so dont mind me:

you are given the line and the circle equation:
line: y = k * x + d
circle: (x - centerx)^2 + (y - centery)^2 = radius^2
2.1 First you need to determine the coefficients for these functions:
lets say your line vector looks like this: A [0,1] B[10, 10]
The "k" coefficient is the slope so...:
k := (B.y - A.y) / (B.x - A.x)
note care for special cases (vertical line = divide by zero error!)
Once you have k, you can now determine d by using the x and y value of either A or B, inputting them into the line function (because the line goes through both points) and adjusting it so that d is on the one side and the rest on the other:
A.y = k * A.x + dA.y - k * A.x = d
The circle is much easier since you have to do pretty much nothing.

2.2 There are now 3 cases for the line-circle intersection:
1 - the line doesnt intersect with the circle (passant)
2 - the line intersects with the circle exactly 1 time (the line is tangential to the circle; its a "tangent")
3 - the line intersects with the circle exactly 2 times (the line "pierces" through the circle; its a "secant")
What it boils down to is evaluating this:
line = circle (if they intersect, there is an (x,y) pair for which this holds true)
We know "y" from the line equation, so lets use it in the circle equation:

(x - centerx)^2 + (y - centery)^2 = radius^2
= (x - centerx)^2 + (k * x + d - centery)^2 = radius^2
to simplify the next step, lets define:
t := d - centery
= (x - centerx)^2 + (k * x + t)^2 = radius^2
= x^2 - 2*x*centerx + centerx^2 + k^2x^2 + 2*kx*t + t^2 = radius^2
= x^2 - 2*x*centerx + k^2x^2 + 2*k*x*t = radius^2 - t^2 - centerx^2
= (k^2 + 1)x^2 - 2*x*centerx + 2*k*x*t = radius^2 - t^2 - centerx^2
We know k, centerx, t, and radius, so what we have here is basically this ~
x^2 - x + x = some_constant
... a quadratic equations.
The number of solutions to a quadratic equations is the same as for our 3 cases:
0 solutions = no intersection (sqrt of negative number - we are not working with complex numbers here so its "no solution")
1 solution = tangent
2 solutions = secant

The last step is trivial: You have x, you just input it to either equation (i suggest the line equation, since its simpler) and get the y value. Then you have your (x,y) pair - which is the intersection position.

3 This is a bit more tricky. I dont have a proper solution but the first idea that came to my mind was a divide & conquer strategy:
You basically segment and approximate the curve (ground) with k line-segments. Then you do the line-line intersection check. You take the segment-line you intersected with, use its boundaries to repeat the whole process - segmenting and approximating the curve (ground) again and again and the more often you do it, the more accurate the result is going to be.

Edit: For problem 3, I have another divide & conquer strategy if there is nothing below "ground":
- divide your line into two segments. Check whether the center point is below or above ground (by determining the y positions of both line and ground at the center_x position)
-- if its below ground: take the segment that is "higher" in the air
-- if its above ground: take the segment that is "lower" in the air - closer to the ground
--- and repeat the whole process t amount of times
Result = center_x value if center_x was below ground at any iteration.
Again, the higher t is, the more accurate the approximation will be.

In Topic: Is O(0) equal to O(1) ?

10 July 2015 - 11:25 AM

Same formal approach as samoth but with the product rule:

Product rule f € O(g), h € O(i) => f*h € O(g*i)
Lets assume f is O(0) and h is O(1).
Furthermore, lets define j € O(n).

f = h => f * j € O(x), h * j € O(y), x = y
(simply speaking: if f is equal to h, then big-O of product of f with an arbitraty function j is equal to big-O of product of h with same arbitraty function j)

Lets check:

f * j = O(0 * n) = O(0) | x = 0
h * j = O(1 * n) = O(n) | y = n

x != y, therefore f != h
So... O(0) != O(1)

Thats a typical theoretical (university) question - practically speaking, O(0) makes no sense. They just wanna make sure you understood the formal definitions or rather have learnt them by hard and know how to juggle with them to find solutions..

In Topic: This place used to be so fun...

18 March 2015 - 09:51 AM

Funny story.. On another forum I used to frequent daily there was this one post asking ~"how to make -x out of x and vice versa".. The thread grew to more than 10 or so pages and one of the more interesting solutions was a shader doing the calculations (... *-1 >.>) on the gpu. Another was some complicated long formula (with 3-4 integrals i think) which yielded -x Those were good times :D