Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075910 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 02:25:01 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)The grumpy old programmer room
Pages: 1 ... 19 20 [21] 22 23 ... 236
Print
Author Topic: The grumpy old programmer room  (Read 437332 times)
Kekskiller
Guest
« Reply #400 on: August 09, 2009, 12:04:46 PM »

I'm grump grumpy because I don't know how to combine timer-based movements vectors with gravity without having unpredictable jump behaviour Huh?
Also, delta values suck ass.
Logged
Aquin
Level 10
*****


Aquin is over here.


View Profile WWW Email
« Reply #401 on: August 09, 2009, 04:40:54 PM »

I'm grumpy because I just found this error in my code:

Code:
true = false;
Logged

I'd write a devlog about my current game, but I'm too busy making it.
Schtee
Level 0
***



View Profile WWW
« Reply #402 on: August 10, 2009, 12:25:29 AM »

That's quite the doozy.
Logged
Aquin
Level 10
*****


Aquin is over here.


View Profile WWW Email
« Reply #403 on: August 10, 2009, 12:47:24 AM »

Tell me about it.  Facepalm Facepalm Facepalm
Logged

I'd write a devlog about my current game, but I'm too busy making it.
Draknek
Level 6
*


"Alan Hazelden" for short

msn@draknek.org
View Profile WWW Email
« Reply #404 on: August 10, 2009, 02:12:14 AM »

I'm grump grumpy because I don't know how to combine timer-based movements vectors with gravity without having unpredictable jump behaviour Huh?
Also, delta values suck ass.

The best/easiest solution is to have a fixed update framerate, but if your code looks like this:

Code:
void update (float dt) {
velocity += gravity * dt;
position += velocity * dt;
}

Try changing it to this:

Code:
void update (float dt) {
velocity += gravity * dt;
position += velocity * dt - 0.5f * gravity * dt * dt;
}

I'm grumpy because I just found this error in my code:

Code:
true = false;

And that compiled?
Logged

Kekskiller
Guest
« Reply #405 on: August 10, 2009, 02:57:08 AM »

I'm grump grumpy because I don't know how to combine timer-based movements vectors with gravity without having unpredictable jump behaviour Huh?
Also, delta values suck ass.

The best/easiest solution is to have a fixed update framerate, but if your code looks like this:

Code:
void update (float dt) {
velocity += gravity * dt;
position += velocity * dt;
}

Try changing it to this:

Code:
void update (float dt) {
velocity += gravity * dt;
position += velocity * dt - 0.5f * gravity * dt * dt;
}

Nahh, that isn't the problem. I said timer-based because I have a specific update delay for a one-step movement on each axis. Every time I'm updating the physics, checking how many tiles the objects has passed since last call (plus movement of them, optional raytracing for distance longer 1 pixel). The problem is the system itself - Uint32 together with floats always fails. I tried to implement float-based delay and tricky rest delta but it doesn't work atm.

But hey - maybe you're right? I have a tile-based world, every position is an Integer, no inbetweens. Yay, that's probably the reason. Random update may not suitable for such world, I guess Sad

Thanks man, I'm so stupid Tongue
Logged
Hideous
That's cool.
Level 10
*****


3D models are the best


View Profile WWW Email
« Reply #406 on: August 10, 2009, 02:58:28 AM »

this is very nice

i hate pointers with passion yes

____________
Viagra Cialis Programmer Drug
Logged

Aquin
Level 10
*****


Aquin is over here.


View Profile WWW Email
« Reply #407 on: August 11, 2009, 10:09:57 AM »

Huh that's weird.  My sound isn't working.  Why won't the sound effects in my game work?!

The filenames are in the right place... it should be loading correctly... oh god, am I playing them correctly... IS THERE A MEMORY LEAK WHAT THE HELL

Oh.  My speakers are turned off.  That...would do it.  Facepalm Facepalm Facepalm

You know this + my true = false debacle is making me look pretty stupid.  It's like I'm FIVE YEARS OLD.  WTF
Logged

I'd write a devlog about my current game, but I'm too busy making it.
Titch
Level 3
***


Cautiously Pragmatic


View Profile WWW
« Reply #408 on: August 12, 2009, 06:36:27 AM »

Grumpy because I've just written what feels like the most redundant function ever.

Code:
private function event_if ($item1:String, $compare_type:String, $item2:String)
{
var $val1:int = 0;
var $val2:int = 0;
var result:Boolean = false;
var regExp:RegExp = /\w/
if (regExp.test($item1))
{
$val1 = variable_index[$item1];
}
else
{
$val1 = int($item1);
}
if (regExp.text($item2))
{
$val2 = variable_index[$item2];
}
else
{
$val2 = int($item2);
}
switch ($compare_type)
{
case "equal":
case "==":
result = $val1 == $val2;
case "not equal":
case "!=":
result = $val1 != $val2;
case "greater than":
case ">":
result = $val1 > $val2;
case "less than":
case "<":
result = $val1 < $val2;
case "greater or equal to":
case ">=":
result = $val1 >= $val2;
break;
case "less or equal to":
case "<=":
result = $val1 <= $val2;
break;
}
if (result) loadBranch(0);
}

So I can process stuff like this:

Code:
<sound name="snd_level_down" />
<if var1="gems" is="greater than" var2="49">
<speak>Trade 50 gems to improve your relationship?</speak>
<choice>
<yes>
<speak>Boy:"Something to say on yes"</speak>
<emote>Boy:happy</emote>
<alter var="gems" amount="-50"></alter>
</yes>
<no>
<speak>Boy:"And a no case answer"</speak>
<emote>Boy:unhappy</emote>
</no>
</choice>
</if>
« Last Edit: August 12, 2009, 06:58:49 AM by Titch » Logged

