Gamestudio Links
Zorro Links
Newest Posts
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, Aku_Aku, 1 invisible), 579 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Developing a 2D 3DGS API, need help #169394
11/25/07 23:05
11/25/07 23:05
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
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.

Last edited by MrCode; 11/25/07 23:11.
Re: Developing a 2D 3DGS API, need help [Re: MrCode] #169395
11/30/07 05:03
11/30/07 05:03
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
Anyone?


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: Developing a 2D 3DGS API, need help [Re: MrCode] #169396
11/30/07 09:01
11/30/07 09:01
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline
Serious User
D3D  Offline
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
Don't get discouraged for the lack of response. I really hope you find some help, because I need better 2D functions in Gamestudio.


smile
Re: Developing a 2D 3DGS API, need help [Re: MrCode] #169397
11/30/07 09:46
11/30/07 09:46
Joined: May 2003
Posts: 567
Spain, Canary Islands
Felixsg Offline
User
Felixsg  Offline
User

Joined: May 2003
Posts: 567
Spain, Canary Islands
why not use 3d models but from a 2d perpective?

Re: Developing a 2D 3DGS API, need help [Re: Felixsg] #169398
11/30/07 11:30
11/30/07 11:30
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline
Serious User
D3D  Offline
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
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.


smile
Re: Developing a 2D 3DGS API, need help [Re: D3D] #169399
12/01/07 02:26
12/01/07 02:26
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
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.


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: Developing a 2D 3DGS API, need help [Re: MrCode] #169400
12/01/07 10:39
12/01/07 10:39
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline
Serious User
LarryLaffer  Offline
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
I tried your code and couldn't figure it out.. You should ask conitec about this


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Re: Developing a 2D 3DGS API, need help [Re: MrCode] #169401
12/01/07 10:47
12/01/07 10:47
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
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.

Re: Developing a 2D 3DGS API, need help [Re: HeelX] #169402
12/01/07 11:13
12/01/07 11:13
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline
Serious User
LarryLaffer  Offline
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
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..


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Re: Developing a 2D 3DGS API, need help [Re: LarryLaffer] #169403
12/10/07 02:47
12/10/07 02:47
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
@HeelX: I want to be able to declare an OBJECT* struct just like anything else (like PANEL*, ENTITY*, and so on).


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1