The Dink Network

sp_foo(bar, -1);

January 16th 2004, 10:19 PM
wizardg.gif
Paul
Peasant He/Him United States
 
I was just thinking about how lame the "-1" method for retriving sprite properies is, and I wondered if anyone was thinking of adding some other method to any of these dink modification/rewrite projects.
January 17th 2004, 09:42 AM
wizardb.gif
merlin
Peasant He/Him
 
You caught my attention. One thing, what does -1 do in Dink? It's not proper in C++ to return a negative integer.
January 17th 2004, 09:55 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Like Paul said, -1 returns a value. For example, like this:

int &sp_x = sp_x(&current_sprite, -1);

would return the x-coordinate of the current sprite.
January 17th 2004, 10:14 AM
wizardb.gif
merlin
Peasant He/Him
 
Er, why the heck wouldn't you just do:

int &sp_x = sp_x(&current_sprite);
January 17th 2004, 12:17 PM
wizardb.gif
Phoenix
Peasant He/Him Norway
Back from the ashes 
cause it requires you to set something, although -1 tells it to set itself to what it currently is. Afaik.
January 17th 2004, 01:19 PM
wizardg.gif
Paul
Peasant He/Him United States
 
See? It's pretty wierd how it works now, isn't it? And the worst part is that means you can't set sprite most attributs to -1. And for some attributs, eg sp_mx and sp_my, -1 would be a perfectly reasonable value. The tricky thing would be keeping backwards compatable if you changed it (I think).

If I were going to do it (which I'm not) I'd probably do either of these:

1. Allow omiting the -1 but still treat is as a special value if the result of the sp command is being asigned to something [&x = sp_y(1, -1);] but if it's just used as a straight statment [sp_y(1, -1);] then really set it to -1.

2. Keep the sp commands for compatibility by add a new set of functions that work in a cleaner way.
January 17th 2004, 04:49 PM
slimeb.gif
pdub
Peasant He/Him
 
Merlin is the guy to talk to. I think that's a good idea. Keep old crappy commands for back.comp and create new one that rock! Give me an ATAN2 function too so I can make sprites automatically track Dink across the screen.
January 17th 2004, 05:27 PM
wizardb.gif
merlin
Peasant He/Him
 
ATAN2?
January 18th 2004, 07:39 PM
bonca.gif
From the manual page for atan2:

ATAN2(3) Linux Programmer's Manual ATAN2(3)

NAME
atan2 - arc tangent function of two variables

SYNOPSIS
#include <math.h>

double atan2(double y, double x);

float atan2f(float y, float x);

long double atan2l(long double y, long double x);

DESCRIPTION
The atan2() function calculates the arc tangent of the two
variables x and y. It is similar to calculating the arc
tangent of y / x, except that the signs of both arguments
are used to determine the quadrant of the result.

RETURN VALUE
The atan2() function returns the result in radians, which
is between -PI and PI (inclusive).