Gamestudio Links
Zorro Links
Newest Posts
No errors in the command line
by jcl. 05/06/26 06:48
Purchase A8 full licence version
by jcl. 05/05/26 11:20
Z9 getting Error 058
by k_ivan. 04/25/26 19:13
ZorroGPT
by TipmyPip. 04/25/26 16:09
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
4 registered members (Hartmann846, TipmyPip, 2 invisible), 5,361 guests, and 12 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hartmann846, dangyc, ukgamer, valino, juergenwue
19212 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
can anyone help me? #308426
02/03/10 10:09
02/03/10 10:09
Joined: Dec 2009
Posts: 12
Y
yunn Offline OP
Newbie
yunn  Offline OP
Newbie
Y

Joined: Dec 2009
Posts: 12
hi.. im a newbie here. currently im developing an interior design game using lite-c.
i've found an example and make it as reference for my game. i manage to get the item placed on the scene. and now, i want to make price for each item(entity) and total up them at the end. the price will be add for each item dragged into the
scene and subtracted when the user delete the item from the scene.

the case is, i wrote the code to call the item like this :

#define f(furniture.pstring)

TEXT* furniture ={
strings = 25;
string("nullunit.mdl","sofa.mdl","tv.mdl");
}
.
.
.

and called by this function:

.
.
.

if(mouse_left){
{
unit = ent_create(f[my.skill2],my.x,act);
vec_set(unit.pan,my.pan);
}
.
.
.


but i had no idea how to combine the price for each item and call it after that to add or substract the related price, and total them up.
does anyone has any idea how to do it?


**sorry for my bad english

Re: can anyone help me? [Re: yunn] #308772
02/04/10 21:18
02/04/10 21:18
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline
Expert
FoxHound  Offline
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
You will need a var that will keep track of the total price, and then you add or subtract from that var to have a correct total as you add or remove items from display. So

if(mouse_left){
{
unit = ent_create(f[my.skill2],my.x,act);
vec_set(unit.pan,my.pan);
grandtotal += price_of_f[my.skill2];
}
if(mouse_right){//also make sure this only works when over an entity.
ent_remove(blah blah)
grandtotal -= price_of_f(blah blah);
}

Another option is to create a manager that knew every item in the screen and have it add up a total each cycle. This one could be buggy if not done right but could be more simple depending.


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: can anyone help me? [Re: FoxHound] #308794
02/05/10 03:23
02/05/10 03:23
Joined: Dec 2009
Posts: 12
Y
yunn Offline OP
Newbie
yunn  Offline OP
Newbie
Y

Joined: Dec 2009
Posts: 12
tq so much foxhound. it gave me some idea.


another question, how am i suppose to embed each price to each item?
is it i need to put it in the same TEXT field?

Re: can anyone help me? [Re: yunn] #308945
02/05/10 23:05
02/05/10 23:05
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline
Expert
FoxHound  Offline
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
Putting it in the text field would display the the price but would not do anything to keeping track of how much is spent. You're best bet is to make a struct for the furniture and having an int to keep track of the price and have it added in the function that creates the furniture and places it in the level.


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: can anyone help me? [Re: FoxHound] #309229
02/08/10 02:04
02/08/10 02:04
Joined: Dec 2009
Posts: 12
Y
yunn Offline OP
Newbie
yunn  Offline OP
Newbie
Y

Joined: Dec 2009
Posts: 12
owh ok..!! thanks~

Re: can anyone help me? [Re: yunn] #309232
02/08/10 02:32
02/08/10 02:32
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
surely you could just save the price in one of the entities skills?

#define cost skill1
action unit(){
my.cost = 15;
}

or just create an array to match your TEXT

Code:
TEXT* txt_furniture = {
   string("nullunit.mdl","sofa.mdl","tv.mdl");
}
var var_cost[25] = { 0, 50, 25.5 };
var var_total;

//then give each item a value so it knows what it's referencing in the array

#define id skill1

action sofa(){
   my.id = 1;
}

action tv(){
   my.id = 2;
}

//do all these for each item


//then for performing the click

void select_item(){
   
   if(!mouse_ent){ return; }
   
   ENTITY* ent = mouse_ent;
   
   //if not already added, add it
   if(!is(ent, LIGHT)){
      //glow green
      vec_set(ent.blue, vector(128, 255, 128));
      set(ent, LIGHT);
      var_total += var_cost[ent.id];
   }else{
      reset(ent, LIGHT);
      var_total -= var_cost[ent.id];
   }

void main(){
   on_click = select_item;
}



*untested* brackets may be missing tongue

hope this helps

Re: can anyone help me? [Re: MrGuest] #309240
02/08/10 04:19
02/08/10 04:19
Joined: Dec 2009
Posts: 12
Y
yunn Offline OP
Newbie
yunn  Offline OP
Newbie
Y

Joined: Dec 2009
Posts: 12
mrguest, thank you so much. i guess it helps a lot. though i have'nt do it. hehe..
i will try it after this.

i manage to get the item on the scene, as you know, interior design should can place item onto other item. but i couldnt place other item onto another item cause of the bounding box. for example, a telephone on the table. do you know how to fix this?

Re: can anyone help me? [Re: yunn] #309241
02/08/10 04:26
02/08/10 04:26
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
use 'c_setminmax(entity)' to set the bounding box to the actual size of the model.

Re: can anyone help me? [Re: DJBMASTER] #309253
02/08/10 07:53
02/08/10 07:53
Joined: Dec 2009
Posts: 12
Y
yunn Offline OP
Newbie
yunn  Offline OP
Newbie
Y

Joined: Dec 2009
Posts: 12
djbmaster, i did use c_setminmax..
any other option besides c_setminmax?

Re: can anyone help me? [Re: yunn] #310872
02/17/10 13:42
02/17/10 13:42
Joined: Dec 2009
Posts: 12
Y
yunn Offline OP
Newbie
yunn  Offline OP
Newbie
Y

Joined: Dec 2009
Posts: 12
anyone knows why cant i place an item onto another item? is it really because of the bounding box or lite c does not support placing item onto other item except terrain?

if it is, how can i fix this?


also want to ask, how to rotate a camera while it points to fix view?

Page 1 of 3 1 2 3

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