Jump to content

  • Log In with Google      Sign In   
  • Create Account


Net Gnome

Member Since 02 Aug 2011
Offline Last Active Apr 12 2014 06:43 AM

#5082248 My OLD Syntax

Posted by Net Gnome on 01 August 2013 - 12:33 PM

i guess you could get crafty and make this work:

x+=vk==vkl?5:vk==vkr?-5:0;y+=vk==vku?-5:vk==vkd?5:0;

destroys all readability though ;)

 

[realized i could compress it a bit more ;)]

 

if your compiler allows logical and-ing ints: you can shorten it to this:

x+=vk&vkl?-5:vk&vkr?5:0;y+=vk&vku?-5:vk&vkd?5:0;



#4973744 Monster thinking in an action rpg

Posted by Net Gnome on 27 August 2012 - 05:27 AM

NN and Genetics will just slow you down, since all they will provide you is what you're going to do during gameplay testing anyway i.e., tweaking your algorithm's variables and structure. You're smarter already than the best NNs and Genetics out there, so they will provide you almost no benefit. Also, HIGHLY recommend getting Dave Mark's book on behavioral mathematics for game AI (link in his signature), almost all of your answers are contained in there Posted Image


#4963405 Passing this as a ref.

Posted by Net Gnome on 26 July 2012 - 01:08 PM

So asking him about the reason for that question so that we can work on a better solution and explain him the issue is irrelevant? I don't think so.


My appologies, I did get a bit mean myself there with the irrelevant comment. I just saw this quickly turning into another "why are you doing that?! are you stupid?" post, and I f'd up and fed the fire. I've been where this guy has been before and hated uppity communities not answering the question I asked, but instead looking for a question they wanted to answer. I fired back inappropriately and a bit unprofessionally, and for that I appologize.


#4963351 Passing this as a ref.

Posted by Net Gnome on 26 July 2012 - 10:13 AM

I -never- stated it was a solution. I stated it was a work-around to his problem. Also, there is no need to berate the man. His question was valid, (paraphrasing) "why wont this work". You're right in that using ref in this case doesnt solve anything due to the fact that the class construct is just a reference mechanism so you dont have to deal with pointers. using bar(Foo foo) is the same as using bar(ref Foo foo) if Foo is a class. However it is -not- the same if Foo is a struct.

