Jump to content


Photo

Need Help With Platformer


  • Please log in to reply
26 replies to this topic

#16 iprice

iprice

    Mega GP Mania

  • GP Guru
  • 1104 posts
  • Gender:Male
  • Location:MK. UK. OK.

Posted 29 November 2008 - 04:53 PM

And about setting up Fenix...

#17 Burbruee

Burbruee

    GP32 Hardcore

  • Members
  • PipPipPipPip
  • 199 posts

Posted 29 November 2008 - 05:37 PM

QUOTE(iprice @ Nov 29 2008, 05:53 PM) View Post

And about setting up Fenix...

Sorry, but I don't quite understand what you mean. unsure.gif

#18 Burbruee

Burbruee

    GP32 Hardcore

  • Members
  • PipPipPipPip
  • 199 posts

Posted 29 November 2008 - 05:57 PM

QUOTE(iprice @ Nov 29 2008, 05:37 PM) View Post

BTW which version of Fenix are you running and which IDE/ - I've tried compiling and running your code in Fenix 0.92 and FBMX, but just get error mesasges and the compiler option keeps switching to Bennu. Obviously I've not set something up correctly. Any advice on setting it up, so that I can then help you properly.

Oh, I missed your edit.. Well, here goes.
I'm not currently using any IDE, for some reason FBMX has stopped working completely since I installed Visual C++ Express on my Vista installation..
If I remember correct, download and extract Fenix 0.92a somewhere. (seems like you already did this)
In FBMX, go to preferences and choose the right path for Fenix, you can leave it at Bennu I think, it will work anyway. But change to the next tab and uncheck ALL boxes except debug (-d) and it should work.

