1 registered members (Akow),
1,365
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Lite C Simple games using just Lite C ?
[Re: jreuschel1]
#213530
06/28/08 18:26
06/28/08 18:26
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
what's wrong with lite-c? What can you not accomplish in it? I don't know about it being buggy because i haven't had any problems.
You have good lite-c code yet you cannot run it on lite-c? Hmm i think you should check the errors in your script rather than blame the engine.
Last edited by DJBMASTER; 06/28/08 18:35.
|
|
|
Re: Lite C Simple games using just Lite C ?
[Re: DJBMASTER]
#213532
06/28/08 18:33
06/28/08 18:33
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
hah i lold hard to jreuschel, not saying irrlicht is bad but that crashing-good-code thingy...
3333333333
|
|
|
Re: Lite C Simple games using just Lite C ?
[Re: DJBMASTER]
#213534
06/28/08 18:45
06/28/08 18:45
|
Joined: Mar 2007
Posts: 18
jreuschel1
Newbie
|
Newbie
Joined: Mar 2007
Posts: 18
|
that is the problem. no errors. just crashes and erratic behavior
look at this code:
VECTOR camloc; //vec_for_vertex(&camloc,eGD5,1651); camloc.x=eGD5.x; camloc.y=eGD5.y; camloc.z=eGD5.z;
now when i use a direct reference to eGD5.x,y, or z i get certain result i try to use camloc.x,y, and z in place of eGD5.x,y, and z and get a totally different result
it does something like this to me:
pseudocode:
B="8" A=B print A result: "5" print B result: "8" print A,B result: "74 is the name of our lord god the Jusuius Grand Master Chryus"
now why is that?
here is the complete code:
function UpdateDust(){ int n; VECTOR camloc; //vec_for_vertex(&camloc,eGD5,1651); camloc.x=eGD5.x; camloc.y=eGD5.y; camloc.z=eGD5.z;
//note: in the following code if i use a direct reference to eGD5 I get totally different results
the reason i don't use eGD5 in the first place is because i want to use the camera location, but when i do that, it freezes, crashes, etc.
for(n=0;n<50;n++){ if(Dust[n].x<(camloc.x-50)){ Dust[n].x=camloc.x+50; Dust[n].y=random(100)-50; Dust[n].z=random(100)-50; } if(Dust[n].x>(camloc.x+50)){ Dust[n].x=camloc.x-50; Dust[n].y=camloc.y+random(100)-50; Dust[n].z=camloc.z+random(100)-50; } if(Dust[n].y<(camloc.y-50)){ Dust[n].y=camloc.y+50; Dust[n].x=camloc.x+random(100)-50; Dust[n].z=camloc.z+random(100)-50; }
if(Dust[n].y>(camloc.y+50)){ Dust[n].y=camloc.y-50; Dust[n].x=camloc.x+random(100)-50; Dust[n].z=camloc.z+random(100)-50; } if(Dust[n].z<(camloc.z-50)){ Dust[n].z=camloc.z+50; Dust[n].x=camloc.x+random(100)-50; Dust[n].y=camloc.y+random(100)-50; } if(Dust[n].z>(camloc.z+50)){ Dust[n].z=camloc.z-50; Dust[n].x=camloc.x+random(100)-50; Dust[n].y=camloc.y+random(100)-50; } } }
|
|
|
Re: Lite C Simple games using just Lite C ?
[Re: jreuschel1]
#213560
06/29/08 00:51
06/29/08 00:51
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
#include <acknex.h>
#include <default.c>
function UpdateDust();
VECTOR eGD5;
int main (){
vec_set(eGD5,vector(10,20,30));
UpdateDust();
}
function UpdateDust(){
VECTOR camloc;
camloc.x=eGD5.x;
camloc.y=eGD5.y;
camloc.z=eGD5.z;
printf ("%lf == %lf\n",(double)camloc.x,(double)eGD5.x);
printf ("%lf == %lf\n",(double)camloc.y,(double)eGD5.y);
printf ("%lf == %lf\n",(double)camloc.z,(double)eGD5.z);
}
i don't know what you're trying to do jreuschel1, but here is an abbreviated form of your code (the parts that actually matter regarding your problem). it works perfectly. next time use [ code] [/ code] tags to display your code please. @dracula: sorry about the off-topicness. have you looked at the entrants for the 100 lines contest (check the AUM forum)? a lot of them use quite cryptic code to save lines, but i think quite a few of them are quite clean small examples of games in lite-C. julz
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: Lite C Simple games using just Lite C ?
[Re: JibbSmart]
#213561
06/29/08 01:25
06/29/08 01:25
|
Joined: Mar 2007
Posts: 18
jreuschel1
Newbie
|
Newbie
Joined: Mar 2007
Posts: 18
|
Ok. here it is in it's entirety: an example "game"
#include <acknex.h>
#include <default.c>
///////////////////////////////////////////////////////////////
// some global definitions
ENTITY* eGD5;
ENTITY* eEN1[7];
ENTITY* Dust[300];
VECTOR vSpeed, vAngularSpeed, vForce, vMove;
VECTOR vVelocity;
///////////////////////////////////////////////////////////////
function UpdateDust(){
int n;
VECTOR camloc;
//vec_for_vertex(&camloc,eGD5,1651);
camloc.x=eGD5.x;
camloc.y=eGD5.y;
camloc.z=eGD5.z;
//in the following code of this function if you replace the text "camloc" with eGD5 it "works" best
//if you replace it with "camera" it freezes
for(n=0;n<50;n++){
if(Dust[n].x<(camloc.x-50)){
Dust[n].x=camloc.x+50;
Dust[n].y=random(100)-50;
Dust[n].z=random(100)-50;
}
if(Dust[n].x>(camloc.x+50)){
Dust[n].x=camloc.x-50;
Dust[n].y=camloc.y+random(100)-50;
Dust[n].z=camloc.z+random(100)-50;
}
if(Dust[n].y<(camloc.y-50)){
Dust[n].y=camloc.y+50;
Dust[n].x=camloc.x+random(100)-50;
Dust[n].z=camloc.z+random(100)-50;
}
if(Dust[n].y>(camloc.y+50)){
Dust[n].y=camloc.y-50;
Dust[n].x=camloc.x+random(100)-50;
Dust[n].z=camloc.z+random(100)-50;
}
if(Dust[n].z<(camloc.z-50)){
Dust[n].z=camloc.z+50;
Dust[n].x=camloc.x+random(100)-50;
Dust[n].y=camloc.y+random(100)-50;
}
if(Dust[n].z>(camloc.z+50)){
Dust[n].z=camloc.z-50;
Dust[n].x=camloc.x+random(100)-50;
Dust[n].y=camloc.y+random(100)-50;
}
}
}
///////////////////////////////////////////////////////////////
function flyEN1(ENTITY* ENT1){
VECTOR vForce1, vMove1;
VECTOR vHeadDiff;
VECTOR vDiff2;
vec_set(vHeadDiff,eGD5.x);
vec_sub(vHeadDiff,ENT1.x);
vec_to_angle(ENT1.pan,vHeadDiff);
ENT1.roll=-eGD5.roll;
vForce1.x=0;
vForce1.y=0;
vForce1.z=0;
//make vForce1=ENT1-eGD5;
//this is really nice how you get to use a function now in place of using an '=' operator
//eg:the clearly readable "vForce1=ENT1.pos-eGD5.pos"
//is now replaced by the next two lines beautiful beautiful beautiful
vec_set(vForce1,ENT1.x);
vec_sub(vForce1,eGD5.x);
vec_scale(vForce1,-0.001);
vec_scale(vForce1,0.4);
VECTOR oldENT1pos;
if(vec_dist(ENT1.x,eGD5.x)<3000){
vec_scale(vForce1,-1);
}
ENT1.x=ENT1.x+vForce1.x;
ENT1.y=ENT1.y+vForce1.y;
ENT1.z=ENT1.z+vForce1.z;
}
///////////////////////////////////////////////////////////////
function main()
{
// Activate 800x600 screen resolution and stencil shadows,
// and set the sound at full volume.
// Video_mode is a 'redefine' variable that has to be set
// before initializig the video device during the first wait().
video_mode = 7;
shadow_stencil = 1;
wait(3);
level_load("");
wait(-1);
// create a sky cube on layer 0
ent_createlayer("stars+6.tga", SKY | CUBE | VISIBLE, 0);
eGD5=ent_create("ringship.MDL",vector(0,0,0),NULL);
eGD5.scale_x=4*3;
eGD5.scale_y=4*3;
eGD5.scale_z=4*3;
int n;
for(n=0;n<7;n++){
eEN1[n]=ent_create("ringship.MDL",vector(n*400,n*300,n*500),NULL);
eEN1[n].scale_x=4*3;
eEN1[n].scale_y=4*3;
eEN1[n].scale_z=4*3;
}
for(n=0;n<50;n++){
Dust[n]=ent_create("Dust.bmp",vector(random(100)-50,random(100)-50,random(100)-50),NULL);
Dust[n].scale_x=0.01;
Dust[n].scale_y=0.01;
Dust[n].scale_z=0.01;
}
while (1)
{
int n;
for(n=0;n<7;n++){
flyEN1(eEN1[n]);
}
vForce.x = -1.5*(key_force.x + mouse_force.x); // pan angle
vForce.y = -1.5*(key_force.y + mouse_force.y); // tilt angle
vForce.z = -0.5*(key_a-key_d); // roll angle
c_rotate(eGD5,vForce.x,USE_AXISR);
vForce.x = 0.018 * (key_w - key_s); // forward after vec_rotate
vForce.y = 0.018 * (key_a - key_d); // sideward after vec_rotate
vForce.z = 0.018 * (key_home - key_end); // upward after vec_rotate
vec_rotate(vForce.x,eGD5.pan);
VECTOR LastPos;
VECTOR CurrentPos;
LastPos.x=eGD5.x;
LastPos.y=eGD5.y;
LastPos.z=eGD5.z;
CurrentPos.x=eGD5.x+vVelocity.x;
CurrentPos.y=eGD5.y+vVelocity.y;
CurrentPos.z=eGD5.z+vVelocity.z;
CurrentPos.x+=vForce.x;
CurrentPos.y+=vForce.y;
CurrentPos.z+=vForce.z;
vVelocity.x=CurrentPos.x-LastPos.x;
vVelocity.y=CurrentPos.y-LastPos.y;
vVelocity.z=CurrentPos.z-LastPos.z;
vec_scale(vVelocity.x,0.99);
eGD5.x=CurrentPos.x;
eGD5.y=CurrentPos.y;
eGD5.z=CurrentPos.z;
VECTOR camloc;
vec_for_vertex(&camloc,eGD5,1651);
vec_set(camera.x,camloc);
vec_set(camera.pan,eGD5.pan);
UpdateDust();
wait(1);
}
}
the best i can do with lite-c
|
|
|
Re: Lite C Simple games using just Lite C ?
[Re: Joozey]
#213566
06/29/08 02:07
06/29/08 02:07
|
Joined: Mar 2007
Posts: 18
jreuschel1
Newbie
|
Newbie
Joined: Mar 2007
Posts: 18
|
please post on topic this is first and last warning
Last edited by Shadow969; 06/29/08 14:26. Reason: offtopic
|
|
|
|