Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Portable Tile Generation System
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheEvilOne




PostPosted: Tue Apr 12, 2005 8:42 pm   Post subject: 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 Razz

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 Very Happy

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.



Tile System.zip
 Description:

Download
 Filename:  Tile System.zip
 Filesize:  6.5 KB
 Downloaded:  330 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Tue Apr 12, 2005 9:19 pm   Post subject: (No subject)

Pretty. One thing.
Line 40. Change it from
code:

exit when eof


to

code:

exit when eof (TileFile)


Things will be a lot happier.
TheEvilOne




PostPosted: Tue Apr 12, 2005 9:24 pm   Post subject: (No subject)

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 Very Happy

** Updated **
dann_west




PostPosted: Wed May 04, 2005 1:56 pm   Post subject: Re: Portable Tile Generation System

creative?...
Twisted Evil Twisted Evil Twisted Evil Twisted Evil Twisted Evil Twisted Evil Twisted Evil
AzureFire




PostPosted: Sat Dec 03, 2005 11:02 am   Post subject: (No subject)

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




PostPosted: Sat Dec 03, 2005 3:59 pm   Post subject: (No subject)

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. Razz
Cervantes




PostPosted: Sat Dec 03, 2005 5:09 pm   Post subject: (No subject)

RedRogueXIII wrote:
* the code for declaring a 2d array eludes me right now...

code:
var my_2d_array : array 1 .. 5, 1 .. 10 of int



RedRogueXIII wrote:

[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,

If the houses or the trees are fixed, I don't see the advantage of this. Could you please elaborate?
Aziz




PostPosted: Sat Dec 03, 2005 11:22 pm   Post subject: (No subject)

Quote:
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?

code:
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" . Very Happy[/code]
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sun Dec 04, 2005 10:18 am   Post subject: (No subject)

Aziz wrote:
code:
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. Rolling Eyes
RedRogueXIII




PostPosted: Sun Dec 04, 2005 1:55 pm   Post subject: (No subject)

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




PostPosted: Mon Dec 05, 2005 8:03 am   Post subject: (No subject)

Cervantes wrote:
Aziz wrote:
code:
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. Rolling Eyes


Sniper You must be silenced!
ZeroPaladn




PostPosted: Mon Dec 05, 2005 10:17 am   Post subject: (No subject)

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




PostPosted: Mon Dec 05, 2005 1:16 pm   Post subject: (No subject)

ZeroPaladn wrote:
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.
code:

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 <= maxcol and spot (x, y + 1) not= 4 then
        y += 1
    end if
    if key (KEY_UP_ARROW) and x - 1 not= 0 and spot (x - 1, y) not= 4 then
        x -= 1
    elsif key (KEY_DOWN_ARROW) and x + 1 <= maxrow and spot (x + 1, y) not= 4 then
        x += 1
    end if
    refresh
    View.Update
    delay (100)
end loop

This isn't exactly what you would be using in that type of situation, but i juss whipped it together to help you understand what is going on.
Good luck with that.
AzureFire




PostPosted: Mon Dec 05, 2005 4:44 pm   Post subject: (No subject)

ok thanks, seems simple enough.


By the way ZeroPaladn, I sent you the signature without the PREVIEW tag in it. Check your PM inbox.
Shyfire




PostPosted: Mon Dec 05, 2005 5:15 pm   Post subject: (No subject)

i think what zero said is easier to understand and its what i use to an extent in rpgs and other games that i make
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: