Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


warnexus

Member Since 07 Jun 2012
Offline Last Active Feb 24 2015 01:27 AM

#5212630 Subtraction Problem in Java

Posted by warnexus on 23 February 2015 - 11:55 PM

Okay so floating point arithmetic in Java is an approximation. Understood, thanks guys. Thanks for the link, Glass_Knife.




#5212373 Subtraction Problem in Java

Posted by warnexus on 22 February 2015 - 09:10 PM

Why is System.out.println(1.4-1) producing "0.3999999999999999" as the difference in Java?

 

In Math, 1.4 - 1 is 0.4.

 




#5203326 About computer instruction in relation to RAM consumption

Posted by warnexus on 10 January 2015 - 02:52 PM

Ignoring instruction fetch bandwidth and cache misses, the speed of instruction execution does not depend on its encoding length.


What do you mean by encoding length? So what does speed of instruction depend on? Is it based on the algorithm analysis?

Real-time games are typically written to consume 100% of each core they can run on.


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.

That's right. More time taken per operation = fewer operations per time = slower.


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?

Usually a lot of stack space is reserved


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?


#5203307 About computer instruction in relation to RAM consumption

Posted by warnexus on 10 January 2015 - 12:05 PM

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




#5202270 Why am I forced to call the super class init method with 3 parameters when in...

Posted by warnexus on 06 January 2015 - 10:32 AM

import SpriteKit
 
 
class HeroNode: SKSpriteNode
{
    
    init(imageNamed: String)
    {
        
        let texture = SKTexture(imageNamed: imageNamed)
        // you have no choice but to call this super class init method for some reason
        super.init(texture: texture, color: nil, size: texture.size())
    }
    
   
 
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

Question 1 : I don't understand why I need to call  "super.init(texture: texture, color: nil, size: texture.size())" and instead cannot use " super.init(texture: texture)". If I use " super.init(texture: texture)", the error I get is "Must call a designated initializer of the superclass 'SKSpriteNode' " but this init is also part of the SKSpriteNode class... Does that mean there is "only one designated initializer" of the superclass "SKSpriteNode" which is " super.init(texture: texture, color: nil, size: texture.size())" Why am I restricted into call this super init and not call the other init methods?

 

Question 2: The compiler also says I need to add " required init?(coder aDecoder: NSCoder) {

        fatalError("init(coder:) has not been implemented") " . 

}

 

This code from Question 2 seems to be making an init variable and optional assuming it will be nil at some point throughout program flow. Why add this "error-catching code" if I don't know if I will catch the error. Is Swift being super safe about error-catching? Why define a required init method if I am already calling the super class init method in the "over-ridden" init method? 

 

Question 3: Is it me or is Swift much harder to code? It seems not to embrace "abstraction" because it lets me access the public variables from within the object of the class.  




#5200727 Cannot grasp the concept of delegation

Posted by warnexus on 29 December 2014 - 10:37 PM

http://best-practice-software-engineering.ifs.tuwien.ac.at/patterns/delegation.html

 

This source says delegation is like inheritance but done manually through object composition.

 

I do not know what they mean by done manually. I know what inheritance is. But they represent a multiple inheritance example. But since I only know Java on a deep level, this example does not make sense to me because such concept does not exist in Java. In Java, one class can only inherit one class(which is always the super class). 

 

I know what object composition. It is the idea that a class can be made up of multiple classes. Like this:

 

public class Mario extends Sprite

{

 

private MarioAnimationMoveLeft;

private MarioAnimationMoveRight;

private MarioFireBall

 

public Mario()

{

 

}

 

}

 

But what is meant by "done manually?"

 

What is confusing me:

The fact that this source gives the multiple inheritance example(because from a programmer who only knows Java I cannot comprehend this concept) and also the single inheritance with delegation.

 

I do not understand the single inheritance with delegation example because my interpretation is that the class B inherits from class C. But if class B inherits from class C then (why is the -b object of Class B in Class C)?<- my interpretation is confusing me. Class C inherits from Class A. 

 

On a side note, I am learning a new programming called Swift. The reason why I am learning Swift is because I can write less code than if I learned Objective C. Despite being really good with Java and programming games using Java for a year and a half, learning Swift presents some challenges in getting used to the Swift syntax and the Xcode environment. I am 4 days in and I know very little.  

 

Not sure if it is how the book prepares the reader or if it is my brain unable to comprehend abstract concepts...Need help SOS. Any advice learning a new programming language having learned Java are well appreciated!




#5199143 Verify answers to these big o notation questions

Posted by warnexus on 19 December 2014 - 01:36 PM

 

 

Can you post the exact wording of the problem?

 




Determine whether each of these functions is [/size]O (x )[/size]. [/size]

 



So what is the answer you came up with? And why?

 

Hi Alvaro, that's the wrong question. It seem you quoted the wrong post that does not exist on this thread. I never typed the part you quoted. I updated the "why" and purpose in the first post.




#5196875 Why is math transformation taxing to most CPUs?

Posted by warnexus on 07 December 2014 - 06:02 PM


Done poorly a game can still overload the CPU with badly-written math operations.

 

badly-written math operations as in "poorly optimized math code"? May you write an example showcasing a badly-written math operations and a goodly-written math operations? Definitely would want to learn more.




#5196730 Why is math transformation taxing to most CPUs?

Posted by warnexus on 06 December 2014 - 09:39 PM

How old is that book?

 

In the 90's the first bottleneck was rasterizing a triangle. Once GPUs became better at it, the next most expensive operation was transform and lighting; which at that time was being done in the CPU and sent every frame to the GPU.

