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.

SplinterGU

sure that you will have a crash... because you can't create a write_string on a private/local variable in a process and when you exit from this process no delete this text...

you have this


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


you must have this


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!


    delete_text(txtid); // <<< THIS YOU MUST DO !!!!

    // 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
Download Lastest BennuGD Release: http://www.bennugd.org/node/2


MisterN

wait, the levels being made will not load, even when put in the directory. hmmmm
werg

SplinterGU

man, really you have a mess in your project...

you show a list of files in folder "@leveleditor", but when you want save/load them, you save/load them from/to current directory (I mean, from/to dcb directory) and you have example_1.lev and example_2.lev in current directory too... you must add "@leveleditor/" to all files that you want load/save...

man, clean your project directory.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

MisterN

what should i do with all the .dll's and stuff? put them in another directory?
werg

SplinterGU

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