A few questions about lite-C game development

Posted By: kmega00

A few questions about lite-C game development - 10/09/13 12:57

I don't know a whole lot about math but I'm aiming to become a professional game developer regardless.

I wish to become a good game developer because I've brought and waisted so much money on so many bad games in the past. I've also brought/played some great games that rocks. I believe by mastering game development techniques using lite-C I'll be able to create some great multi-player games that'll be enjoyed by many.

I've been through the tutorials a while back and now carefully reading through the main Acknex manual. There are some things I understand and there are things I don't.

In order to create the best games possible I wish to ask questions about things I don't understand.

Any answers are well appreciated.

My first question:

I know absolutely nothing about floats except I think it's used in creating some material effects and other things.

It seems that the knowledge of float is not fully required to create great looking games.

Is it possible to create great games with lite-C without the mathematical knowledge of float?
Posted By: PadMalcom

Re: A few questions about lite-C game development - 10/09/13 13:09

Float is a data type for decimal numbers. If english is your mother language, you should definitely learn some math! If not, read a book about programming first before you start programming games. To know what a float is is absolutely necessary.
Posted By: Aku_Aku

Re: A few questions about lite-C game development - 10/09/13 13:24

I am not sure what do you talk about, i assume it is a type of the numeric variables.
There integers where there is no decimal point.
There are decimal numbers, they have integer part and fraction part and between them there is the decimal point.
Here are two subtypes, the first has fixed number of decimal numbers, and the second part where the decimal point can move left-right or foreward-backward.
Here is the web page what is describe this variable type, better than me:
Floating point
Posted By: kmega00

Re: A few questions about lite-C game development - 10/09/13 17:11

Thanks for the info on floats.

