i've done everything i can think of

Posted By: gamingfan101

i've done everything i can think of - 07/01/09 03:03

hi, i finally got my menu done, for the most part. I'm trying to test the button that switches over to a seperate program. It reads it fine, but it says that there is an error in this line.

function turn_on()
{
set(nxthi_panel, SHOW);
}

In its own program it works fine, but once its connected it doesnt. heres the other code.


PANEL* mainbutton1 =
{
bmap = gonorm;
pos_x = 10;
pos_y = 100;
button (0, 0, goclicked, gonorm, goover, robotswitch, NULL, NULL);
flags = OVERLAY | SHOW;
}

function robotswitch()
{
#include"robotshowcase.c";
}

Thanks!
Posted By: the_mehmaster

Re: i've done everything i can think of - 07/01/09 03:41

#include "robotshowcase.c";

You do not need the semi-colon. It should be

#include "robotshowcase.c"

Also, this only includes the code from the program, so it probably won't work even if you get the syntax errors gone..
Posted By: delinkx

Re: i've done everything i can think of - 07/01/09 05:54

after including the code. u need to call the particular function from that .c file.
Posted By: gamingfan101

Re: i've done everything i can think of - 07/01/09 17:36

this is probably an easy answer question, but i couldnt find it in the tutorials or AUMs, how would i call this particular function?
Posted By: Ottawa

Re: i've done everything i can think of - 07/01/09 22:37

Hi!

By writing in your code the name of the function
my_robot_function ();
which is in your "robotshowcase.c"

I think that the include should be at the top of your main.c file
under all the other includes
and not in a function.
You where in fact trying to call the actions of your entity with the include
That's not the way to do it. You have to call the name of the function wink
Posted By: gamingfan101

Re: i've done everything i can think of - 07/02/09 00:24

Ok, i added the include to the top, and heres the code to call it, what should go in the place of the ???.


function robotswitch()
{
while (key_any) {wait (1); }
??????????????
}

i tried what i thought should go there, but it didnt work.
Posted By: gamingfan101

Re: i've done everything i can think of - 07/02/09 04:03

wouldnt the code be something like this?

function robotswitch()
{
while (key_any) {wait(1);}
goto(robotshowcase.c);
}

Please help
Posted By: MrGuest

Re: i've done everything i can think of - 07/02/09 10:28

heya
Code:
#include"robotshowcase.c";

function turn_on()
{
  set(nxthi_panel, SHOW);
}

PANEL* mainbutton1 =
{
bmap = gonorm;
pos_x = 10;
pos_y = 100;
button (0, 0, goclicked, gonorm, goover, robotswitch, NULL, NULL);
flags = OVERLAY | SHOW;
}

function robotswitch(var button_no, PANEL* panel_id)
{
  while(key_any){wait(1);}
  beep();
  turn_on();// display next panel? if that's what you're attempting
}


hope this helps
Posted By: gamingfan101

Re: i've done everything i can think of - 07/02/09 17:10

no, what im trying to do is switch to another program completely.
Posted By: Ottawa

Re: i've done everything i can think of - 07/02/09 20:03

Hi!

so your : goto(robotshowcase.c);
is not the correct way to do it.
You never call a .c file this way...you use #include
which you have already done.

Now what you will have to do if you want to change levels
is to call a level_load or
call the starting function

Is robotshowcase.c another level ?
Posted By: gamingfan101

Re: i've done everything i can think of - 07/02/09 20:08

no, it was just a temporary program until i got my real program finished. So right now lets work with my credits which i just finished. what im wanting to do is when i click on the credits button on my main menu, i want it to switch to my credits program. My credits program and my menu program are two completely different programs.
Posted By: Ottawa

Re: i've done everything i can think of - 07/02/09 20:35

Hi!

But the code for your, "what you call programs", is all together?

If you use #include then the code is a one unit program or a game
and you have one main.

Is this the situation?
Have you done or looked at the workshops?
Posted By: gamingfan101

Re: i've done everything i can think of - 07/02/09 20:40

yes i have looked at the workshops but i couldnt find what im looking for. and i mean, i have two completely different programs, "mainmenu.c" and "credits.c".
when i press the credits button in the mainmenu.c i want it to switch to the credits.c program.
Posted By: Ottawa

