Developing a 2D 3DGS API, need help

Posted By: MrCode

Developing a 2D 3DGS API, need help - 11/25/07 23:05

I'm in the beginnings of developing a "2DAPI" for 3D Gamestudio (which should prove very useful). I'm trying to get this function to work, but it doesn't. By all means, it should, unless there's something I should know about a code structure like this:

Code:
struct->struct->member



I think this is where the problem lies, because when I remove the first struct, it works.

You know, I think it would be easier if I just posted the whole code instead of hemming and hawing like this

So here's the Code:

#include <acknex.h>

#define NONE 1
#define IMG_SIZE 2
#define PAN_SIZE 3
#define MANUAL 4
#define RELDIST 5
#define ABSDIST 6

VECTOR* objCenter= {x= 0; y= 0;}

typedef struct _OBJECT
{
PANEL* panel;
int boundstype;
int boundsX;
int boundsY;
}OBJECT;

void obj_move(OBJECT* obj,VECTOR* move,int flag)
{
float thrustX,thrustY;
while(obj)
{
switch(flag)
{
case RELDIST:
obj->panel->pos_x= objCenter->x - obj->panel->center_x;
obj->panel->pos_y= objCenter->y - obj->panel->center_y;
thrustX= sin(obj->panel->angle);
thrustY= cos(obj->panel->angle);
objCenter->x-= (thrustX * ((key_cuu * move->x) - (key_cud * move->y))) * time_step;
objCenter->y-= (thrustY * ((key_cuu * move->x) - (key_cud * move->y))) * time_step;
obj->panel->angle+= ((key_cul * move->z) - (key_cur * move->z)) * time_step;
default:
break;
}
wait(1);
}
}

And this is the code I use to test the function:

#include <acknex.h>
#include <2DAPI.h>
#include <default.c>

VECTOR* move= {x= 10; y= 10; z= 10;}

PANEL* test=
{
bmap= "aship.pcx";
center_x= 12;
center_y= 16;
flags= VISIBLE | OVERLAY;
}

OBJECT* movetest=
{
panel= test;
boundstype= NONE;
boundsX= 0;
boundsY= 0;
}

void main()
{
video_mode= 8;
video_screen= 1;
screen_color.red= 1;
obj_move(movetest,move,RELDIST);
}

And yes, 2DAPI.h is in the include folder, so the <...> syntax isn't the reason ;)



As you can see, I've created a struct OBJECT* to simplify collision operations (which will be implemented later on, if I can get this to work). The problem is, when I try to use obj->panel->pos_x/y/angle, the function doesn't work. It works when I chage the OBJECT* parameter into a PANEL* and remove the obj-> part, but that's it. The code is to allow for relative movement and rotation, just like c_move in the standard 3DGS functions.

Can ne1 clarify on how (if at all) you use the "struct->struct->member" code? The compiler reads it as valid syntax, it's just not running the function.
Posted By: MrCode

Re: Developing a 2D 3DGS API, need help - 11/30/07 05:03

Anyone?
Posted By: D3D

Re: Developing a 2D 3DGS API, need help - 11/30/07 09:01

Don't get discouraged for the lack of response. I really hope you find some help, because I need better 2D functions in Gamestudio.
Posted By: Felixsg

Re: Developing a 2D 3DGS API, need help - 11/30/07 09:46

why not use 3d models but from a 2d perpective?
Posted By: D3D

Re: Developing a 2D 3DGS API, need help - 11/30/07 11:30

That can be done though it would not be real 2D with just texture art not models. ATM I need to use DirectX SDK and C++ to create a Contra clone with the help of some books which is very hard to learn. Maybe I could have complete it in a month if using easy script like C-Script/Lite-C.
Posted By: MrCode

Re: Developing a 2D 3DGS API, need help - 12/01/07 02:26

Thx 4 the responses, guys, but I'm really just looking for a yes or no, and if no, then how would I work around it? I still want to use the OBJECT* struct, but I can't seem to be able to use a PANEL* as one of its members.
Posted By: LarryLaffer

Re: Developing a 2D 3DGS API, need help - 12/01/07 10:39

I tried your code and couldn't figure it out.. You should ask conitec about this
Posted By: HeelX

Re: Developing a 2D 3DGS API, need help - 12/01/07 10:47

I wonder why you create the OBJECT the way you are doing it. Just simply go this way:

  • write a function which creates and returns an OBJECT: OBJECT* createOBJECT ()
  • an OBJECT has an own PANEL element. So, createOBJECT would need to dynamically create a PANEL by pan_create
  • use parameters in createOBJECT to create and fill the PANEL


From now on you can simply create OBJECTs like OBJECT* testObject = createOBJEC(); and everything gets done automatically.
Posted By: LarryLaffer

Re: Developing a 2D 3DGS API, need help - 12/01/07 11:13

His syntax still works though, and for all i understand, the code should be working but it's not. The new panel's parameters don't get modified when accessed through a parent struct, when they should..
Posted By: MrCode

Re: Developing a 2D 3DGS API, need help - 12/10/07 02:47

@HeelX: I want to be able to declare an OBJECT* struct just like anything else (like PANEL*, ENTITY*, and so on).
Posted By: i_program_games

Re: Developing a 2D 3DGS API, need help - 12/10/07 07:35

Conitec will probably have more info. However,I did get this to work when entered into your main routine:

movetest->panel=test;
movetest->panel->pos_x=100;
movetest->panel->pos_y=100;
Posted By: MrCode

Re: Developing a 2D 3DGS API, need help - 12/13/07 05:35

Well, then you would have to declare:

test= (insert your panel here);

But I think I can make it work somehow.
© 2024 lite-C Forums