Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
arrays of object.... continued #226445
09/09/08 19:52
09/09/08 19:52
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
I know i started this in the other topic but felt it best to start a new topic as my problems wandered so far from the old topic description that its possible people wouldnt bothere reading if it didnt interest them...

Basically im learning this Lite-C malarky and have become quite stuck:

================================================================
#include <acknex.h>
#include <default.c>

ENTITY* FLOOR;

typedef struct
{
ENTITY* model;
} box;

function new_box()
{
box my_box;
my_box.model = "cube.x";
my_box.model.x = -400;
my_box.model.y = 0;
my_box.model.tilt = 145;
my_box.model.z = 2800;
phent_settype (my_box.model, PH_RIGID, PH_BOX); // set the physics entity type
phent_setmass (my_box.model, 3, PH_BOX); // and its mass
phent_setfriction (my_box.model, 80); // set the friction
phent_setdamping (my_box.model, 40, 40); // set the damping
phent_setelasticity (my_box.model, 50, 20); // set the elasticity
}

function main()
{
video_mode=7;
level_load("");
FLOOR = ent_create ("plain3d1.x", vector(-400, 0, 100), NULL); // create the ball
set(FLOOR,LIGHT);
wait(2);
camera.x = 7500;
camera.y = 250;
camera.z = 1250;
camera.pan = 180;
FLOOR.scale_x=5000;
FLOOR.scale_y=5000;
FLOOR.scale_z=30;
FLOOR.z = -5;
FLOOR.red = 0;
FLOOR.green =0;
FLOOR.blue =0;
FLOOR.ambient = 25;
FLOOR.z=-50;

ph_setgravity (vector(0, 0, -6086)); // set the gravity

while (1)
{
// CONTROLS
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
camera.pan -= mouse_force.x * 2;
camera.tilt += mouse_force.y * 2;
if (key_w) camera.y += 12 * time_step;
if (key_s) camera.y -= 12 * time_step;
if (key_a) camera.x += 12 * time_step;
if (key_d) camera.x -= 12 * time_step;
on_e = new_box;
wait(1);
}
}
==============================================================

the two models are cubes and the program is supposed to create a new box every time the E key is pressed. However running the code above, lite-c simply gives the error:

"Malfuntion w1600
Entity not a physics object in main"
OK - CANCEL

What does this mean? :s


I am a noob to this... Blitz3D is where i am best at!
Re: arrays of object.... continued [Re: CdeathJD] #226470
09/09/08 22:44
09/09/08 22:44
Joined: Jul 2008
Posts: 894
T
TechMuc Offline
User
TechMuc  Offline
User
T

Joined: Jul 2008
Posts: 894
my_box.model = "cube.x"; should be

my_box.model = ent_create("cube.x",vector(0,0,0),null);

Re: arrays of object.... continued [Re: TechMuc] #226486
09/10/08 01:17
09/10/08 01:17
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
Cheers! That actually worked. Unfortunately now the editor seems to be discriminating me!!!

heres my new code:
==================================================================================
#include <acknex.h>
#include <default.c>

ENTITY* FLOOR;

typedef struct
{
ENTITY* model;
} box;

function new_box()
{
box my_box;
my_box.model = ent_create("cube.x",vector(0,0,0),NULL);
// my_box.model.x = -400;
// my_box.model.y = 0;
my_box.model.tilt = 145;
// my_box.model.z = 2800;
wait(1);
phent_settype (my_box.model, PH_RIGID, PH_BOX); // set the physics entity type
phent_setmass (my_box.model, 3, PH_BOX); // and its mass
phent_setfriction (my_box.model, 80); // set the friction
phent_setdamping (my_box.model, 40, 40); // set the damping
phent_setelasticity (my_box.model, 50, 20); // set the elasticity
}

function main()
{
video_mode=7;
fps_max = 60;
level_load("");
wait(1);
FLOOR = ent_create ("plain3d1.x", vector(-400, 0, -4800), NULL); // create the ball
set(FLOOR,LIGHT);
wait(2);
camera.x = 7500;
camera.y = 250;
camera.z = 1250;
camera.pan = 180;
FLOOR.scale_x=5000;
FLOOR.scale_y=5000;
FLOOR.scale_z=30;
FLOOR.z = -5;
FLOOR.red = 0;
FLOOR.green =0;
FLOOR.blue =0;
FLOOR.ambient = 25;
FLOOR.z=-50;

ph_setgravity (vector(0, 0, -886)); // set the gravity

while (1)
{
// CONTROLS
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
camera.pan -= mouse_force.x * 2;
camera.tilt += mouse_force.y * 2;
if (key_cuu) camera.x -= 252 * time_step;
if (key_cud) camera.x += 252 * time_step;
if (key_cul) camera.y += 252 * time_step;
if (key_cur) camera.y -= 252 * time_step;
if (key_enter) new_box;
//on_e =
wait(1);
}
}
================================================================================
at the "key_enter" part it all goes wrong and gives me that useless "sytax error" again, even though the function works using the commented out "on_e". But i want to make it happen whilst a key is pressed down.... why isn't it working? argh!