Re: i've done everything i can think of - 07/02/09 20:44

Hi!

Then you have to use level_load (thenewlevel).
and if you want to come back
in the other do the same level_load (the previous level)
Posted By: gamingfan101

Re: i've done everything i can think of - 07/02/09 20:52

oh, ok thanks!
Posted By: gamingfan101

Re: i've done everything i can think of - 07/02/09 20:57

ok, when i clicked the button to switch it says boxiecredits.c is a bad format. heres the code i used for it.

function creditsswitch()
{
while (key_any) {wait (1); }
level_load("boxiecredits.c");
}

and also when i have the inlcude"boxiecredits.c" both programs play at once and neither of them work.
Posted By: Ottawa

Re: i've done everything i can think of - 07/02/09 23:08

Hi!

You have to create a level and the extention of the title is .wmb
as : level_load (boxiecredits.wmb);

Quote:

From the manual.
Gamestudio uses several proprietary file formats that are similar to popular formats used by other engines, such as the engines by id Software. There are five Gamestudio-specific file formats: WMP for a level, WAD for level textures, WMB for a compiled level with BSP tree and lightmaps, MDL for animated models, and HMP for terrain.

.....
WMB files are created by WED's Map Compiler. They contain the content of the WMP file with included textures, BSP tree data, and lightmaps.

....


Use ...Help...search tab.... wmb
you will get 42 pages of information. Good reading smile
Posted By: boyax

Re: i've done everything i can think of - 07/03/09 04:09

try to look at this some sample code.

Code:
//---------------------------------
// main.c
//---------------------------------
#include <acknex.h>
#include <default.c>

#include "quit.c"  // other c file

//////////////////////////////////////////////////////////////////////
PANEL* main_pan =
{
  bmap = "main.pcx";
  pos_x = 250;     
  pos_y = 200;    
  button (250, 134, "quitclicked.pcx", "quitnormal.pcx", "quitover.pcx", quit_program, NULL, NULL); 
  flags = OVERLAY | VISIBLE;
}

////////////////////////////////////////////////////////////////////
function main()
{
  video_mode = 7; 
  screen_color.blue = 150;
  mouse_mode = 4;
}



Code:
//------------------------------------
// quit.c
//------------------------------------
function quit_program()
{
  while (key_any) { wait (1); }
  sys_exit(NULL);
}



hope that helps.
Posted By: gamingfan101

Re: i've done everything i can think of - 07/03/09 19:57

ok, thanks but i dont think thats quite what im looking for. I've got the #include part finished. But im having trouble calling it. When i click on the button in one script, i want it to take me to another. I was looking in the manual and i tried this, but i think i misunderstood something. Is there anyway this could work? Or am i going in the wrong direction?

function creditsswitch()
{
while (key_any) { wait (1); }
#include "%EXE_DIR%C:\Users\Charles\Desktop\litec programs\boxiecredits.c";
}

Im sorry if im missunderstanding all of this, please forgive me.
Posted By: MrGuest

Re: i've done everything i can think of - 07/03/09 20:52

really the wrong direction

#include adds the functions in your script to your main script when compiled, so really you shouldn't be only adding these if you're clicking on a specific button, either add them or don't

any command with # isn't used at runtime, only when compiling, so this really won't work. and, i'm not sure what you are meaning when you say program.


ideally you should have something like:

Code:
//main.c

#define PRAGMA_PATH "Models"
#define PRAGMA_PATH "Sounds"

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

#include "boxiecredits.c" //no ; required

void main(){
  //whatever needed here
}



Code:
//boxiecredits.c

function show_credits(){
  set(boxie, SHOW);
}



what exactly is the difference in your 2 scripts?
Posted By: gamingfan101

Re: i've done everything i can think of - 07/03/09 21:00

basically what im doing with my scripts is i have a main menu script, with three buttons on it. When i click on the credits button for example, it takes me to the credits script. So basically i have four scripts.
1) main menu
2) credits
3) main game
4) endurance (just another game type)
Posted By: MrGuest

Re: i've done everything i can think of - 07/03/09 21:10

just include all the script (though i don't know why you're seperating them all into seperate files?)

