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!


m3mb3rsh1p

Member Since 27 Mar 2008
Offline Last Active Aug 09 2013 09:39 PM

Posts I've Made

In Topic: What is a tight loop?

09 August 2013 - 08:11 PM

Does it work?

For a game, nobody really cares if your system is sub-optimal. Nobody cares about the implementation details. Nobody cares that you chose one algorithm over another. All that people care about is it looks good on their screen and plays well in their mind.

If they say "It looks like a game, and it is fun" they don't care which pathfinding algorithm you used, or if your particle systems rely on SOA or AOS layouts. All they care about is that the end result looks good and feels good to them.


If it works for you and your app, then it is just fine.

Computers are really, really, really fast. For the PC you've got about a half-billion cycles per frame. Feel free to use them.

This negative attitude is detrimental to the goal of producing good technology especially when one asks for the "right way" to accomplish a task.

People do and should care about efficiency and correctness even if the component is invisible to the user. It transfers good practices to parts that are visible.

There are numerous examples of systems that "work" but have performance quirks because someone didn't care or thought the part would be invisible.

it is best to use technology correctly and efficiently because it only feels limitless in the moment. A fast but callously developed app on one device will be sluggish on another or even on the same device when other resource-hungry apps are active....

Seriously, please care.

In Topic: a = b = new c?

30 June 2013 - 12:17 PM

There's also the type casting taking place:

T a = b = (T)new c();
mParameters[Name] = pParam = (ShaderParameter)new FloatParameter;

...or however it should be done.

 

I think it would be clearer to have the cast or temporary identified on a separate line.


In Topic: Virtual Coin Flip

12 October 2012 - 07:01 PM

Eureka! I solved the "equals() method not working properly!" conundrum!
public boolean equals(Object other)
{
final Coin c = (Coin)other;
return _side == c._side;
}

In Topic: Virtual Coin Flip

12 October 2012 - 05:28 PM

Hi. I'm also a beginner so I thought I'd share my solution. I'm stuck at how to count the flips without loops because I don't quite yet have a firm grasp of the Java utils.

I enjoyed this. Thanks to all!
import java.util.Random;
import java.util.Arrays;
import java.util.Collections;

public class Coin
{
public enum Side { heads, tails, edge };

public Coin()
{
	_side = Side.edge;
}
public Coin(Side side)
{
	_side = side;
}
public Coin(Random generator)
{
	flip(generator);
}
public void flip(Random generator)
{
	double value = generator.nextDouble();

	if(value < 0.5 )
	{_side = Side.heads;}
	else if(value > 0.5)
	{_side = Side.tails;}
	else
	{_side = Side.edge;}
}
public boolean equals(Coin other)
{
	return _side == other._side;
}
public String toString()
{
	return _side.toString();
}
	private Side _side;

public static void main(String[] args)
{
	Coin heads = new Coin(Side.heads);
	Coin tails = new Coin(Side.tails);
	
	Random rand = new Random();
	
	Coin[] coins = new Coin[]
	{
		new Coin(rand),
		new Coin(rand),
		new Coin(rand),
		new Coin(rand),
		new Coin(rand),
		new Coin(rand),
		new Coin(rand),
		new Coin(rand),
		new Coin(rand),
		new Coin(rand)
	};

	System.out.println(Arrays.toString(coins));

	int numHeads = Collections.frequency(Arrays.asList(coins), heads);
	System.out.println("There are " + numHeads + " heads.");

	int numTails = Collections.frequency(Arrays.asList(coins), tails);
	System.out.println("There are " + numTails + " tails.");
}
}

I encountered some challenges while finding the "right way"
- no easy way to "apply"
- countif/equality not working here
- *()&(SFHKJHSF(&(*&:>( code tags!!

In Topic: [C++] When you inherit from a base class which has virtual functions, why is...

06 March 2012 - 01:50 PM

I don't understand what SegmentationFault was trying to explain.

??

...FastRunner::run() is not virtual any more. So that if you inherit it in the class Foo:
...
Foo::run() does not override FastRunner::run() but hide it
...

??
yet the example provided calls Foo::run() through a Fastrunner. With Fastrunner privately inherited, the example wouldn't compile.

For now I'll stick to pulpfist's initial summary.

Also, I don't think it's virtual by default, Its virtual by force. I don't think you can "stop" the chaining of a virtual function in C++


PARTNERS