FBMX is a little buggy, so every time you start it, you need to go to preferences and click OK. (You don't actually need to change anything, just go in there and click OK)

I use Fenix 0.92 with Notepad++ and commandline currently since my FBMX no longer works..

Edited by Burbruee, 29 November 2008 - 05:57 PM.


#19 iprice

iprice

    Mega GP Mania

  • GP Guru
  • 1104 posts
  • Gender:Male
  • Location:MK. UK. OK.

Posted 29 November 2008 - 07:36 PM

You're so right about FBMX being buggy - sometimes it works then other times it doesn't!!! Terrible.

I have discovered that it is to with how you have set up the multi-dimensional array - if you change one value to a number other than 0 or 1 (say 4) you will see that "4" will appear more than once in your display if you use a WRITE command to display the value of that array, rather than a PUT command. This is obviously wrong.

I'm not sure you can declare a mutli-dimensional array the way you are trying to.

CODE

PROGRAM TROLLET_IV;
GLOBAL
    int i, j, map;
    int TILE_SIZE = 16;

    int level1[20][15];

BEGIN;

level1[0][0]=1;
level1[19][0]=2;
level1[0][14]=3;
level1[19][14]=4;

    set_title("TROLLET IV: UNDERTITLE TO BE DECIDED");
    set_mode(640,480,8,256);
    map = new_map(16,16,8);
    for(y=0; y<15; y++)    
    for(x=0; x<20; x++)
      write (0,x*16,y*16,0,level1[x][y]);
       end;
    end;
    
    loop
        if(key(_esc)) exit("",0); end;
        frame;
    end;
    
END;


You will see in my code that the corners are shown correctly (from 1 to 4 from top left) when run, hence the map displaying code is working correctly - hence it's the way the data is loaded into the array.

And a second test -
CODE

PROGRAM TROLLET_IV;
GLOBAL
    int n, map;
    int TILE_SIZE = 16;

int level1[20][15];

BEGIN;

for(y=0; y<15; y++)    
for(x=0; x<20; x++)
level1[x][y]=n;
n++;
end;
end;

    set_title("TROLLET IV: UNDERTITLE TO BE DECIDED");
    set_mode(640,480,8,256);
    map = new_map(16,16,8);
    for(y=0; y<15; y++)    
    for(x=0; x<20; x++)
      write (0,x*48,y*16,0,level1[x][y]);
      
       end;
    end;
    
    loop
        if(key(_esc)) exit("",0); end;
        frame;
    end;
    
END;


This counts up from 0, displaying each number on the display.

You are going to have to load your data into the array either one at a time - (like I did with the four corners), or use an external file to hold the data and read it all in.

Edited by iprice, 29 November 2008 - 07:46 PM.


#20 iprice

iprice

    Mega GP Mania

  • GP Guru
  • 1104 posts
  • Gender:Male
  • Location:MK. UK. OK.

Posted 29 November 2008 - 08:23 PM

Sorry for the double post, but here is the solution -
CODE

PROGRAM TROLLET_IV;
GLOBAL
    int n, map;
    int TILE_SIZE = 16;

    int lvl[20][15];

int level1[]=1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;


BEGIN;

for(y=0; y<15; y++)    
for(x=0; x<20; x++)
lvl[x][y]=level1[n];
n++;
end;
end;

    set_title("TROLLET IV: UNDERTITLE TO BE DECIDED");
    set_mode(640,480,8,256);
    map = new_map(16,16,8);
    for(y=0; y<15; y++)    
    for(x=0; x<20; x++)
      write (0,x*16,y*16,0,lvl[x][y]);
      
       end;
    end;
    
    loop
        if(key(_esc)) exit("",0); end;
        frame;
    end;
    
END;


Use a single dimensioned array to hold the original data and then use a loop to convert it into a 2D array.

#21 Burbruee

Burbruee

    GP32 Hardcore

  • Members
  • PipPipPipPip
  • 199 posts

Posted 29 November 2008 - 08:34 PM

QUOTE(iprice @ Nov 29 2008, 08:36 PM) View Post

You're so right about FBMX being buggy - sometimes it works then other times it doesn't!!! Terrible.

I have discovered that it is to with how you have set up the multi-dimensional array - if you change one value to a number other than 0 or 1 (say 4) you will see that "4" will appear more than once in your display if you use a WRITE command to display the value of that array, rather than a PUT command. This is obviously wrong.

I'm not sure you can declare a mutli-dimensional array the way you are trying to.

You are going to have to load your data into the array either one at a time - (like I did with the four corners), or use an external file to hold the data and read it all in.


Yeah, I figured it had something to do with that. I couldn't find any information on the net about how to set up multi-dimensional arrays in Fenix. In C++ I would just put brackets around each line and another set of brackets around everything. Fenix won't recognise { } though.

I'll try to read it into the array one at a time or textfile loading, thanks.

EDIT: Thanks for the solution, I'll try it right away. smile.gif

Edited by Burbruee, 29 November 2008 - 08:37 PM.


#22 Burbruee

Burbruee

    GP32 Hardcore

  • Members
  • PipPipPipPip
  • 199 posts

Posted 29 November 2008 - 09:46 PM

It's working, thanks for all the help!
Just one more question though.

How would I handle loading different levels? Or rather, how would I "unload" the current level and replace it with another one in a good way?

Edited by Burbruee, 29 November 2008 - 09:46 PM.


#23 iprice

iprice

    Mega GP Mania

  • GP Guru
  • 1104 posts
  • Gender:Male
  • Location:MK. UK. OK.

Posted 29 November 2008 - 11:46 PM

If you had all your levels stored as level2[]=xxxx and level3[]=xxxx etc. then you could use the FOR loop as before -

CODE

n=0;
for(y=0; y<15; y++)    
for(x=0; x<20; x++)
lvl[x][y]=levelX[n]; // <--------Change the level number here

// Or make Level a multi-dimensioned array
// lvl[x][y]=level[level_number][n]; etc...

n++;
end;
end;


Personally, I always make level editors for my games and load the data in as required, rather than hard code it - the choice is yours though.

#24 Burbruee

Burbruee

    GP32 Hardcore

  • Members
  • PipPipPipPip
  • 199 posts

Posted 30 November 2008 - 12:52 AM

QUOTE(iprice @ Nov 30 2008, 12:46 AM) View Post

If you had all your levels stored as level2[]=xxxx and level3[]=xxxx etc. then you could use the FOR loop as before -

CODE

n=0;
for(y=0; y<15; y++)    
for(x=0; x<20; x++)
lvl[x][y]=levelX[n]; // <--------Change the level number here

// Or make Level a multi-dimensioned array
// lvl[x][y]=level[level_number][n]; etc...

n++;
end;
end;


Yes, but I would need to change the level once in the game loop. (for example by checking keypress or when touching a specific "goal" tile.
So I would need that for-loop to run again and change the level. But putting it in the game loop would loop the for-loop forever, no?

QUOTE(iprice @ Nov 30 2008, 12:46 AM) View Post

Personally, I always make level editors for my games and load the data in as required, rather than hard code it - the choice is yours though.

I probably will, eventually. But I like to start simple and then make things better as I go along.
Haven't even thought about how to build an editor yet, could be a fun experience if I succeed. smile.gif

#25 iprice

iprice

    Mega GP Mania

  • GP Guru
  • 1104 posts
  • Gender:Male
  • Location:MK. UK. OK.

Posted 30 November 2008 - 11:16 AM

You don't have to put the FOR loop into the main loop - put it into a process/function of it's own and then call the process when required. smile.gif

You didn't ask where to implement it, you just asked how to implement it;) tongue.gif

Level editors are surprisingly easy to create, give me a yell when you are ready to go that route. smile.gif

#26 Burbruee

Burbruee

    GP32 Hardcore

  • Members
  • PipPipPipPip
  • 199 posts

Posted 30 November 2008 - 04:57 PM

QUOTE(iprice @ Nov 30 2008, 12:16 PM) View Post

You don't have to put the FOR loop into the main loop - put it into a process/function of it's own and then call the process when required. smile.gif

You didn't ask where to implement it, you just asked how to implement it;) tongue.gif

Level editors are surprisingly easy to create, give me a yell when you are ready to go that route. smile.gif

Sure, thanks for offering help. smile.gif

#27 Burbruee

Burbruee

    GP32 Hardcore

  • Members
  • PipPipPipPip
  • 199 posts

Posted 15 February 2009 - 02:34 PM

Ok, I think it''''s time to think about a map editor now.. And I think I''''ll make it a separate program and not built-in. (don''''t want the user to be able to edit the maps, it''''s just for me the developer. and preferrably the files Fenix writes and reads should not be easily editable through a texteditor by the user either but it''''s not as important at the moment)

So the map editor should be able to write and read files for saving and loading. Cycle through the available tiles and paint them on screen (either by mouse or keyboard). Anything I forgot?

I''''m not really sure how to pull this off on my own, so I might need some help on where to start.
At the moment I''''m checking out a C++ example from here: >http://www.parallelrealities.co.uk/tutorials/intermediate/tutorial13.php

Will try and adapt that to Fenix and hope for the best. But feel free to help me out if you have experience in this.

EDIT: I sorted it out, got a fully working level editor now. biggrin.gif

Edited by Burbruee, 15 February 2009 - 10:57 PM.