demo'd by this program:
struct Foo2
	{
		public int Val;
		public void bar(Foo2 foo)
		{
			foo.Val += 1;
			Console.WriteLine(foo.Val + ":" + this.Val);
			if (object.Equals(foo, this))
				Console.WriteLine("yes");
			else
				Console.WriteLine("no");
		}
		public void bar2(ref Foo2 foo)
		{
			foo.Val += 1;
			Console.WriteLine(foo.Val + ":" + this.Val);
			if (object.Equals(foo, this))
				Console.WriteLine("yes");
			else
				Console.WriteLine("no");
		}
	}
	class Foo
	{
		public int Val = 0;
		private Foo thisFoo;
		public Foo()
		{
			thisFoo = this;
		}
		public static void Main()
		{
			Foo foo = new Foo();
		  
			foo.Val = 1;
			foo.doSomething();
			foo.doSomethingElse();
			Console.ReadLine();
		}
		public void doSomething()
		{
			bar(ref thisFoo);
			bar2(thisFoo);
		}
		public void bar(ref Foo foo)
		{
			Console.WriteLine(foo.Val + ":" + thisFoo.Val + ":" + this.Val);
			foo.Val += 1;
			Console.WriteLine(foo.Val + ":" + thisFoo.Val + ":" + this.Val);
		  
			if (foo == this && foo == thisFoo)
				Console.WriteLine("yes");
			else
				Console.WriteLine("no");
		}
		public void bar2(Foo foo)
		{
			Console.WriteLine(foo.Val + ":" + thisFoo.Val + ":" + this.Val);
			foo.Val += 1;
			Console.WriteLine(foo.Val + ":" + thisFoo.Val + ":" + this.Val);
			if (foo == this && foo == thisFoo)
				Console.WriteLine("yes");
			else
				Console.WriteLine("no");
		}

		public void doSomethingElse()
		{
			Foo2 foo = new Foo2();
			foo.Val = 0;
			foo.bar(foo);
			foo.bar2(ref foo);
		}

output:
1:1:1
2:2:2
yes
2:2:2
3:3:3
yes
1:0
no
1:1
yes


#4963295 Passing this as a ref.

Posted by Net Gnome on 26 July 2012 - 07:25 AM

and what would be the point to pass a ref to this in a reference type again?


Irrelevant. The man asked a question. I gave him an answer. Why he needs it is irrelevant.

If i had to take a WAG, he's using an API that requires a ref param to a type he's extended [The OP responded]. You cant pass "this" as a refernece as that is illegal, nor did he have an object to pass due to the scope of the call, so he needed another way to pass the class, which was to create an object reference of the class within itself upon instantiation, thus creating an object that is usable by a ref parameter.

if you used this
class Foo
	{
		public int Val = 0;
		private Foo thisFoo;
		public Foo()
		{
			thisFoo = this;
		}
		public static void Main()
		{
			Foo foo = new Foo();
			foo.Val = 1;
			foo.doSomething();
		  
			Console.ReadLine();
		}
		public void doSomething()
		{
			bar(ref thisFoo);
		}
		public void bar(ref Foo foo)
		{
			Console.WriteLine(foo.Val + ":" + thisFoo.Val + ":" + this.Val);
			foo.Val += 1;
			Console.WriteLine(foo.Val + ":" + thisFoo.Val + ":" + this.Val);
		}
	}

the output would be
1:1:1
2:2:2


#4927265 Physics Question - How does thrust and mph work?

Posted by Net Gnome on 01 April 2012 - 02:35 PM

What you want are Newton's First and Second laws of motion (velocity and acceleration) as well as his laws of gravitation. They are not too complex as long as you are comfortable with algebra and a little bit of calculus (only if you want to understand how the laws and equations came about, otherwise algebra will work fine).

http://en.wikipedia.org/wiki/Newton's_laws_of_motion
http://en.wikipedia.org/wiki/Newton's_law_of_universal_gravitation

and relate those to thrust: http://en.wikipedia.org/wiki/Thrust

Tie all those together into the equations of motion, and you can move stuff Posted Image http://en.wikipedia....tions_of_motion


With all that said, i think your issue is you're multiplying a velocity by a force, which isnt giving you what you want. In your case you have a Thrust (which is a force), and a force is a mass (airplane) by an acceleration. if you know the mass of the airplane, and its current thrust, you can find an acceleration, you can then use that acceleration to figure out how fast the aircraft is going after a certain amount of time has passed.


#4925088 Mass Effect 3 Ending

Posted by Net Gnome on 25 March 2012 - 06:02 AM

Basically, Promit is lamenting the -fact- that the ME3 writers pulled the biggest taboo of writerdom: the Deus Ex Machina (God out of the Machine). Its a literary term for what Bioware did: pulled a game-changer/ender out of their ass at the last minute that was non-alluded/non-expected/non-probable that completely changes the way the story is handled. This is often seen as extremely poor writing.

So you can imagine the general let-down from a fanbase when a company known for its stories, pulls one of the largest story taboos.


#4923277 What's wrong with OOP?

Posted by Net Gnome on 19 March 2012 - 07:24 AM

I see OOP as a collection of capabilities I can take advantage of in the language i'm using. If it makes sense to use iheritance, use it. If it make sense that a framework should use overloaded/overriden methods, do it, if it doesnt, dont do it. OOP is just another tool in your toolbox, treat it as such. Know how that tool works, and what its best used for and you'll never use it wrong. Same can be said about Declaritive, Functional, Reactive, etc methodologies. Use them when it makes sense for the problem at hand, otherwise use something more appropriate.


#4920198 [Easy] 2D coordinate space issues

Posted by Net Gnome on 07 March 2012 - 03:22 PM

i use the following code in my "smart camera" to have the camera follow a focus point

basically the jist is: find the camera position, find the camera center, find the focus position, find how far it is to the focus point, find the vector of the camera center to the focus point, move the camera origin the appropriate distance along that vector to the focus point. For your example, you dont need to worry about a focus radius, you just should jump strait to the focus point (use full distance)

			Position focusPosition = (Position) c_PositionMapper.get(entity);
			CameraFocus focus = (CameraFocus) c_CameraFocusMapper.get(entity);
			ViewPort cameraView = (ViewPort)c_ViewportMapper.get(c_Camera);
			Vector2 cPos = cameraView.getOrigin();
			Vector2 center = cPos + cameraView.getDimensions() / 2;
			Vector2 fPos = focusPosition.getPosition();
			float dist,radius;
			dist = Vector2.Distance(fPos,center);
			radius = focus.getFocusRadius();
			if (dist > radius)
			{
				Vector2 vec = Vector2.Subtract(fPos, center);
				vec.Normalize();
				cPos += Vector2.Multiply(vec, dist - radius);
				cameraView.setOrigin(cPos);
			}



#4913998 Dealing with multiple collision contact points

Posted by Net Gnome on 17 February 2012 - 02:12 PM

in my 2d collision detection and response routine, the sum of the minimum translation vectors (MTV) of all the collision detection points will move an object out of all collisions. I just store a list of all colliding objects (not duplicating in case two collision points collide with the same object). I then calc the MTV between the colliding object each target object separately and move them apart for each collision. The sum is always the position for no collision.


#4909093 Artificial Emotion

Posted by Net Gnome on 03 February 2012 - 04:59 AM

I think its being coined as Benign Violation Theory... I've seen it put as such: Grandpa is harmless... Erections can be threatening/disturbing... but Grandpa with an Erection is funny... Though, not all Benign Violations work... The key is the Violation has to be negate-able... if you cant negate it with something and make it benign, odds are it can never be funny...

[note to self... too many "..."... suspect too much coffee...]


#4905426 Need tips for CS project management on game/application development

Posted by Net Gnome on 23 January 2012 - 07:14 AM

"Plans are nothing, Planning is Everything" - Eisenhower

Don't worry so much about putting stuff on paper, worry more about the proplem at hand and how you're going to go about dealing with it. That is what planning is: Your approach towards solving a problem. It doesnt need to be complete to the n-th degree, its just a guide you put together to remind yourself what you need to do next on your path to solve a problem. Human memory is faulty, and as programmers/engineers, we tend to get lost in the weeds more than we should and loose sight of where we're heading. Plans help to remind us why we were chasing problem x down the rathole or why group x was chasing that problem. They also tell us where we've been so we dont end up duplicating work as well or tell us where we may have made a wrong turn, so we dont have to start over entirely.

So to sum it up, don't worry too much about "having the ultimate plan", just make sure that you think about how you're going to solve the problem(s) before you, and write that approach down, so you can make use of it and formulate a strategy to resolve it (planning). Do that and you'll have a useful plan.

P.S.:
Remember, NO plan is complete nor correct at the start, not a single one. So don't expect yours to be. They can change and modify as you learn more about the problem you're solving. Additionally, remember this: be able to accept that you may have to start over from scratch if you learn your original assumptions were wrong. Sometimes your initial approach will be the exact opposite of what you need to do to solve the problem, so be comfortable with this idea. Anyway, good luck.


#4905112 Beginner General Networking Question

Posted by Net Gnome on 22 January 2012 - 09:42 AM

Basically, you want to use port forwarding to accomplish this. Apache should be able to do the port forwarding to the IP:PORT of your choice. That is assuming you are using different IPs for each of your VMs in your virtual network on your virtual host. if you're not, you'll probably want to set it up that way so you can.


#4904968 Need tips for CS project management on game/application development

Posted by Net Gnome on 21 January 2012 - 05:29 PM

If you can get a hold of MIL Handbook 881 (Work Breakdown Structures) it helps alot with breaking down the tasks of projects of any size (software to ships). Once you get past the military jargon, its a real asset. Another good one is MIL Handbook 61a (Configuration Management). What makes these nice is they are free (unlike IEEE, ISO, and EIA). Additionally, ISO, IEEE, and EIA were based off of them ;)