Code:
#include "main_menu.c"
#include "credits.c"
#include "main_game.c"
#include "endurance.c"

//then show your panel

PANEL* mainbutton1 =
{
  bmap = gonorm;
  pos_x = 10;
  pos_y = 100;
  button (0, 0, goclicked, gonorm, goover, robotswitch, NULL, NULL);
  flags = OVERLAY | SHOW;
}

then in each file have an init function

so //credits.c

function credits_init(){
  //do whatever you want done from here
  //probably start with hiding the panel?
  reset(mainbutton1, SHOW);
}

and change the name of your functions and structs so you'll be able to easily identify them later

hope this helps
Posted By: gamingfan101

Re: i've done everything i can think of - 07/03/09 21:18

ok, i almost have it. The only thing is that i want it to completely switch scripts, and im not sure how to call that in the function. There are no panels i want hidden, there are just 2 completely different c. scripts. (and i wanted the scripts seperated just for organization, that way if something in my credits messes up, ill go to that script, and so on.)
Posted By: DJBMASTER

Re: i've done everything i can think of - 07/04/09 00:16

you can't switch scripts. The script that starts is the one with the "main" function in. When you include other scripts the engine knows what's in them, so you can call functions and use resources in them, just by specifying their name, and the engine will automatically know where to find them.
Posted By: gamingfan101

Re: i've done everything i can think of - 07/04/09 00:38

ok, in that case, i would have to do everything in one script, would i use a goto function? when this button is pressed it goes to that part of the script?
Posted By: gamingfan101

Re: i've done everything i can think of - 07/04/09 00:54

ok, im really am sorry, i can tell im beginning to get annoying, so heres what i want to do, flat out. I have two scripts so far. "mainmenu.c" and "credits.c" when i click on this button below from the main menu, i want it to run the credits. Now considering i cant switch scripts, what would be the best way to do this? Thanks

PANEL* creditbutton3 =
{
bmap = goclicked;
pos_x = 10;
pos_y = 300;
button(0, 0, goclicked, gonorm, goover, NULL, NULL, NULL);
flags = OVERLAY | SHOW;
}
Posted By: DJBMASTER

Re: i've done everything i can think of - 07/04/09 01:44

In the button definition, just use the name of the function in the "credits.c" as if it were in the same script. Seperating scripts doesn't do anything apart from help you organise your code. They all get merged together when the game is ran as if it was all one big script.

So if in your "credits.c" script you have a function called StartCredits(), then just use "StartCredits", in your button definition and the engine will automatically find the function in the other script and run it.
Posted By: gamingfan101

Re: i've done everything i can think of - 07/04/09 02:04

ok, now there seems to be another problem, when i #include <credits.c> it tries to combine both scripts, so they both run at the same time, but the buttons dont work. ok heres both scripts, can you please tell me what im doing wrong? Probably a lot. Hopefully this will resolve the problems. I apologize for all of this.

menu:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <boxiecredits.c>

/////////////////////////////////////////////CURSOR////////////////////////////
BMAP* my_cursor = "gold_cursor.bmp";

/////////////////////////////////////////////MENU DEFINITIONS//////////////////
BMAP* headpic = "boxieheader.bmp";
BMAP* gonorm = "gonorm.bmp";
BMAP* goover = "goover.bmp";
BMAP* goclicked = "goclicked.bmp";
STRING* gameheader = "BOXIE";
STRING* main_str = "MAIN GAME";
STRING* endu_str = "ENDURANCE MODE";
STRING* cred_str = "CREDITS";
STRING* exit_str = "EXIT";
FONT* header_font = "ariel#80b";
FONT* options_font = "Bauhaus 93#40b";

//////////////////////////////////////////////PANELS//////////////////////////////

PANEL* menupicture =
{
bmap = headpic;
pos_x = 425;
pos_y = 230;
layer = 1;
flags = OVERLAY | SHOW;
}

PANEL* mainbutton1 =
{
bmap = gonorm;
pos_x = 10;
pos_y = 100;
button (0, 0, goclicked, gonorm, goover, NULL, NULL, NULL);
flags = OVERLAY | SHOW;
}