I am a noob to this... Blitz3D is where i am best at!
Re: arrays of object.... continued [Re: CdeathJD] #226541
09/10/08 09:28
09/10/08 09:28
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Simple enough. When calling a function from code, as opposed to
an on_key command, you need to specify what parameters are being passed
to the function, even if there isnt any.

To summarise, change the line
if (key_enter) new_box;
to be
if (key_enter) new_box();

and it'll fix the syntax error. I havent looked any deeper than that.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: arrays of object.... continued [Re: EvilSOB] #226566
09/10/08 11:17
09/10/08 11:17
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
thats rather crazy, in that sometimes you dont have to add "()" on and sometimes you do... personally i prefer to do so all the time! Regardless, the code works and works well, besides a few strange physics errors which i have found:



1) for some reason there appears to be an invisable (and undeclared) box around an area of the screen.

2) The physics seems to crash when i go a bit mental with the ENTER key. I think this may be because when the stream of cube reaches the mystery bounding box, a collision is forced all the way down the line of objects, which stops the most newly created object from moving at all, the engine then tries to create a new physics box next frame in the exact same space, and thus doesnt really know how to solve the collisions and thus throws a benny!

Would i be right in all that?

3) Also how would i go about altering these entities. In blitz there would be something like an "for b.box = each box" command. Ideally im trying to add a "life" property which decreases to zero and then the entity is removed, just to get the hang of acessing individual struct entries properties.

Last edited by CdeathJD; 09/10/08 16:18. Reason: Added q3!

I am a noob to this... Blitz3D is where i am best at!
Re: arrays of object.... continued [Re: CdeathJD] #226647
09/10/08 17:03
09/10/08 17:03
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I'll answer as best I can, but Im no physics guru.

1) I have seen in other posts thats there is some form of virtual bounding box in lite-c to minimise resource requirements.
I think your blocks may be hitting that. It seems this 'box' is based on object placement, but not size. So your 'plain'
may be sticking out the sides without forcing it to expand. Put the following code into main before the loop and see if it helps.
It did weird things to mine but I may be using badly sized models.
Code:
// create universe boundaries
ent_create("cube.x",vector( 500000, 500000,0),NULL);
ent_create("cube.x",vector( 500000,-500000,0),NULL);
ent_create("cube.x",vector(-500000, 500000,0),NULL);
ent_create("cube.x",vector(-500000,-500000,0),NULL);


2) I think you are half right about your phisics going splat, but not cause the this mysterious box.
I think its just too many boxes overlapping each other causing it to go schitzo.

3) Complex question here, but I would suggest looking at some "particle" tutorials because thats exactly how they
are forced behave often, and they be able to explain better than I best way to do this. (Each entity will take care of itself)

Best of luck


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: arrays of object.... continued [Re: EvilSOB] #226824
09/11/08 14:35
09/11/08 14:35
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
I cant find any tutorials on anything... where are they all hidden?


I am a noob to this... Blitz3D is where i am best at!
Re: arrays of object.... continued [Re: CdeathJD] #226825
09/11/08 14:43
09/11/08 14:43
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Nidhogg Offline
Serious User
Nidhogg  Offline
Serious User

Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Try good ol wiki


Windows XP SP3
Intel Dual Core CPU: E5200 @ 2.5GHz
4.00GB DDR3 Ram
ASUS P5G41T-M LX
PCIE x16 GeForce GTS 450 1Gb
SB Audigy 4
Spyware Doctor with AntiVirus
Re: arrays of object.... continued [Re: Nidhogg] #226826
09/11/08 14:55
09/11/08 14:55
Joined: Aug 2008
Posts: 55
United Kingdom
CdeathJD Offline OP
Junior Member
CdeathJD  Offline OP
Junior Member

Joined: Aug 2008
Posts: 55
United Kingdom
I did, its only got a very brief description of something called "add_struct" which isnt what i need.

I need information on how to alter these things after creation and how to delete them!


I am a noob to this... Blitz3D is where i am best at!
Re: arrays of object.... continued [Re: CdeathJD] #226833
09/11/08 16:32
09/11/08 16:32
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Go to the website http://au.conitec.net/ amd
look under tutorials link, handy site.
Its also accessable from the "resources" link
at the footer of this forums pages.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

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

Gamestudio download | 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