#4902358 Component Entity Model Without RTTI

Posted by Net Gnome on 13 January 2012 - 08:58 AM

From what i usually see, is you have a series of systems that concern themselves with the player's entity. This means there is an entity ID out there, that you've remembered in some way, that represents the player. You dont extend the Entity class with a PlayerEntity class, you just remember that Entity 123 is the player. I like how Artemis does it and keeps a dictionary of notable single entities (i.e., mapping the string "PLAYER" or const PLAYER to Entity 123) through a Tag Manager (you could probably modify this to be faster with pre-defined static types as well). or important groups through a Group Manager. Each system knows which entities it cares about and then uses thier IDs as indexes through component mappers.

Anyway, back to your question. The basic importance is that Entities are IDs, Components are just data containers, and systems crunch through components based on some entity ID. Systems do anything you want game logic to do. Obviously, you're going to have player focused systems, which crunch on components owned by the entity tagged PLAYER. But, you may even want to think of it more abstractly. Perhaps you dont need to be so focused on the PLAYER, but perhaps a specific type of key component of interest, like Controllable. Perhaps you only have one Controllable component in the entire game space (or perhaps several for a squad based game), and you move it (i.e., re-assign it or re-create it) around to various entities along with a Camera Focus component. The system just takes keyboard inputs and then uses those to modify the Spatial component of the entity that owns the Controllable component

Once you start thinking about it, you're not really controlling the model being rendered, but you're really just affecting position data points which are tied to this entity, which in turn are being represented by something on the screen from some arbitrary viewpoint by the rendering system. The rendering system doesnt care that its the player, only that it should put texture x or model y at coordinate z and render from viewpoint v. You could do some really crazy things when you string components together and add/remove them. Like an item that grants an effect that then morphs into an enemy that you fight then becomes a corpse quest item that you pick up that can be used in a recipe to make some other item which you turn in for a reward. Without an ECS Framework, making that happen would be an absolute nightmare, but you could do it in an ECS Framework by just dynamically adding/removing/updating components to an entity.

Its really a different way to think about things. It shows how things we think are related to eachother really have absolutely nothing to do with eachother, since our human need to categorize/group unrelated things gets in the way.

I will not lie, ECS Frameworks have data overhead to them, and therefore may not suit everyones needs (i.e., may be overkill). They can be fast (6000+ created, rendered, destroyed entiteis per second / 1,000,000+ created, unrendered, destroyed entities per second) [i believe this is what artemis touts], but only if you put some good thought into their management. They are great for games with complex systems (RPGs, roguelikes, MMOs particularly), since you can separate logic easier and you have significantly less ripple effects when you modify systems.




PARTNERS