That's why HW TnL (Hardware Transform and Lighting) was invented, which kept the vertices always in the GPU, and the math was done entirely in the GPU. Later this would evolve in what we now know as vertex shaders.

 

I have a hunch that book could be really, really old.

This book is a information technology - 2 years old. It's focus is trouble-shooting. The author decided to shed light on some 3D graphics just for fun.




#5195078 Critique My Implementation Of Pong?

Posted by warnexus on 27 November 2014 - 06:19 PM

While, I cannot see your code because I do not use C++. I can say good code generally materialized from bad code. At least you are learning a whole lot by combing game development and general programming!




#5194542 Touch painting in the dirt

Posted by warnexus on 24 November 2014 - 10:34 PM

This might give you some insight: 

 

The above video is how the team at Disney simulating snow for their movie "Frozen". They get into some deep math and jargon. Is it required for dirt? Depends how you want your dirt to react.

 

I would think its a real-time visual stimulation that reacts differently depending the level of touch. Disney did a lot of tests so I suggest the same thing do a lot of scientific tests to get insight and build on top of that. They wind up seeing a lot of snow references and play a lot with snow just to be in attuned with snow.

 

I think the challenge is figuring out how your app is going to read the fingerprints and then tell the dirt to behave based on how deep you press your screen or smear around screen. Play with dirt and record your findings if you want to go realistic.

 

As with setting or building new technical demos, start simple and work your way up steadily.




#5194212 Game Development.

Posted by warnexus on 22 November 2014 - 08:29 PM

First rule is getting the basic foundation of the programming language down first. 

 

I come from the Java background. Learned a lot of the basic Java concepts and then learned a lot of 2D graphics concepts in Java graphic libraries and then learned more concepts about game development. Learned how to image edit. Paint and GIMP works fine. 

 

Another advice is see a gameplay video frame by frame, I mean by the tenth, hundredth and thousand of the second, there is a lot of animation insight from video analysis.

 

Since I use Java, I use Eclipse IDE.

 

Important thing is there is no right program. It is just a tool. If you know the tool and stay dedicated to learning until you can make and finish a simple game, you are ahead of a lot of people. There is a lot of tough work even after thinking you understood the programming language and game development will teach you even more concepts along the way. Best thing is don't give up.




#5192356 Why are new game updates unable to view old RTS game replays?

Posted by warnexus on 11 November 2014 - 09:04 PM

It does not seem to be a technical issue that cannot be fixed (you know like "it should be possible for the programmer to make a new game update view old game replay data) but why don't they? Is it because the new game update overwrites the old game data of units and buildings and etc thus there is an inconsistency?

 

I would think a game replay for an RTS game is just a text containing a lot of data in regards to "events" of objects:

 

1) what units and buildings were created from both parties and when did the interactions happening among these type of objects per second?

2) and updating in game text data

 

 




#5192290 Gameplay and Balance Design between a mage and a warrior

Posted by warnexus on 11 November 2014 - 12:36 PM

Okay so this seems to be a tough balance to create.

 

This game would be a 1 v 1 pvp with 2 classes: mage and warrior

 

The only way I can ensure the mage won't win all the time against a warrior is

1) if the mage can fire spells while being immobile.

2) comparison to the mage, the warrior is slightly quicker.

3) comparison to the warrior, the mage attack power is slightly stronger

4) comparison to the mage, the warrior has slightly more armor and hp.

 

None of the actual game has been developed but I thought I draft up a small design document like this before development starts.

 

Any thoughts?




#5183392 Detecting tile collisions in a 2D platformer

Posted by warnexus on 27 September 2014 - 09:05 PM

My question is there a better way of detaching collisions. I never done a 2D platformer and I already learned a lot of lessons after solving the coordinate comparisons problem with the main character colliding with the block.

 

I was thinking storing the blocks tiles into a list for a given "game map" class. But then it seems the main character need to go through constantly a list of blocks let say for "24 blocks" which means 24 elements in an array list even though the main character is no where the blocks but is in the game map that contains those blocks. 

 

I love to hear everyone suggestions. I know the below code can be improved. block 1 code is the same code as block 0 code. The difference is the replace block0 name with block1 name and you will see the code is exactly the same.

 

Code is in Java. 

 

 
// block 0 code
if(getX() + idleRightAnim.getWidth() > block.getX() - camera.getX()
&& getX() < block.getX() + block.getWidth() - camera.getX()
&& getY() + idleRightAnim.getHeight() == block.getY() - camera.getY()
&& state != ActionState.RUNNING && state != ActionState.ATTACKING)
{
 
state = ActionState.IDLE;
onSurface = true;
 
 
}
 
if((getX() + idleRightAnim.getWidth() < block.getX() - camera.getX()
|| getX()  > block.getX() + block.getWidth() - camera.getX())
&& getY() + idleRightAnim.getHeight() == block.getY() - camera.getY())
{
onSurface = false;
 
}
 
// block 1 code
if(getX() + idleRightAnim.getWidth() > block1.getX() - camera.getX()
&& getX() < block1.getX() + block1.getWidth() - camera.getX()
&& getY() + idleRightAnim.getHeight() == block1.getY() - camera.getY()
&& state != ActionState.RUNNING && state != ActionState.ATTACKING)
{
 
state = ActionState.IDLE;
onSurface = true;
 
 
}
 
 
if((getX() + idleRightAnim.getWidth() < block1.getX() - camera.getX()
|| getX()  > block1.getX() + block1.getWidth() - camera.getX())
&& getY() + idleRightAnim.getHeight() == block1.getY() - camera.getY())
{
onSurface = false;
 
}
 

 

ScreenShot2014-09-27at105957PM_zps5372b3






PARTNERS