Need Help With Platformer
#16
Posted 29 November 2008 - 04:53 PM
#18
Posted 29 November 2008 - 05:57 PM
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
Posted 29 November 2008 - 07:36 PM
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.
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 -
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
Posted 29 November 2008 - 08:23 PM
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
Posted 29 November 2008 - 08:34 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.
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.
Edited by Burbruee, 29 November 2008 - 08:37 PM.
#22
Posted 29 November 2008 - 09:46 PM
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
Posted 29 November 2008 - 11:46 PM
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
Posted 30 November 2008 - 12:52 AM
If you had all your levels stored as level2[]=xxxx and level3[]=xxxx etc. then you could use the FOR loop as before -
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?
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.
#25
Posted 30 November 2008 - 11:16 AM
You didn't ask where to implement it, you just asked how to implement it;)
Level editors are surprisingly easy to create, give me a yell when you are ready to go that route.
#26
Posted 30 November 2008 - 04:57 PM
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.
You didn't ask where to implement it, you just asked how to implement it;)
Level editors are surprisingly easy to create, give me a yell when you are ready to go that route.
Sure, thanks for offering help.
#27
Posted 15 February 2009 - 02:34 PM
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.
Edited by Burbruee, 15 February 2009 - 10:57 PM.