bateleur
Level 10
*****



View Profile
« Reply #409 on: August 12, 2009, 07:59:44 AM »

You know this + my true = false debacle is making me look pretty stupid.  It's like I'm FIVE YEARS OLD.

Not at all. Five year olds are extremely alert and don't make those kinds of errors much. It's more like you're 105. Tongue
Logged

Kekskiller
Guest
« Reply #410 on: August 12, 2009, 09:59:11 AM »

You know this + my true = false debacle is making me look pretty stupid.  It's like I'm FIVE YEARS OLD.

Not at all. Five year olds are extremely alert and don't make those kinds of errors much. It's more like you're 105. Tongue
This proves he's old enough to know that it works in real life.
Logged
Aquin
Level 10
*****


Aquin is over here.


View Profile WWW Email
« Reply #411 on: August 12, 2009, 11:35:23 AM »

Um... when I was 5 and writing BASIC, I made mistakes like that all the time.  Of course I was an inquisitive child.

"What do you mean true can't equal false?  Says who?  Why not?  Why is the sky blue? Yada yada yada..."
Logged

I'd write a devlog about my current game, but I'm too busy making it.
team_q
Level 10
*****


Divide by everything is fine and nothing is wrong.

team_q@hotmail.com
View Profile WWW Email
« Reply #412 on: August 12, 2009, 02:00:29 PM »

I know its bad form but I just do it like this:

Code:
bool booly;

if (booly)
funstuff();
else if (!booly)
notfunstuff();

I was also told that writing it like this:

Code:
if (true == booly)
dostuff();

makes it easier to catch doing this:

Code:
if (true = booly)//doesn't compile
dostuff();

Code:
if (booly= true )//totally compiles
dostuff();


Logged

Dirty Rectangles

_PRINCE OF ARCADE_
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW Email
« Reply #413 on: August 12, 2009, 05:23:09 PM »

I know its bad form but I just do it like this:

Code:
bool booly;

if (booly)
funstuff();
else if (!booly)
notfunstuff();

Why are you testing a boolean twice?  There's no need for the second test.

Code:
bool booly;

if (booly)
funstuff();
else
notfunstuff();

That will work just fine.

Quote
Code:
if (true == booly)
dostuff();

Try comparing a boolean to true or false in a job interview and you'll get laughed out of the room.  That is extremely bad form.  Not having to do that is the whole point behind a boolean data type.
Logged

Franchise - The restaurant wars begin!

What would John Carmack do?
Aquin
Level 10
*****


Aquin is over here.


View Profile WWW Email
« Reply #414 on: August 12, 2009, 05:27:44 PM »

Yeah, I've even been known to treat ints as booleans..

if(numTimes) then  blah blah

I've never done a == true or such.  As for other data types, I rarely make the "this = that" mistake.  I also catch it really quickly when I do.  It's never been an issue for me.  Shrug
Logged

I'd write a devlog about my current game, but I'm too busy making it.
Mr. Yes
Level 5
*****



View Profile WWW Email
« Reply #415 on: August 12, 2009, 05:34:37 PM »

Heh. I make that mistake regularly. And it always takes me so long to notice. You would think that, by now, I wouldn't be making such a simple mistake so often.
Logged

team_q
Level 10
*****


Divide by everything is fine and nothing is wrong.

team_q@hotmail.com
View Profile WWW Email
« Reply #416 on: August 12, 2009, 06:03:28 PM »

Why are you testing a boolean twice?  There's no need for the second test.

I know, it was just to show the (!booly).

Try comparing a boolean to true or false in a job interview and you'll get laughed out of the room.  That is extremely bad form.  Not having to do that is the whole point behind a boolean data type.

I guess I should've done the example with ints.

Logged

Dirty Rectangles

_PRINCE OF ARCADE_
nihilocrat
Level 10
*****


Full of stars.


View Profile WWW Email
« Reply #417 on: August 12, 2009, 06:09:12 PM »

Try comparing a boolean to true or false in a job interview and you'll get laughed out of the room.  That is extremely bad form.  Not having to do that is the whole point behind a boolean data type.

I guess I should've done the example with ints.


It seems the professionals you know have serious cases of Asperger's. Bad form? Seriously, who gives a crap?
Logged

William Laub
Level 10
*****


Gold Cray


View Profile WWW Email
« Reply #418 on: August 12, 2009, 06:54:41 PM »

The ability to control computers makes gods out of ordinary human beings, but there's a limit to how many gods we can have walking around, so there has to be an additional qualification. Only the ones who can control computers the right way get to be gods (allman style is a good start).
Logged
bateleur
Level 10
*****



View Profile
« Reply #419 on: August 12, 2009, 10:23:45 PM »

Try comparing a boolean to true or false in a job interview and you'll get laughed out of the room.  That is extremely bad form.  Not having to do that is the whole point behind a boolean data type.

If I saw someone had done that I'd most likely hire them (unless there was something wrong with the rest of their code). It may be less elegant than using the boolean value directly in the test, but at least it deviates from that in the direction of increased clarity. That's a good fault to have.
Logged

Pages: 1 ... 19 20 [21] 22 23 ... 236
Print
Jump to:  

Theme orange-lt created by panic