increase map and scroll size and keep everything in its place?

Started by MisterN, July 04, 2012, 01:55:13 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MisterN

...
the level editor menu should be on it. ill email you it (again).
werg

MisterN


DECLARE FUNCTION string textinput(); // important to declare functions that return strings.
END


is declared


PROCESS menu();
PRIVATE
//directory reading
int dir_id;
string dir_result[9]; //used to show what files are where in the menu
string directory = ".\@leveleditor\*.lev";

byte i=0;

//menu text
string menu_text[9];

string file_command_text[9];
string file_text[9];


string temp_string;

byte text_restore = true;

byte file_loaded = false;

byte new_dialog = false;
byte new_file_panel;

BEGIN
//open the directory where the level files are located
dir_id=diropen(directory);
//the console will produce this message
say("Reading the directory: "+directory);

new_file_panel = rgb(0,0,255);

    LOOP
        //count the first 9 files
        if(i<10)
            dir_result[i]=dirread(dir_id);
            say(i + ". " + dir_result[i]);
            i++;
        end
       
        //display the text on the program itself
        if(text_restore==true)
            //write a caption at the top of the screen
            write(0,1,0,0,"********************FILES********************");
           
            //display all the files shown
            file_text[0] =  write(0,16,16,0,"1. "); file_command_text[0] =  write_string(0,32,16,0,&dir_result[0]);
            file_text[1] =  write(0,16,32,0,"2. "); file_command_text[1] =  write_string(0,32,32,0,&dir_result[1]);
            file_text[2] =  write(0,16,48,0,"3. "); file_command_text[2] =  write_string(0,32,48,0,&dir_result[2]);
            file_text[3] =  write(0,16,64,0,"4. "); file_command_text[3] =  write_string(0,32,64,0,&dir_result[3]);
            file_text[4] =  write(0,16,80,0,"5. "); file_command_text[4] =  write_string(0,32,80,0,&dir_result[4]);
            file_text[5] =  write(0,16,96,0,"6. "); file_command_text[5] =  write_string(0,32,96,0,&dir_result[5]);
            file_text[6] = write(0,16,112,0,"7. "); file_command_text[6] = write_string(0,32,112,0,&dir_result[6]);
            file_text[7] = write(0,16,128,0,"8. "); file_command_text[7] = write_string(0,32,128,0,&dir_result[7]);
            file_text[8] = write(0,16,144,0,"9. "); file_command_text[8] = write_string(0,32,144,0,&dir_result[8]);
            file_text[9] = write(0,16,160,0,"0. "); file_command_text[9] = write_string(0,32,160,0,&dir_result[9]);
           
            //divide the files shown from the menu commands
            write(0,1,176,0,"*********************************************");
           
            //display the menu commands
            menu_text[0] = write(0,16,192,0,"Press the # next to the file to load it");
            menu_text[1] = write(0,16,208,0,"LEFT/RIGHT keys: turn page");
            menu_text[2] = write(0,16,224,0,"ESC: close program");
            menu_text[3] = write(0,160,224,0,"N: new level");
           
            //make text_restore false so that the text isnt constantly being written
            text_restore=false;
        end
       
        //once a file has been loaded, this shall kill itself
        if(file_loaded==true)
            manage_level();
            delete_text(all_text);
            delete_draw(0);
            write(0,160,120,1,"LOADING");
            signal(id,s_kill);
        end
       
        if(key(_n))
            if(new_dialog==false)
                //Draw the dialog box
                    drawing_color(new_file_panel);
                    drawing_z(-1);
                    draw_box(80,60,240,160);
                //Draw the text on the dialog box
                    text_z = -2; //this way its above the dialog box
                    write(0,90,70,0,"NAME: ");
                    new_dialog = true;
                //Start up the text typer
                    temp_string = textinput();                // Nicolas, where does the input text go?
                                                // haven't you forgotten something here?
                                                // see remark in the textinput function.
                                                // tip: look in dykodialogs code for functions
                                                // that return strings, because they have to be
                                                // declared first (for compiler reasons).

            else
                //delete the dialog box
                    delete_text(all_text);
                    delete_draw(0);
                    new_dialog = false;
                //restore the text
                    text_restore = true;
            end
            while(key(_n))
                 frame;
            end
        end
       
        if(key(_enter))
            if(new_dialog==true)
           
                level.filename=temp_string; // !!!!!!
           
                say("textinput_outputstring = "+temp_string);
                say("level.filename= " +level.filename);
           
                //save(level.filename,level); //??
                load(level.filename,level);
               
                say("loading new level: "+level.filename);
               
                if(file_loaded==false)
                    file_loaded=true;
                end
            end
        end
       
        //load levels with the corresponding keys 1,2,3,4,5,6,7,8,9,0
        if(new_dialog==false)
            if(key(_1))
                if(file_exists(dir_result[0]))
                    if(file_exists(dir_result[0]))
                        level.filename = dir_result[0];
                        say(dir_result[0]+" has been loaded");
                        if(file_loaded==false)
                            file_loaded = true;
                        end
                    end
                else
                    say("ERROR: File does not exist");
                end
                while(key(_1))frame;end
            end
           
            if(key(_2))
                if(file_exists(dir_result[1]))
                    if(file_exists(dir_result[1]))
                        level.filename = dir_result[1];
                        say(dir_result[1]+" has been loaded");
                        if(file_loaded==false)
                            file_loaded = true;
                        end
                    end
                else
                    say("ERROR: File does not exist");
                end
                while(key(_2))frame;end
            end
           
            if(key(_3))
                if(file_exists(dir_result[2]))
                    if(file_exists(dir_result[2]))
                        level.filename = dir_result[2];
                        say(dir_result[2]+" has been loaded");
                        if(file_loaded==false)
                            file_loaded = true;
                        end
                    end
                else
                    say("ERROR: File does not exist");
                end
                while(key(_3))frame;end
            end
           
            if(key(_4))
                if(file_exists(dir_result[3]))
                    if(file_exists(dir_result[3]))
                        level.filename = dir_result[3];
                        say(dir_result[3]+" has been loaded");
                        if(file_loaded==false)
                            file_loaded = true;
                        end
                    end
                else
                    say("ERROR: File does not exist");
                end
                while(key(_4))frame;end
            end
           
            if(key(_5))
                if(file_exists(dir_result[4]))
                    if(file_exists(dir_result[4]))
                        level.filename = dir_result[4];
                        say(dir_result[4]+" has been loaded");
                        if(file_loaded==false)
                            file_loaded = true;
                        end
                    end
                else
                    say("ERROR: File does not exist");
                end
                while(key(_5))frame;end
            end
           
            if(key(_6))
                if(file_exists(dir_result[5]))
                    if(file_exists(dir_result[5]))
                        level.filename = dir_result[5];
                        say(dir_result[5]+" has been loaded");
                        if(file_loaded==false)
                            file_loaded = true;
                        end
                    end
                else
                    say("ERROR: File does not exist");
                end
                while(key(_6))frame;end
            end
           
            if(key(_7))
                if(file_exists(dir_result[6]))
                    if(file_exists(dir_result[6]))
                        level.filename = dir_result[6];
                        say(dir_result[6]+" has been loaded");
                        if(file_loaded==false)
                            file_loaded = true;
                        end
                    end
                else
                    say("ERROR: File does not exist");
                end
                while(key(_7))frame;end
            end
           
            if(key(_8))
                if(file_exists(dir_result[7]))
                    if(file_exists(dir_result[7]))
                        level.filename = dir_result[7];
                        say(dir_result[7]+" has been loaded");
                        if(file_loaded==false)
                            file_loaded = true;
                        end
                    end
                else
                    say("ERROR: File does not exist");
                end
                while(key(_8))frame;end
            end
           
            if(key(_9))
                if(file_exists(dir_result[8]))
                    if(file_exists(dir_result[8]))
                        level.filename = dir_result[8];
                        say(dir_result[8]+" has been loaded");
                        if(file_loaded==false)
                            file_loaded = true;
                        end
                    end
                else
                    say("ERROR: File does not exist");
                end
                while(key(_9))frame;end
            end
           
            if(key(_0))
                if(file_exists(dir_result[9]))
                    if(file_exists(dir_result[9]))
                        level.filename = dir_result[9];
                        say(dir_result[9]+" has been loaded");
                        if(file_loaded==false)
                            file_loaded = true;
                        end
                    end
                else
                    say("ERROR: File does not exist");
                end
                while(key(_0))frame;end
            end
        end
       
    FRAME;END
