Jump to content

  • Log In with Google      Sign In   
  • Create Account


MJLaukala

Member Since 21 Jan 2011
Offline Last Active Jul 13 2012 01:44 AM
-----

Posts I've Made

In Topic: If statement frustration with UdpClient.Receive

30 May 2012 - 01:10 AM

yes, I am going to use a ThreadPool. I was just doing a test run when I came across this error. I've been doing some research into passing arrays as parameters. Because they are reference type variables passed by value, any changes made to the original value or parameterized value will change the in memory value. My next thoughts were to send the array to another function and then start the thread there but because we're still dealing with a reference type, we will have the same issue. What options do I have at this point that might work better than message.CopyTo()? I feel like creating a new array every time a message is received is going to be pretty resource intensive as well. It would work fine for testing purposes but I would prefer a system that is optimized for speed.

In Topic: [java] need help with unexpected results

02 February 2011 - 09:48 PM

mm,
you know that java have no pointers?

All calls with objects are call by reference and all primitive calls are call by value



Maybe not explicitly but they are there.If they weren't, then this code would work on an update.

this._PreviousKeyState = this._CurrentKeyState;
this._CurrentKeyState = this.keyboard;


I found that if you write

this._PreviousKeyState = this._CurrentKeyState;
this._CurrentKeyState = this.keyboard;


in the constructor only, that both this._PreviousKeyState and this._CurrentKeyState will always equal this.keyboard even when this.keyboard's value is changed and this._PreviousKeyState and this._CurrentKeyState was never told to equal this.keyboard after the statement is the constructor.

In Topic: [java] need help with unexpected results

01 February 2011 - 11:41 PM

I figured out why it's not working! The problem is pointers. Now I just need to figure out how to solve the problem. I'll look for a topic on not using pointers and if I can't find one, I'll make a new topic.

Yeah, I understand now, why my code didn't work. Pointers are no fun to work with but it's ok. I think I can make this work to my advantage!!

In Topic: [java] need help with unexpected results

01 February 2011 - 08:40 PM

TBH, I've no idea why you wouldn't simply implement the standard KeyListener and then use then keyPressed() and keyReleased() methods. Store the boolean status of your key presses (true for pressed, false for released) and then action accordingly. No disrespect, but your methid seems overly complicated and considerably extra work for no real benefit.


I'm building a highly reusable input manager. What you suggest is essentially what I am doing. The only difference is that I am using enums for the key states instead of booleans.



In Topic: [java] need help with unexpected results

01 February 2011 - 08:32 PM



	protected KeyboardState getState()
	{
		KeyboardState state = new KeyboardState();
		state = this;
		return state;
	}

Sens, this doesn't make any.

some thoughts, favor composition over inheritance, use inheritance as sparse as possible(interfaces nearly always better).
A Keyboard Object should have a KeyStatus object and a KeyStatus object should have many Key objects.

Beside that, throw all your code away and just use the standart java libs.







I changed

	protected KeyboardState getState()
	{
		KeyboardState state = new KeyboardState();
		state = this;
		return state;
	}

to

	protected KeyboardState getState()
	{
		return this;
	}

Yeah, that was kinda extra code that was not needed. I use interfaces where I don't need classes. I am building a reusable Game Engine. The problem is not weather I am using interfaces or classes. the problem is that for some unknown reason, my code doesn't work and i'm not getting any compile errors or runtime errors.

PARTNERS