Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

356 Neutral

About Aphton

  • Rank
  1. Aphton

    Total Begginer needs lot of advice

        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!
  2. Aphton

    Efficient click detection design

    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.
  3. Aphton

    2D Line Intersection Math

    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^22.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 = dThe 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.
  4. Aphton

    Is O(0) equal to O(1) ?

    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..
  5. Aphton

    This place used to be so fun...

    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
  6. A simple brute-force optimization that came to mind when reading the title was: ( 1,2,3, 4,5,6, 7,8,9 )   For each cell, you can perform 3 checks: Horizontal (H), Vertical (V) and Diagonal (D(D1, D2)) But not all checks are needed for each cell, so lets see: Cell 1: H, V, D1 Cell 2: V Cell 3: V, D2 Cell 4: H Cell 5: - Cell 6: - Cell 7: H Cell 8: - Cell 9: - In case its not clear: Cell 2: H is not needed because its covered by Cell1-H and D is simply not possible Cell 5: H is covered by Cell4-H, Diagonals are covered by Cell1-D1 and Cell3-D2 and V is covered by Cell2-V   So this leaves you with 3x H, 3x V and 2x D checks ~ 8x Checks in total, which is much less then 36x Checks Ofc the other solutions are much more elegant (referring to the one suggested at #5)   Edit: Oh and ofc, the traversal itself could look like this: // Horizontal for (int i = 0; i < 3; i++)   ... field[(pos.x + i) % 3, pos.y] ... // Vertical for (int i = 0; i < 3; i++)   ... field[pos.x, (pos.y + i) % 3] ... // Diag 1 for (int i = 0; i < 3; i++)   ... field[(pos.x + i) % 3, (pos.y + i) % 3] ... // Diag 2 for (int i = 0; i < 3; i++)   ... field[(pos.x - i) % 3, (pos.y + i) % 3] ... Im not sure about whether C++ % (mod) handles negative numbers mathematically correctly..
  7. Aphton

    Other uses for matrices in games?

    Sobel-Operator (Image Processing - Edge Detection) Gaussian Elemination
  8. Aphton

    What gets you motivated to code?

    For me, its sci-fi movies ^_^
  9. Aphton

    How to get good fast?

    There is one thing I havent read here yet: Its not only practice and study but most of it is the will to become better! You have to actually want to become better. There is one parallel I can think of to make it more clear: Your whole (school-) life you have been learning and practising "writing" - such as grammar/spelling/different types of text/... Yet not everyone (including you), who does this, is a (good) writer.. The same applies to programming & programmers. There are many types of em: Some like the beauty in it, some just do it because they have to and want to get the job done, even though sloppily... I think the best way to learn anything is to do it autodidacticly. If you let anyone else (teacher?!) shove knowledge down your throat without really being interested, the results will be just the same as how you learnt to write! Try to not lose your interest. Also, stop distracting yourself with such petty worries. Just start learning and practising ^^ To me it almost seems like procrastination xD   Oh btw, to your original question at how to actually get better in a fast and effective way: Well, it just boils down to practising and learning, steadily! And trying out new stuff. You can buy a book or two and get the basics down.   You should tackle some projects / ideas you think you "might" be able to do. There should still be stuff thats new to you that you have to learn about as you go along. If you repeat this, you will gain knowledge, little by little, over time. It will become invaluable experience!
  10. Aphton

    data compression

    "abcabcabc" --> "3|abc"   Time component: it took some cpu cycles to compress it Space component: it requires less space after compression   But you didnt move information from one dimension to another. You rather changed information in the same domain - you densed it up, in a way. There are different methods for compressing, all of which are very interesting to read up on. You shouldnt think in such a roundabout way, keep it simple (and stupid).
  11. Aphton

    A simple question on mathematics

    Damn formatting =/
  12. How about running perlin noise on (src: wikipedia - sphere) ?
  13. Aphton

    How to create minimap? (sdl/opengl)

    How about this~ void Game::drawTiles(bool forMiniMap) Depending on the parameter, you either draw a blue dot or the actual building
  14. Aphton

    How to create minimap? (sdl/opengl)

    Creating a minimap isnt difficult. Its actually really simple. Forget about what I wrote 2 posts before - you dont need to calculate the data. Just let opengl do it.   Try this:   drawTiles();   glTranslatef(miniMapX, miniMapY, 0);   glScalef(miniMapWidth / scr_Width, miniMapHeight / scr_Height, 1);   drawTiles();
  15. Aphton

    How to create minimap? (sdl/opengl)

    Then show some code pls. I cant foresee what you've already implemented and what you are lacking or what the problem precisely is.. =/
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!