END

function string textinput();
private
    string internal_string;
    int t;
    int t2;
    byte last_ascii;
begin

    // show what you type in top left corner
    txtid = write_string(0,130,70,0,&internal_string);

    // clean the string
    internal_string = "";

    // get input from the user
    // pressing enter will end the loop
    loop
        if(ascii!=0&&last_ascii==ascii) // check if a key is pressed and if the same key
                                        // was pressed last frame
            if(t==0||t>fps/6) // check if the key was just pressed or it has been pressed
                              // for 0.25 seconds
                if(t==0||t2>fps/30) // check if the key was just pressed or it has been pressed
                                    // for the last 0.03 seconds
                    t2=0;
                    switch(ascii) // handle input
                        case 8: //backspace
                            internal_string = substr(internal_string,0,len(internal_string)-1);
                        end
                        case 13: //enter
                            break;
                        end
                        default: //addkey
                            internal_string+=chr(ascii);
                        end
                    end
                end
                t2++;
            end
            t++;
        else
            t = t2 = 0; // reset
        end
        last_ascii = ascii;
    frame;
    end

   
    // print the filename on the console
    say("filename typed: "+internal_string);
   
    // delete the text used
    //level.filename = &txtid;    // no way! bad idea. you better move this line into the calling function.
                                // i.e. level.filename = textinput(); be sure to declare this "textinput"
                                // function first, or it won't return a string but an int instead!
                               
                                // the crash is probably caused by the incorrect data type that was returned.
                                // another oddity is that the map is created with w=0 and h=0, that can't
                                // be right eh?
                               
                                // txtid is an it and not the string!
                               

    // return the typed string (as a string data of course. function must be declared, see remark in
    // in game_leveleditor.prg!)
    RETURN (internal_string); 
   