PANEL* endubutton2 =
{
bmap = goover;
pos_x = 10;
pos_y = 200;
button(0, 0, goclicked, gonorm, goover, NULL, NULL, NULL);
flags = OVERLAY | SHOW;
}

PANEL* creditbutton3 =
{
bmap = goclicked;
pos_x = 10;
pos_y = 300;
button(0, 0, goclicked, gonorm, goover, ???????, NULL, NULL);
flags = OVERLAY | SHOW;
}

PANEL* exitbutton4 =
{
bmap = gonorm;
pos_x = 10;
pos_y = 400;
button(0, 0, goclicked, gonorm, goover, quit_program, NULL, NULL);
flags = OVERLAY | SHOW;
}

/////////////////////////////////////////TEXTS///////////////////////////////
TEXT* headertxt =
{
pos_x = 300;
pos_y = 20;
string = gameheader;
font = header_font;
flags = SHOW;
}

TEXT* maintxt =
{
pos_x = 75;
pos_y = 110;
string = main_str;
font = options_font;
flags = SHOW;
}

TEXT* endurancetxt =
{
pos_x = 75;
pos_y = 210;
string = endu_str;
font = options_font;
flags = SHOW;
}

TEXT* creditstxt =
{
pos_x = 75;
pos_y = 310;
string = cred_str;
font = options_font;
flags = SHOW;
}

TEXT* exittxt =
{
pos_x = 75;
pos_y = 410;
string = exit_str;
font = options_font;
flags = SHOW;
}


/////////////////////////////////////////FUNCTIONS///////////////////////////

function main()
{
video_mode = 7;
mouse_map = my_cursor;
mouse_mode = 4;
media_loop("mainmusic.wav",NULL,100);
}

function quit_program()
{
while (key_any) { wait (1); }
sys_exit(NULL);
}




credits:
///////////////////////////////
#include <acknex.h>
#include <default.c>

//////////////////////////////////////////////CURSOR///////////////
BMAP* cursor = "gold_cursor.bmp";

////////////////////////////////////////////////////////////SOUNDS/////////////////////
SOUND* credits_snd = "credits.wav";

/////////////////////////////////////////////BMAP DEFINITIONS////////////////////////////
BMAP* creditbground = "creditsbground.bmp";
BMAP* creditbutt = "creditback.bmp";

/////////////////////////////////////////////PANELS//////////////////////////////////
PANEL* credbground =
{
bmap = creditbground;
pos_x = 20;
pos_y = 10;
layer = 1;
flags = OVERLAY | SHOW;
}

////////////////////////////////////////////////STRING/FONT DEFINITIONS////////////////////
STRING* backbutton = "BACK TO MAIN MENU";
STRING* opening = "AN ATARI TODAY PRODUCTION";
STRING* boxieopen = "BOXIE";
STRING* owner = "OWNER: CHARLES BAILEY";
STRING* character = "CHARACTER DESIGN: CHARLES BAILEY";
STRING* level = "LEVEL DESIGNER: CHARLES BAILEY";
STRING* object = "PROGRAMMER: CHARLES BAILEY";
STRING* instru = "HIT 'BACK TO MAIN MENU' TO RETURN";
FONT* header_font = "ariel#20b";
FONT* options_font = "Bauhaus 93#40b"; //used for both main menu options and the credits opener
FONT* credits_font = "Bauhaus 93#30b"; //used for all other texts in the credits
FONT* boxiestarter_font = "ariel#100b"; //used for the boxieopener only

//////////////////////////////////////////////////////TEXTS////////////////////////////
TEXT* opening_txt =
{
pos_x = 90;
pos_y = 175;
string = opening;
font = options_font;
layer = 3;
}

TEXT* boxieopener_txt =
{
pos_x = 200;
pos_y = 250;
string = boxieopen;
font = boxiestarter_font;
layer = 3;
}

TEXT* owner_txt =
{
pos_x = 100;
pos_y = 300;
string = owner;
font = credits_font;
layer = 3;
}

TEXT* character_txt =
{
pos_x = 250;
pos_y = 150;
string = character;
font = credits_font;
layer = 3;
}

TEXT* level_txt =
{
pos_x = 275;
pos_y = 400;
string = level;
font = credits_font;
layer = 3;
}

