Bennu Game Development

English Forums => Helpdesk => Topic started by: MisterN on July 04, 2012, 01:55:13 AM

Title: increase map and scroll size and keep everything in its place?
Post by: MisterN on July 04, 2012, 01:55:13 AM
This is the process that renders the level, theres no other process that renders it in any way.

/* Process that renders a map. It creates a new map in memory for drawing blocks onto, and uses that */
/* map in a scroll.                                                                                */

PROCESS rendermap(); // can be a function. you don't have use processes for everything.

PRIVATE

// x and y values for plotting the blocks
int temp_x;
int temp_y;

BEGIN

 
    // create a new map in memory
    scroll_map=map_new(level.width, level.height,16);
    say("creating map: w="+level.width+" h="+level.height);
   
    // start a scroll : scroll no.=0, file=0, foreground=scroll_map, background=0, region=0, locking indicator=0
    start_scroll(0,0,scroll_map,0,0,0);
    say("scroll started");
   
   
    // put the player
    player_id=player(level.player_x,level.player_y+4);
    say("putting player: x="+level.player_x+" y="+level.player_y);

   
   
    // put the blocks
    FOR (tile_count_x=0; tile_count_x<TILE_DIMX; tile_count_x+=1)
           
        FOR (tile_count_y=0; tile_count_y<TILE_DIMY; tile_count_y+=1)
   
            IF (level.tile[tile_count_x][tile_count_y].used==TRUE)
           
                // make sure that the tiles are put on the right place
                temp_x=(tile_count_x*block_size)+8;
                temp_y=(tile_count_y*block_size)+8;
                   
                block_graph=level.tile[tile_count_x][tile_count_y].kind;
       
                //map_xputnp ( <INT destinationFileID> , <INT destinationGraphID> , <INT originFileID> , <INT originGraphID> , <INT x> , <INT y> , <INT angle> , <INT scale_x> , <INT scale_y> , <INT blitflags> )
               
                // put a block into the scroll
                map_xputnp(0,scroll_map,block_fpg,block_graph,temp_x,temp_y,0,100,100,0);
                say("plotting tile: "+tile_count_x+" , "+tile_count_y);
            END
        END
    END
   
   
    // load fpg files
        //pellet
        IF(MAX_PEL>0)
            if(collec_fpg==0)
                collec_fpg = load_fpg("collectibles.fpg");
            end
        ELSE
            unload_fpg(collec_fpg);
        END
        //enemy_a
        IF(MAX_ENE_A>0)
            enemy_a_fpg = load_fpg("enemy_a.fpg");
        ELSE
            unload_fpg(enemy_a_fpg);
        END
        //enemy_b
        IF(MAX_ENE_B>0)
            enemy_b_fpg = load_fpg("enemy_b.fpg");
        ELSE
            unload_fpg(enemy_b_fpg);
        END
        //enemy_c
        IF(MAX_ENE_C>0)
            enemy_c_fpg = load_fpg("enemy_c.fpg");
        ELSE
            unload_fpg(enemy_c_fpg);
        END
        //enemy_d
        IF(MAX_ENE_D>0)
            enemy_d_fpg = load_fpg("enemy_d.fpg");
        ELSE
            unload_fpg(enemy_d_fpg);
        END
        //enemy_e
        IF(MAX_ENE_E>0)
            enemy_e_fpg = load_fpg("enemy_e.fpg");
        ELSE
            unload_fpg(enemy_e_fpg);
        END
        //enemy_f
        IF(MAX_ENE_F>0)
            enemy_f_fpg = load_fpg("enemy_f.fpg");
        ELSE
            unload_fpg(enemy_f_fpg);
        END
   

    // put the pellets
    FOR (count=0; count<MAX_PEL; count+=1)
   
        IF (level.obj_pellet[count].used==TRUE)
            obj_pellet_id[count]=pellet(level.obj_pellet[count].x,level.obj_pellet[count].y,count);
            say("putting pellet: "+count+" x="+level.obj_pellet[count].x+" y="+level.obj_pellet[count].y+" used: "+level.obj_pellet[count].used);
        END
    END
   
    // put the healthkits
    FOR (count=0; count<MAX_HKT; count+=1)
   
        IF (level.obj_healthkit[count].used==TRUE)
            obj_healthkit_id[count]=healthkit(level.obj_healthkit[count].x,level.obj_healthkit[count].y,count);
            say("putting healthkit: "+count+" x="+level.obj_healthkit[count].x+" y="+level.obj_healthkit[count].y+" used: "+level.obj_healthkit[count].used);
        END
    END
   
    // put the enemy A's
    FOR (count=0; count<MAX_ENE_A; count+=1)
   
        IF (level.obj_enemy_a[count].used==TRUE)
            obj_enemy_a_id[count]=enemy_a(level.obj_enemy_a[count].x,level.obj_enemy_a[count].y,level.obj_enemy_a[count].gravity,count);
            say("putting enemy A: "+count+" x="+level.obj_enemy_a[count].x+" y="+level.obj_enemy_a[count].y+" used: "+level.obj_enemy_a[count].used);
        END
    END
   
    // put the enemy B's
    FOR (count=0; count<MAX_ENE_B; count+=1)
       
        IF (level.obj_enemy_b[count].used==TRUE)
            obj_enemy_b_id[count]=enemy_b(level.obj_enemy_b[count].x,level.obj_enemy_b[count].y,count);
            say("putting enemy B: "+count+" x="+level.obj_enemy_b[count].x+" y="+level.obj_enemy_b[count].y+" used: "+level.obj_enemy_b[count].used);
        END
    END
   
    // put the enemy C's
    FOR (count=0; count<MAX_ENE_C; count+=1)
       
        IF (level.obj_enemy_c[count].used==TRUE)
            obj_enemy_c_id[count]=enemy_c(level.obj_enemy_c[count].x,level.obj_enemy_c[count].y,level.obj_enemy_c[count].direction,count);
            say("putting enemy C: "+count+" x="+level.obj_enemy_c[count].x+" y="+level.obj_enemy_c[count].y+" used: "+level.obj_enemy_c[count].used);
        END
    END
   
    // put the enemy D's
    FOR (count=0; count<MAX_ENE_D; count+=1)
       
        IF (level.obj_enemy_d[count].used==TRUE)
            obj_enemy_d_id[count]=enemy_d(level.obj_enemy_d[count].x,level.obj_enemy_d[count].y,count);
            say("putting enemy D: "+count+" x="+level.obj_enemy_d[count].x+" y="+level.obj_enemy_d[count].y+" used:
            "+level.obj_enemy_d[count].used);
        END
    END
   
    // put the enemy E's
    FOR (count=0; count<MAX_ENE_E; count+=1)
       
        IF (level.obj_enemy_e[count].used==TRUE)
            obj_enemy_e_id[count]=enemy_e(level.obj_enemy_e[count].x,level.obj_enemy_e[count].y,count);
            say("putting enemy E: "+count+" x="+level.obj_enemy_e[count].x+" y="+level.obj_enemy_e[count].y+" used:
            "+level.obj_enemy_e[count].used);
        END
    END
   
    // put the enemy F's
    FOR (count=0; count<MAX_ENE_F; count+=1)
       
        IF (level.obj_enemy_d[count].used==TRUE)
            obj_enemy_f_id[count]=enemy_f(level.obj_enemy_f[count].x,level.obj_enemy_f[count].y,count);
            say("putting enemy F: "+count+" x="+level.obj_enemy_f[count].x+" y="+level.obj_enemy_f[count].y+" used:
            "+level.obj_enemy_f[count].used);
        END
    END

END // end of map rendering process


Heres some stuff I want to be able to do now (if you know the answer to one of the questions just put the number before your sentence/paragraph  :) ):
1. Ive seen examples of stuff working like this but i want to know how i can type in the program itself, and im assuming what I type is a string? well how can I make that a variable?

2. I want to be able to change the size of level.width and level.height through a panel that lets me change the variables of them (dont worry about the panel, i just gotta know about the variable end). The problem is, the tiles are loaded on the map, and the thing I tried made a new map, so it clears all your hard work (minus the processes on the map, those are fine). Heres a question to my question, how can I change the map size and it will work all fine and dandy in the scroll and all that stuff?

Thanks
Title: Re:increase map and scroll size and keep everything in its place?
Post by: handsource-dyko on July 04, 2012, 02:36:34 PM
Since I know how the level map rendering works in your engine (it's a fixed size array), I assume you want TILE_DIMX and TILE_DIMY to be variables?

That would require a completely different approach for saving the data (you need a dynamic array) wich is kinda tricky. It's not something you
can quickly implement, it requires a fair bit of manual memory managment designing first. Also the Load/Save functions are not suitable for data of unknown sizes. Basically it would have be changed to using the manual functuions.

It's not impossible, but it just takes a fair bit of time to implement and you have to make the tradeoff if you really need variable map sizes v.s. the design and test time to implement it. Even with malvado I didn't bother with variable map sizes (I simply choose a constrained maximum). In fact, a lot of engines use fixed (maximum) map sizes. Also the leveleditor and rendering logic becomes more eleborate if you want this.

Anyway I don't recommend it, maybe some other people have different thoughts on this (or suggestions).

B.tw  to clarify things for the others, what do you want with strings? Is it for an interface with an external dialog program? Maybe you could explain a bit more about your intend. ???
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 04, 2012, 03:30:18 PM
Not necessarily TILE_DIMX and TILE_DIMY, I can easily set both of those to say 3000 and I the game will still work just fine. I mean changing level.width and level.height while inside the editor and it adds more room to the map.
Title: Re:increase map and scroll size and keep everything in its place?
Post by: handsource-dyko on July 04, 2012, 03:37:26 PM
Oh, inside the editor. I see. Well, it still requires the map to be re-rendered (before it resizes it's current state has to be saved first).
Possible, as long as it's simply a resize of the viewport (because the map size is fixed in terms amount of tiles in x and y directions) I assume you
simply want the scroll bitmap size to change?
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 04, 2012, 08:05:26 PM
Yeah I want to be able to change the scroll_map size at any given moment inside the editor
Title: Re:increase map and scroll size and keep everything in its place?
Post by: handsource-dyko on July 05, 2012, 08:22:28 AM
Then you have unload the old map first and create a new one with the new size, and re-render the tiles. Unloading the old map is important in order to prevent memory leaks. Also the scroll must be refreshed, by stopping it first and then starting a new scroll again.
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 05, 2012, 04:49:37 PM
can you show me how i can unload the map and place every tile again?
Title: View files in a directory (certain format) and chose them
Post by: MisterN on July 06, 2012, 02:25:28 AM
Ok so I got that working now but now I want to know this part.

*How can I view all the files in a certain directory of a certain format? (like you can in programming languages like C# and stuff with the openfiledialog) i'm not asking for an open file dialog, ill have it done in game. ill use some text and stuff, ill get it to work in this picture:
(http://forum.bennugd.org/index.php?action=dlattach;topic=3121.0;attach=2448)

For example, I want it to only show me the format *.lvl, and in alpabetical order. And if there are more than (say 16), then a "page" will be made, that i can navigate with the arrow keys. can you show me code for this? thanks

Also: I want to be able to type string variables in the game, how can I do that?
Title: Re:increase map and scroll size and keep everything in its place?
Post by: handsource-dyko on July 06, 2012, 02:42:07 PM
You can use the glob() function and readdir() for this purpose. Bennu doesn't have a textinput function, but can make your own. Here's an example: http://wiki.bennugd.org/index.php?title=Tutorial:Textinput (http://wiki.bennugd.org/index.php?title=Tutorial:Textinput)

You could also opt for an oldskool textinput system with a grid of characters and a selection cursor.
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 07, 2012, 03:20:45 AM
I noticed that every key (like tab and esc) also had their own character, how can I make it so that they dont?
Title: Re:increase map and scroll size and keep everything in its place?
Post by: handsource-dyko on July 07, 2012, 09:30:53 AM
Simply ignore them. In fact, each key on the keyboard has it's on scancode.
Title: help with text typing (ill upload the .prg's)
Post by: MisterN on July 08, 2012, 06:07:50 AM
im confused, everything should worked, the problem is with the string txtid. this is just the level editor. take a look inside the leveleditor_menu.prg, thats where all the magic happens. Can you tell me why its crashing upon me pressing enter and not making the level? Thanks
Title: Re:increase map and scroll size and keep everything in its place?
Post by: handsource-dyko on July 10, 2012, 02:06:35 PM
How do I enter the menu? ???
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 10, 2012, 04:33:31 PM
the menu should be there when you boot up the leveleditor
(http://forum.bennugd.org/index.php?action=dlattach;topic=3121.0;attach=2451)
and dont tell me that the .prg's in that zip file dont have the menu, i just tested it
Title: Re:increase map and scroll size and keep everything in its place?
Post by: handsource-dyko on July 11, 2012, 02:45:55 PM
Do I need to do anything special? I'm getting this instead (see image):



(http://forum.bennugd.org/index.php?action=dlattach;topic=3121.0;attach=2453)
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 11, 2012, 04:25:35 PM
...
the level editor menu should be on it. ill email you it (again).
Title: weird error
Post by: MisterN on July 15, 2012, 04:25:01 PM

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)
(http://forum.bennugd.org/index.php?action=dlattach;topic=3121.0;attach=2456)
Title: Re:increase map and scroll size and keep everything in its place?
Post by: SplinterGU on July 15, 2012, 07:58:05 PM

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
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 16, 2012, 12:35:16 AM
wait, so what do I do?
Title: Re:increase map and scroll size and keep everything in its place?
Post by: handsource-dyko on July 16, 2012, 06:49:12 AM
I guess you forgot to incluse some modules? I must admit, I haven't check for that because it's kinda obvious. :-[
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 16, 2012, 04:34:23 PM
well I added mod_text and I got the same error.
Title: Re:increase map and scroll size and keep everything in its place?
Post by: SplinterGU on July 16, 2012, 09:43:58 PM
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.
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 16, 2012, 10:50:30 PM
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.
Title: Re:increase map and scroll size and keep everything in its place?
Post by: SplinterGU on July 17, 2012, 08:12:16 PM
I reply you yesterday or early today
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 17, 2012, 11:11:55 PM
Yeah I sent you an email from another address with a .zip file attacked to it. It should be @engine_7_16_2012.zip
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 17, 2012, 11:33:06 PM
I changed stuff like you said but im getting INTERGER to STRING errors and I get this

(http://forum.bennugd.org/index.php?action=dlattach;topic=3121.0;attach=2464)
Title: Re:increase map and scroll size and keep everything in its place?
Post by: SplinterGU on July 18, 2012, 12:14:43 AM
you forget the attachments in the lasts emails.
Title: Re:increase map and scroll size and keep everything in its place?
Post by: SplinterGU on July 18, 2012, 12:21:15 AM
I think that last version don't run... libpng15-15.dll is missing... I think
Title: Re:increase map and scroll size and keep everything in its place?
Post by: SplinterGU on July 18, 2012, 12:22:20 AM
in windows fail... I'll see it... thanks.
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 18, 2012, 01:05:35 AM
Oh I was gone at the store. Is there something I need to do?
Title: Re:increase map and scroll size and keep everything in its place?
Post by: SplinterGU on July 18, 2012, 03:01:34 AM
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
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 18, 2012, 03:56:10 AM
thank you so much!
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 18, 2012, 05:03:16 AM
wait, the levels being made will not load, even when put in the directory. hmmmm
Title: Re:increase map and scroll size and keep everything in its place?
Post by: SplinterGU on July 18, 2012, 03:47:12 PM
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.
Title: Re:increase map and scroll size and keep everything in its place?
Post by: MisterN on July 18, 2012, 04:07:25 PM
what should i do with all the .dll's and stuff? put them in another directory?
Title: Re:increase map and scroll size and keep everything in its place?
Post by: SplinterGU on July 18, 2012, 04:31:00 PM
some dlls you can put in other directory.