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
2 registered members (TipmyPip, 1 invisible), 18,731 guests, and 7 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
did i do this right? #142704
07/22/07 05:36
07/22/07 05:36
Joined: Apr 2007
Posts: 35
texas
over_board Offline OP
Newbie
over_board  Offline OP
Newbie

Joined: Apr 2007
Posts: 35
texas
I took up an interest in 3dgs and decided to script. its hard...and arduous. but im ready to learn . i joined Initiate games because the owner is my friend and classmate. I was trying to make a simple counter go from 1 to 17 then to 0 and exit the engine. But... it only goes up to 99 and stops...and does nothing.

here is the code i used
code
---------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////
//code by over board - new programmer in Initiate Games /////////
/////////////////////////////////////////////////////////////////
function count_down
{
{

while(cool_var == 10);
{
count += 1;
wait(1);
}
if(count == 17);
{
count -= 1;
wait(1);
}
if(count == 0);
{
exit;
}
}
}


New progammer for... Initiate Games (c) 2007 and Sckratch Magazine (c) 2007 http://www.sckratchmagazine.com
Re: did i do this right? [Re: over_board] #142705
07/22/07 06:02
07/22/07 06:02
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Your loop will never end because when count reach 17,
if (count == 17)
{
count -=1; // count became 16
}

then go back to

count += 1; // count = 17 then again and again.....

Re: did i do this right? [Re: vlau] #142706
07/22/07 06:04
07/22/07 06:04
Joined: Apr 2007
Posts: 35
texas
over_board Offline OP
Newbie
over_board  Offline OP
Newbie

Joined: Apr 2007
Posts: 35
texas
how would i make it count down to 0 from 17 then?


New progammer for... Initiate Games (c) 2007 and Sckratch Magazine (c) 2007 http://www.sckratchmagazine.com
Re: did i do this right? [Re: over_board] #142707
07/22/07 06:33
07/22/07 06:33
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline
User
MrCode  Offline
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
I would put the count-= 1; part in a separate function, and then once the counter reaches 17, use break to stop the current function and run it.

Code:

function count_back()
{
while(count<= 17)
{
count-= 1;
wait(1);
}
}

...

in your counting up function:

if(count== 17)
{
break;
count_back();
}



Of course in Lite-C this could easily be done with for loops:

Code:

#include <acknex.h>

var count;

PANEL* num_display=
{
digits (320,240,"%1.0f",_a4font,1,count);
flags= VISIBLE;
}

void main()
{
screen_color.blue= 1;
for(count; count < 17; count+= 1 * time_step) wait(1);
for(count= 17; count <= 17; count -= 1 * time_step) wait(1);
}



This will actually make the number go negative when it's counting down, but it works.

Last edited by MrCode; 07/22/07 06:45.

Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: did i do this right? [Re: over_board] #142708
07/22/07 06:38
07/22/07 06:38
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline
Serious User
D3D  Offline
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
Code:
var cool_var;

panel countdisplay
{
digits(50,50,4,*,1,cool_var);
}

function TheCount()
{
while(cool_var != 17)
{
cool_var += 1;
wait(5000); // for test
}
//cool_var = 0;
return;
//exit;
}

function main()
{
countdisplay.visible = on;
on_enter=TheCount;
}




smile
Re: did i do this right? [Re: D3D] #142709
07/22/07 06:53
07/22/07 06:53
Joined: Apr 2007
Posts: 35
texas
over_board Offline OP
Newbie
over_board  Offline OP
Newbie

Joined: Apr 2007
Posts: 35
texas
oki thanks


New progammer for... Initiate Games (c) 2007 and Sckratch Magazine (c) 2007 http://www.sckratchmagazine.com
Re: did i do this right? *DELETED* *DELETED* *DELE [Re: over_board] #142710
07/22/07 07:11
07/22/07 07:11
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline
Serious User
D3D  Offline
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
@Xarthor: Yes lol your right, but i'm up all night. Tried to remove the other post it didn't worked


smile
Re: did i do this right? [Re: D3D] #142711
07/22/07 07:14
07/22/07 07:14
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
@D3D:
Doesn't he want to count it down to zero again?

Code:

var cool_var;

function TheCount()
{
while(cool_var < 17)
{
cool_var += 1;
wait(-1);
}

while(cool_var > 0)
{
cool_var -= 1;
wait(-1);
}
}




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