TEXT* object_txt =
{
pos_x = 220;
pos_y = 50;
string = object;
font = credits_font;
layer = 3;
}

TEXT* instructions_txt =
{
pos_x = 90;
pos_y = 175;
string = instru;
font = credits_font;
layer = 3;
}
////////////////////////////////////////////////////BUTTONS////////////////////////////////
TEXT* back =
{
pos_x = 275;
pos_y = 20;
string = backbutton;
font = header_font;
layer = 2;
flags = SHOW;
}

PANEL* backbutt =
{
bmap = creditbutt;
pos_x = 275;
pos_y = 10;
button(0, 0, creditbutt, creditbutt, creditbutt, quit_program, NULL, NULL);
layer = 3;
flags = OVERLAY | SHOW;
}


////////////////////////////////////////////////FUNCTIONS////////////////////////
function main()
{
video_mode = 7;
mouse_map = cursor;
mouse_mode = 4;
snd_play(credits_snd, 100, 0);
media_play("mainmusic.wav",NULL,90);
wait(-5);
opening_txt.flags = SHOW;
wait(-4);
boxieopener_txt.flags = SHOW;
wait(-4);
opening_txt.flags = 0;
boxieopener_txt.flags = 0;
wait(-2);
screen_color.red = 135;
screen_color.green = 62;
screen_color.blue = 36;
owner_txt.flags = SHOW;
wait(-4);
owner_txt.flags = 0;
screen_color.red = 0;
screen_color.green = 62;
screen_color.blue = 36;
character_txt.flags = SHOW;
wait(-4);
character_txt.flags = 0;
screen_color.blue = 0;
screen_color.green = 88;
screen_color.red = 88;
level_txt.flags = SHOW;
wait(-4);
level_txt.flags = 0;
screen_color.red = 177;
screen_color.green = 239;
screen_color.blue = 135;
object_txt.flags = SHOW;
wait(-4);
object_txt.flags = 0;
screen_color.blue = 0;
screen_color.red = 0;
screen_color.green = 0;
instructions_txt.flags = SHOW;
}

function quit_program()
{
while (key_any) { wait (1); }
sys_exit(NULL);
}


Thanks a lot!


Posted By: DJBMASTER

Re: i've done everything i can think of - 07/04/09 03:56

PANEL* creditbutton3 =
{
bmap = goclicked;
pos_x = 10;
pos_y = 300;
button(0, 0, goclicked, gonorm, goover, ???????, NULL, NULL);
flags = OVERLAY | SHOW;
}

That will give you errors, replace '???????' with NULL or a different function.

Apart from that i can't see much wrong with it. Which button is causing the problem?
Posted By: gamingfan101

Re: i've done everything i can think of - 07/04/09 04:12

no, i was trying to ask what should go in the ????? place. Im sorry, i didnt make that very clear. And the button works ok, the problem is the function. I want the credit script to run when i press the button in the main menu script. But since i cant switch scripts i need to know how to set up the functions from the scripts above. Thanks you
Posted By: the_mehmaster

Re: i've done everything i can think of - 07/04/09 04:38

you've got 2 main() functions! you cannot have 2 main() functions otherwise the second overrides the first!

I have another solution for you though. you should publish both your scripts separately, then put them both in the same folder. One of the scripts should have an externel .exe execute function (exec(STRING* program, STRING* options)) inside that runs the other one. same in the other script.
Hope this helps..
Posted By: MrGuest

Re: i've done everything i can think of - 07/04/09 09:48

there's no point in having 2 programs for this,
Originally Posted By: gamingfan101
ok, im really am sorry, i can tell im beginning to get annoying
and you're not being annoying laugh

you need to create unique functions for what you're trying to do
so in your credits functions you still have all the definitions you need, but youu just need to set which TEXT and PANEL visible depending on what you're doing

so you can put all your PANELs and TEXT in a seperate scripts like you have, then have a function that toggles what you need

so on buttonclick of creditbutton3 have toggle show_credits()

then
Code:
function show_credits() set(opening_txt, SHOW);

etc... hope this helps
Posted By: the_mehmaster

Re: i've done everything i can think of - 07/04/09 11:07

Quote:
there's no point in having 2 programs for this

