Nicholas Kong

Members
  • Content count

    943
  • Joined

  • Last visited

Community Reputation

1535 Excellent

About Nicholas Kong

  • Rank
    Advanced Member
  1. Okay so floating point arithmetic in Java is an approximation. Understood, thanks guys. Thanks for the link, Glass_Knife.
  2. Why is System.out.println(1.4-1) producing "0.3999999999999999" as the difference in Java?   In Math, 1.4 - 1 is 0.4.  
  3. I would actually go against reading any book on game programming until you have at least 5 games of different genre under your belt that you wrote on your own. Just because building your own systems with your own creativity is like doing your own homework. Only reading the other books just as supplementals or until you have lived in the trenches in your projects. 
  4. From my experience, I would suggest implementing the load/save system should be the highest priority on the to-do list. This approach makes the code implementation more readable.    I remember implementing the load save feature for my 2D rpg. But that was the last feature I implemented of all the many things I coded for the game. It took me 3-4 days to implement the feature and on top of having duplicated code. 
  5.   so there is no best method then?   I would recommend where it is easy to modify and find the data. This allows you to iterate quickly.
  6.   oh yeah. I never questioned that. But I always have the thought of it. That is a great way to identify duplicate code.   Say, is producing duplicate code off the start a bad habit? I find myself doing it a lot.
  7. From what I can gathered about duplicate code, it is if the list of code that occurs more than once. Okay, based on what context? Is a duplicate code based on the similar appearance of the code?   In the below case, I have a character state animation driven by key press events and enum that hold states or behavior denoted by constants.   The reason is the first and second code are the similar in appearance and in functionality but they used different state and key presses to execute this functionality of the game character.   if(direction == Direction.RIGHT && state == ActionState.RUNNING) { runRightAnim.update();   if(rightReleased) { state = ActionState.IDLE; }   }   if(direction == Direction.LEFT && state == ActionState.RUNNING) { runLeftAnim.update();   if(leftReleased) { state = ActionState.IDLE; } }
  8.   oh Wow. I should try looking into libGDX and using that with Java to publish to iOS. This is a great advice!
  9. Thanks for the link, jbadams!       Won't that overheat or overwork the CPU or reduce the lifespan of a CPU if it processing a lot of data at that level? Or is it that the CPU loves this kind of work and won't do damage to the CPU?       It was programmed in Java-build from the ground up. I learned a lot about building game systems.
  10.   It's a RPG Game: everything of the game(2 map, 2 npcs of map # 1, 9 monsters of map #2, quest and dialogue system, save system, character data and animation files)  is loaded ahead of time and is drawn and executed based on key or mouse commands
  11. [quote name="Nypyren" post="5203316" timestamp="1420918778"] Ignoring instruction fetch bandwidth and cache misses, the speed of instruction execution does not depend on its encoding length.[/quote] What do you mean by encoding length? So what does speed of instruction depend on? Is it based on the algorithm analysis? [quote name="Nypyren" post="5203316" timestamp="1420918778"] Real-time games are typically written to consume 100% of each core they can run on.[/quote] Wait, won't using up 100% of the core aka the CPU be bad for real time games even for the simple game like Pac-Man? The games I wrote use update, draw, and sleep the application for some time to give the CPU some breathing room. [quote name="Nypyren" post="5203316" timestamp="1420918778"] That's right. More time taken per operation = fewer operations per time = slower.[/quote] I don't know why the source says access from RAM takes nanosecond scale and access from HDD takes millisecond scale. I thought nanosecond is much longer time than millisecond. Shouldn't the length of time for RAM and HDD be swapped? [quote name="Nypyren" post="5203316" timestamp="1420918778"] Usually a lot of stack space is reserved[/quote] How much stack space the computer gets is dependent on the amount of RAM of the computer? How can I find out how much stack space is reserved? Is it important to know the amount?
  12. 1) Why does a program(i.e. Internet Browser) gets loaded into the RAM(I think it is called lv1 cache from the CPU correct me if I am wrong) from hard disk? Why not just access it from the hard disk since that is where the program originated from after installation?   2) Does a computer instruction that takes longer to execute use more RAM?   3) If an instruction needs to create a stack frame does it use RAM and when the stack frame gets popped off, is that when RAM gets released?   4) Since RAM does not seem to be an issue (I assume even people with a tight budget use Windows 7 or a Mac, why is there a need to optimize a function when there is a bottleneck?   5) Are all bottlenecks linked to consuming too much RAM or is it much more than that? I have not experienced a bottleneck (maybe it is because I never used a profiler before or maybe I just know how to write computer instruction that supposedly used less RAM? if that makes any sense)   6) To access the data in RAM, the processor takes a nanosecond scale. Meanwhile, to access the data on the HDD, the time taken in milliseconds scale. I'm confused I thought millisecond or 0.001 was MORE than nanosecond or 0.000000001. Shouldn't accessing RAM take less time than accessing from HDD? Here is the source: http://new-ones.blogspot.com/2012/08/ram-function-for-performance-pc-and.html    7) How much CPU usage should a video game generally used up? I programmed a 2D RPG game and it uses up 15-17% CPU usage and 100 MB of RAM based on the data I am seeing from my Macbook Air's Activity Monitor.   Edit: I hate anonymous down votes...I just want to learn on a deep level
  13. No, it's a tiny amount compared to HD video (or even audio).   Consider what an HD video is at the point it is displayed on your screen: 30 frames of 1920x1080 pixels of 3 bytes each, every goddamn second. Sure, there is a metric ton of compression going on, but it's still a ridiculous amount of data (and let's not even think about 4K video).   By comparison, a well-designed network game has to send the position, velocity and a handful of state variables, for each of the small number of characters that are near the player in the virtual world. That's pretty streamlined.   what do you mean by streamlined? May you explain what is meant by buffered application?
  14. I read Objective C was built on the C programming language. So my initial thought was maybe I should learn C first before learning Objective C so I don't wind up shooting myself in the foot. Or worse, blow my whole leg off using the language.   Originally i tried learning game programming in Swift(thinking I can handle it since I made games using Java). But this does not seem to be the case. There is so much mental overhead and quirks in terms of how the code is presented. It is vastly different from Java.   On a side note, does learning C making C++ more understandable?