Another question from the manual (I'm slowing reading through it):

Want to make sure I'm understanding this example from Strucs under the programming tab in the manual.

Code:
function spot_init(SPOT* spot) 
{ 
  if (!spot) return; // prevent crash when an empty pointer is passed
  spot.x = 1; 
  spot.y = 1; 
}
...
SPOT myspot; // creates an uninitalized SPOT struct named "myspot"
...
spot_init(myspot); // passes a pointer to myspot



It's my belief function spot_init sets myspot.x to 1 and myspot.y to 1 when it's ran with (myspot) as an argument?
Posted By: sivan

Re: A few questions about lite-C game development - 10/09/13 17:34

yes.

not scientifically : a struct is a structure that contains its own variables, given in its definition. like a VECTOR that has x, y and z.
Posted By: kmega00

Re: A few questions about lite-C game development - 10/09/13 18:19

I'm feeling pretty good I understood or at least understood enough about the last example. I'll continue to post about things I don't understand here.

A while back I tried to build a game with mostly just the knowledge I had obtained from the lite-c tutorial alone. I'll share a few screen-shots and the unfinished code I was working with.













I don't plan to finish this game because I'm trying to learn as much as I can from the Acknex manual and then build a much better one that is procedural. The more I learn from the manual the more I realize I could have had a much easier time coding.

I believe posting over 3,000 lines of code here might be too much?

The code can be downloaded from zippyshare here:
msf.c


Another question:
A function sample under Functions tab within programming category:

Code:
function vector_add2 (var* sum,var* v1,var* v2)
{
	//calculate the sum of two vectors
	sum[0] = v1[0] + v2[0];
	sum[1] = v1[1] + v2[1];
	sum[2] = v1[2] + v2[2];
}
var vector1[3] = { 1,2,3 };
var vector2[3] = { 4,5,6 };
var vector3[3];
//...
vector_add2 (vector3,vector1,vector2); //vector3 now contains 5,7,9



I understand that different argument types are supported but...
can I pass other argument types at the same time such as

Code:
function vector_add2 (var* sum,var* v1,var* v2,ENTITY* ent,PARTICLE* p) ???
{
	//calculate the sum of two vectors
	sum[0] = v1[0] + v2[0];
	sum[1] = v1[1] + v2[1];
	sum[2] = v1[2] + v2[2];
}
var vector1[3] = { 1,2,3 };
var vector2[3] = { 4,5,6 };
var vector3[3];
//...
vector_add2 (vector3,vector1,vector2); //vector3 now contains 5,7,9

Posted By: sivan

Re: A few questions about lite-C game development - 10/10/13 07:14

yes, you can combine any in that way you wrote.
Posted By: kmega00

Re: A few questions about lite-C game development - 10/10/13 19:32

An example under Programming, under Precompiler, (#ifdef,#ifndef,#else,#endif)

Code:
#define LOW_RES
...
#ifndef LOW_RES
  video_mode = 8; // 1024x768
#else
  video_mode = 6; // 640x480
#endif



I partially understand this example. I'm assuming that I may never need to wright code using this? I don't see the advantage since you can use functions for this also. Does this have any advantage over functions if your only programming in lite_C ?
Posted By: Aku_Aku

Re: A few questions about lite-C game development - 10/10/13 19:39

When you post source code parts, please use the code tags.
You can find it, meanwhile you write your own post, at the top of the text box of the post. It has an icon with # sign.
I am sure your post will be prettier, and the community will understand easier.
Posted By: oliver2s

Re: A few questions about lite-C game development - 10/10/13 19:41

This example from the manual isn't the best in my opinion.

I will try a better one:
Code:
//#define USE_PHYSX3

#ifdef USE_PHYSX3
	#include <ackphysx3.h>
	#else
	#include <ackphysx.h>
#endif

void create_physics_ent()
{
	ENTITY* ent_tmp=ent_create(CUBE_MDL,nullvector,NULL);
	
	#ifdef USE_PHYSX3
		pX3ent_settype(ent_tmp,PH_RIGID,PH_BOX);
		pX3ent_setdamping(ent_tmp,50,80);
		pX3ent_setskinwidth(ent_tmp,0);
		pX3ent_setiterations(ent_tmp,16);
		pX3ent_setfriction(ent_tmp,100);

		#else

		pXent_settype(ent_tmp,PH_RIGID,PH_BOX);
		pXent_setdamping(ent_tmp,50,80);
		pXent_setskinwidth(ent_tmp,0);
		pXent_setiterations(ent_tmp,16);
		pXent_setfriction(ent_tmp,100);
	#endif
}



In my example I use it to switch between A8 PhysX DLL and the Community PhysX3 DLL. I just have set or unset "#define USE_PHYSX3" and the whole code is changing.
Posted By: kmega00

Re: A few questions about lite-C game development - 10/10/13 21:20

Originally Posted By: oliver2s
In my example I use it to switch between A8 PhysX DLL and the Community PhysX3 DLL. I just have set or unset "#define USE_PHYSX3" and the whole code is changing.


Thanks
Great example. I'm still on A7 (I also understand PHYSX is for A8) but I still understand however...
How would you set or unset "#define USE_PHYSX3" ?
Posted By: alibaba

Re: A few questions about lite-C game development - 10/11/13 06:41

You can do that by script:
#define USE_PHYSX3

Or by command line:

-d USE_PHYSX3
Posted By: oliver2s

Re: A few questions about lite-C game development - 10/11/13 06:44

You set it by just typing "#define USE_PHYSX3" in your script. And you unset it by deleting that line or comment it out "//#define USE_PHYSX3".
Posted By: alibaba

Re: A few questions about lite-C game development - 10/11/13 07:14

Whoops, missed the question grin
Posted By: kmega00

Re: A few questions about lite-C game development - 10/14/13 19:41

Thanks for the info.
Another question (Engine Objects/ENTITY/Events/EVENT_DISCONNECT)

Code:
function disconnect_event() 
{
  if (event_type == EVENT_DISCONNECT)
  {
    ptr_remove(me);
  }
}

action actor()
{
  ...
  my.emask |= ENABLE_DISCONNECT; // sensible for disconnects
  my.event = disconnect_event;
  ...
}



I'm assuming that any entity with ENABLE_DISCONNECT attached will definitely know when it's client has indeed disconnected without fail.

Another question under (Engine Objects, ENTITY, Script parameters, skill1..skill100)

Skills can also be accessed through an array index from 0 to 99, f.i. my.skill1 == my.skill[0].

Is the manual stating my.skill3 is the same as my.skill[2] ?
Code:
my.skill3 = 100;
my.skill[2] = 100;


Both statements above sets my.skill3 to (100)?

Manual (Engine Objects, ENTITY, Script parameters, string1, string2)
Code:
str_cpy(name_str,my.string1);


Please give another example on how entity.string is used/or what it can be used for. Thanks.
Posted By: kmega00

Re: A few questions about lite-C game development - 10/15/13 20:13

When I try to run this example from the manual in:
(Engine Objects, PARTICLE, [BEAM,STREAK])

Code:
function p_alphafade (PARTICLE *p)
{
	p.alpha -= p.skill_a*time_step;
	if (p.alpha <= 0) p.lifespan = 0;
}

function p_trace (PARTICLE *p)
{
	set (p,BRIGHT | TRANSLUCENT | BEAM);
	p.size = 2;
	p.skill_a = 1; //fade factor
	p.event = p_alphafade;
}

//entity that runs in circles and leaves a vapor trail
action tracer ()
{
	var dist = 0,radius = 10,sign = 1;
	VECTOR last_pos;
	while (1)
	{
		vec_set (last_pos,my.x);
		dist += 30*time_step;
		radius += sign*random(3)*time_step; //change radius randomly
		if (radius > 150) sign = -1;
		else if (radius < 30) sign = 1;
		my.x = radius*sin(dist);
		my.y = radius*cos(dist);
		effect (p_trace,1,my.x,vec_sub(last_pos,my.x));
		wait (1);
	}
}

function main ()
{
	vec_set (sky_color, vector (50,1,1)); //dark blue
	level_load (NULL);
	video_window (NULL, NULL, 0, "Vapor trail demo");
	vec_set (camera.x, vector (-250,0,50));
	vec_set (camera.pan, vector (0, -15,0));
	ent_create (NULL, vector (0,0,0),tracer);
}



I get a compiler error message

Error in line 3:
'var' undeclared identifier
< var myvariable = 123.456; >
Error E355: Startup failure - any key to abort

Would anyone know how to make this code error free?
Thanks.

Planet lineup from my abandoned 3D space game

Posted By: oliver2s

Re: A few questions about lite-C game development - 10/15/13 20:15

You need to include Acknex in the very first line of the code:

Code:
#include <acknex.h>

Posted By: kmega00

Re: A few questions about lite-C game development - 10/15/13 20:20

Originally Posted By: oliver2s
You need to include Acknex in the very first line of the code:

Code:
#include <acknex.h>



Just tried it and still does not work. Same error message.
Posted By: oliver2s

Re: A few questions about lite-C game development - 10/15/13 20:25

In your code above there's no "var" in line 3. Please post the complete code.
Posted By: kmega00

Re: A few questions about lite-C game development - 10/16/13 02:35

This is the whole example code from the A7 manual in:
(Engine Objects, PARTICLE, [BEAM,STREAK]
Code:
function p_alphafade (PARTICLE *p)
{
	p.alpha -= p.skill_a*time_step;
	if (p.alpha <= 0) p.lifespan = 0;
}

function p_trace (PARTICLE *p)
{
	set (p,BRIGHT | TRANSLUCENT | BEAM);
	p.size = 2;
	p.skill_a = 1; //fade factor
	p.event = p_alphafade;
}

//entity that runs in circles and leaves a vapor trail
action tracer ()
{
	var dist = 0,radius = 10,sign = 1;
	VECTOR last_pos;
	while (1)
	{
		vec_set (last_pos,my.x);
		dist += 30*time_step;
		radius += sign*random(3)*time_step; //change radius randomly
		if (radius > 150) sign = -1;
		else if (radius < 30) sign = 1;
		my.x = radius*sin(dist);
		my.y = radius*cos(dist);
		effect (p_trace,1,my.x,vec_sub(last_pos,my.x));
		wait (1);
	}
}

function main ()
{
	vec_set (sky_color, vector (50,1,1)); //dark blue
	level_load (NULL);
	video_window (NULL, NULL, 0, "Vapor trail demo");
	vec_set (camera.x, vector (-250,0,50));
	vec_set (camera.pan, vector (0, -15,0));
	ent_create (NULL, vector (0,0,0),tracer);
}


I realize that most of the examples from the Acknex manual will not run on it's own however I would most appreciate any help in rewriting this example into something that can run without error so it can be experimented with grin
Thanks.
Posted By: oliver2s

Re: A few questions about lite-C game development - 10/16/13 08:16

It just works fine for me, even in A7. I just opened SED, created an empty file, copied your code and it worked.
Posted By: Nems

Re: A few questions about lite-C game development - 10/16/13 09:16

Yup, worked for me too, straight copy and past then save and run...
Posted By: kmega00

Re: A few questions about lite-C game development - 10/16/13 10:06

Originally Posted By: oliver2s
It just works fine for me, even in A7. I just opened SED, created an empty file, copied your code and it worked.

Originally Posted By: Nems
Yup, worked for me too, straight copy and past then save and run...

It now works for me also smile
I tried it again but this time I saved the script into the work dir instead of the GStudio 7 dir and also made sure it was the only script file opened.

On another topic:
I was thinking that a game would render faster with fake 3D models using 2D Sprites instead of models. For instance if I built two 6 sided space ships (front,back,top,bottom,left,right), one built through WED and the other built from 6 sprites that came together to simulate a 3D ship but all 6 sprites would have to update their angles and position every frame in order to keep their 3D looks.

Would the 6 sprites boxed together and updating their angles and position every frame render faster then an actual 3D space ship model?
Posted By: Superku

Re: A few questions about lite-C game development - 10/16/13 11:02

This fake 3D sprite ship approach sounds like a really bad idea to me, sorry. Just use a 3D model instead, if you keep the polygon count low it will even render faster than 6 sprites because the engine and the culling algorithm only have to consider one entity and you don't have to update angles and the like.
© 2024 lite-C Forums