I realise that, and that's not how i would do it.
It's just that that's the simplest method using what he already has.

In fact, the method i actually use is more like yours.
Posted By: gamingfan101

Re: i've done everything i can think of - 07/04/09 18:52

ok, i've got the functions and all, but i cant test them because everytime i use the #include "credits.c" they combine the two scripts and none of the buttons will work. I think its because of something missing in my main function. Here it is below, what else should go into it? These arent levels so level_load will not work.

function main()
{
video_mode = 7;
mouse_map = my_cursor;
mouse_mode = 4;
media_loop("mainmusic.wav",NULL,100);
}

thanks again
Posted By: Ottawa

Re: i've done everything i can think of - 07/04/09 23:28

Hi!

This is good reading wink

All your code is panels and text.
Put everything under one title and one main
then play with "show"
If you touch this button then show this...."function"..
The function would hold the name of the panel and set show...it would
also set the other panels to no---show
Posted By: MrGuest

Re: i've done everything i can think of - 07/05/09 00:16

and in your original code, remove the SHOW flags from items you don't want do 'show' on startup
Posted By: gamingfan101

Re: i've done everything i can think of - 07/05/09 01:37

ok, thank you so much, i've got this part working now. Once again thank you so much for your patience.
Posted By: gamingfan101

Re: i've done everything i can think of - 07/05/09 01:45

ok, one more question, when i stop my music that i have playing bt media_play. What would i use to stop it? media_stop doesnt work.
Posted By: DJBMASTER

Re: i've done everything i can think of - 07/05/09 04:48

media_stop should work fine, just make sure you have a handle to the sound that you are playing...

Code:
var handle;
handle = media_loop("music.mp3",null,50);
...
media_stop(handle);


Posted By: not_me

Re: i've done everything i can think of - 07/05/09 06:02

Originally Posted By: Ottawa
Hi!

By writing in your code the name of the function
my_robot_function ();
which is in your "robotshowcase.c"

I think that the include should be at the top of your main.c file
under all the other includes
and not in a function.
You where in fact trying to call the actions of your entity with the include
That's not the way to do it. You have to call the name of the function wink



I always thought that if you defined an #include in a function that it becomes a local function. and #includes defined outside of functions are global...but i think i may be wrong...if im right..then he would just define the #include before the action hes calling. that way it has its file to call from...thats my thinking though.
Posted By: gamingfan101

Re: i've done everything i can think of - 07/05/09 14:42

ok, i've got my credits and buttons working now. One minor problem that comes up though. When i go to the credits, I've got one text that pops up, then dissapears and another pops up. When i click on the main menu from there the main menu pops back up. The problem is that the credits are still playing in the background. How would i set it to completelt stop?
Posted By: gamingfan101

Re: i've done everything i can think of - 07/05/09 17:17

ok, im about to ask a question that is probably easily answered, but im using the free version of lite-c, so after a certain point everything in the workshops start using WED so i cant use those workshops. Thats why i need help with this. In my game, you are on the ground moving side to side to avoid these spikes falling from the ceiling. what code would i use to alternate between two panels when i press either the curr or the curl? Please help. and i have a few more questions if you'd be willing to help.
Posted By: MrGuest

Re: i've done everything i can think of - 07/05/09 19:20

you're using just 1 panel, but want it to move left and right? or making a panel flip from left to right? or 2 similar panels that appear in different places? or 2 totally different panels?

do you have a screen shot of what you're trying to create?

Code:
void move_left(){
//...
}

void move_right(){
//...
}

void main(){
//...
  on_cul = move_left;
  on_cur = move_right;
}


Posted By: gamingfan101

Re: i've done everything i can think of - 07/06/09 15:24

i do not have a screen shot, but what i want it to do is when i press the curl, one panel dissapears, and another pops up, then that one dissapears and the first one pops up. I want it do this while im holding the button.
Posted By: paracharlie

Re: i've done everything i can think of - 07/06/09 18:31

I hate to say go read the lite-c samples because I hate when someone tells me to do that but,, you really need to do that. I learned how to make this happen by reading the lite-c tutorials. Everything your asking for is in there. If I can learn believe me you can too.
© 2024 lite-C Forums