end


is the code that uses it

I keep getting this error in the console (look at the picture)
werg

SplinterGU


splinter@splinter:~/tmp> bgdc str.prg
BGDC 1.0.0 (Jul  9 2012 06:56:36)
Bennu Game Development Compiler

Copyright � 2006-2012 SplinterGU (Fenix/BennuGD)
Copyright � 2002-2006 Fenix Team (Fenix)
Copyright � 1999-2002 Jos� Luis Cebri�n Pag�e (Fenix)

/home/splinter/tmp/str.prg:42: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:53: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:53: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:54: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:54: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:55: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:55: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:56: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:56: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:57: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:57: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:58: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:58: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:59: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:59: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:60: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:60: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:61: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:61: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:62: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:62: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:68: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:69: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:70: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:71: warning: implicit conversion (INTEGER to STRING).
/home/splinter/tmp/str.prg:120: error: Unknown identifier ( token error: "LEVEL" ).


bgdc.imp


mod_string
mod_string
mod_text
mod_proc
mod_key
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

MisterN

werg

handsource-dyko

I guess you forgot to incluse some modules? I must admit, I haven't check for that because it's kinda obvious. :-[

MisterN

werg

SplinterGU

I'm only want test your code... but your code no compile... and not a mod_text error... you no have defined level (var struct) but use it...

please, if you need help, then post a complete a working (compilable) code.

thanks.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

MisterN

I sent you an email (i clicked the button under your name) check it and send a message to the email i currently use and I will send you the game.
werg

SplinterGU

Download Lastest BennuGD Release: http://www.bennugd.org/node/2

MisterN

Yeah I sent you an email from another address with a .zip file attacked to it. It should be @engine_7_16_2012.zip
werg

MisterN

I changed stuff like you said but im getting INTERGER to STRING errors and I get this

werg

SplinterGU

Download Lastest BennuGD Release: http://www.bennugd.org/node/2

SplinterGU

I think that last version don't run... libpng15-15.dll is missing... I think
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

SplinterGU

Download Lastest BennuGD Release: http://www.bennugd.org/node/2

MisterN

Oh I was gone at the store. Is there something I need to do?
werg