
-----------------------------------
TheEvilOne
Tue Apr 12, 2005 8:42 pm

Portable Tile Generation System
-----------------------------------
Alright, this is my second 'open source' post here. This time, I know something like this has probably been posted here before, but oh well... im posting it anyways  :P 

This system is easily changable, and added on to. I programmed in in procedures that you can move wherever you want. If you feel like it, im sure you can make the variables be passed. For now, most things are just constants, and are layed out easily enough to find.

Well, just unzip it, and remember, the Readme file is your friend  :D 

Any Comments/Suggestions are welcome.

I'm working on a complex collision/interaction system to go with the tiles, so you can make it so that the tiles have easy interaction with your characters. e.g. your character cant run into this tile, but if there is a sign tile nearby, you can read it, etc.

-----------------------------------
Delos
Tue Apr 12, 2005 9:19 pm


-----------------------------------
Pretty.  One thing.
Line 40.  Change it from

exit when eof


to 


exit when eof (TileFile)


Things will be a lot happier.

-----------------------------------
TheEvilOne
Tue Apr 12, 2005 9:24 pm


-----------------------------------
You know... I meant to do that in the first place. And that stopped the error. I error checked that so many times and it just slipped my mind.

Thank you  :D

** Updated **

-----------------------------------
dann_west
Wed May 04, 2005 1:56 pm

Re: Portable Tile Generation System
-----------------------------------
creative?...
 :twisted:  :twisted:  :twisted:  :twisted:  :twisted:  :twisted:  :twisted:

-----------------------------------
AzureFire
Sat Dec 03, 2005 11:02 am


-----------------------------------
Thank you!!!! I've been trying to learn how these text file maps work forever...lol

one quick question. How do you make a tile solid, so that a player cannot walk through it?



P.S. Sorry for bumping an old post ^_^

-----------------------------------
RedRogueXIII
Sat Dec 03, 2005 3:59 pm


-----------------------------------
Very cool, maybe i could integrate it with my own Zelda engine, see other post.

 and to make a non passible spot just make a 2 dimensional array of boolean.

at spot (x,y) = false then cannot walk eg.
* the code for declaring a 2d array eludes me right now...


[edit] also when making map files that can be loaded and saved, you can also have multiple layers so that you could lay down the basic tiles first then on a new layer or paragraph you declare spots where you want bigger elements to go, eg houses or trees, the same could be said for map transitional data,  spotx, spoty opens map(whatever). just to how pro map files can be. :P

-----------------------------------
Cervantes
Sat Dec 03, 2005 5:09 pm


-----------------------------------
* the code for declaring a 2d array eludes me right now...
var my_2d_array : array 1 .. 5, 1 .. 10 of int




If the houses or the trees are fixed, I don't see the advantage of this.  Could you please elaborate?

-----------------------------------
Aziz
Sat Dec 03, 2005 11:22 pm


-----------------------------------
For now, tile names must be numbers. Integer numbers to be exact. I'm working on a way to allow string names, but for now, im sorry to say that you have to use integers.

Why not make an array called filenames?

var filenames : array 1 .. 10 of int :=
    init ("Grass", "TallGrass", "Bush",
          "Flower", "SmallTallGrass", "GrassWithFlower",
          "Fence", "Log", "2Logs", "Stump" )

Now if you read a tile number, say 6, it's filename would be: filenames(6) + ".bmp" . :D[/code]

-----------------------------------
Cervantes
Sun Dec 04, 2005 10:18 am


-----------------------------------
var filenames : array 1 .. 10 of int :=
    init ("Grass", "TallGrass", "Bush",
          "Flower", "SmallTallGrass", "GrassWithFlower",
          "Fence", "Log", "2Logs", "Stump" )

Don't forget to make that an array of strings.  :wink:

You might also look into making that an enumerated type.  Sadly, we don't have a tutorial on the topic.  AsianSensation was supposed to make one, but then he went to University.  :roll:

-----------------------------------
RedRogueXIII
Sun Dec 04, 2005 1:55 pm


-----------------------------------
what i mean when having trees and houses on a different layer is to just grab and place the whole graphic into the map, instead of calling all the individual tiles that compose the graphic. eg if a house took 4 tiles then on the tile layer set those to default and call the graphic on the computer's x,y axis. i hope that explains what i meant to say.

-----------------------------------
Aziz
Mon Dec 05, 2005 8:03 am


-----------------------------------
var filenames : array 1 .. 10 of int :=
    init ("Grass", "TallGrass", "Bush",
          "Flower", "SmallTallGrass", "GrassWithFlower",
          "Fence", "Log", "2Logs", "Stump" )

Don't forget to make that an array of strings.  :wink:

You might also look into making that an enumerated type.  Sadly, we don't have a tutorial on the topic.  AsianSensation was supposed to make one, but then he went to University.  :roll:

 :snipe: You must be silenced!

-----------------------------------
ZeroPaladn
Mon Dec 05, 2005 10:17 am


-----------------------------------
for collision detection for a tile system is to make a second (collision detection" layer as a picture. whatever you cant walk on, make it a diff colour, and declare it beofre you draw the main picture, do collision detection, then draw the main map. on most computers you dont even see the colission detection layer.

-----------------------------------
jamonathin
Mon Dec 05, 2005 1:16 pm


-----------------------------------
for collision detection for a tile system is to make a second (collision detection" layer as a picture. whatever you cant walk on, make it a diff colour, and declare it beofre you draw the main picture, do collision detection, then draw the main map. on most computers you dont even see the colission detection layer.
I dont think thats what he ment ZeroPally.  Not saying that methods bad (not perfect).
What you can do, is use your textfile.  I mean, it right there, why not?

So lets say in your text file, everywhere the number '4' is, your NOT supposed to walk there because theres some fat tree in the way.  Well, if you have already loaded from your file to put a fat tree there, why not check using the same text file?  Basically what you'll be doing is walking through the actual text file, rather than the screen.  The screen will just show you what you're doing, in a prettier format  :color: .  So basically, this is what your player will be doing.

setscreen ("graphics:150;150,nobuttonbar,position:center;center,offscreenonly")
colorback (black)
color (white)
cls
var spot : array 1 .. maxrow + 1, 1 .. maxcol + 1 of int
% The +1 is for when the game is running, it checks at maxrow+1 which does not exist . . so lets make it exist

for q : 1 .. upper (spot, 1) %maxrow
    for i : 1 .. upper (spot, 2) %maxcol
        spot (q, i) := Rand.Int (0, 4) %4 means cannot walk there
    end for
end for

spot (1, 1) := 0 %Make the first spot open
var x, y : int := 1 %(x,y) starts at (1,1) which is =0
var xHold, yHold : int := x
var valueHold : string := ""

var key : array char of boolean

proc refresh
    for q : 1 .. upper (spot, 1) - 1    %we cannot go to maxrow+1 so dont
        for i : 1 .. upper (spot, 2) - 1 %we cannot go to maxcol+1 so dont
            color (spot (q, i)+28)
            locate (q, i) %locate properly
            put spot (q, i) .. %put whatever value is there
        end for
    end for
    color (10)
    locate (x, y) %locate where our man is
    put "P" ..
end refresh

loop
    Input.KeyDown (key)
    % Basically the if statements say, if the next spot is NOT 4 and is NOT off screen then go ahead
    if key (KEY_LEFT_ARROW) and y - 1 not= 0 and spot (x, y - 1) not= 4 then
        y -= 1
    elsif key (KEY_RIGHT_ARROW) and y + 1 