|
Post by shadow008 on Dec 14, 2009 20:20:08 GMT -5
I hope someone finds it useful ! I dont have any plans to go further than this, cuz i really dont see much more there is to add. Put the executable in the default programs folder. Figure out any bugs on your own Because of this i will be starting an extensive 2d game engine... We'll see how that works out . Attachments:
|
|
|
Post by shadow008 on Dec 15, 2009 21:08:52 GMT -5
weird... testing it i found out that executables have some errors with writing to files... it only writes to a certain size. After that, it quits(mid sentence or not).
|
|
|
Post by shadow008 on Dec 18, 2009 12:15:15 GMT -5
no feedback? and can someone PLEASE tell me why executables wont write a file more than 512 bytes?
|
|
|
Post by James :) (aka Madcow) on Dec 18, 2009 16:51:42 GMT -5
im not sure if itll work but try adding a 5 milisecond sleep each time you write anything to the file. i know basic4gl sometimes quits midway if you send a lot of traffic down the network engine so im wondering if the filesystem falls foul of this as well.
if not must be a limitation or something but i cant see why you cant i know ive written files larger than that in basic4gl before, might just be memory as i used less variables as mine was a simple text based file transfer program.
|
|
|
Post by Adam on Feb 12, 2010 23:39:07 GMT -5
hello shadow, would you mind adding an alternative file output type. its a nice small format XD
i wrote a crude converter from your format to mine, and figured you could use it if you want to add it as an optional output (which i hope you do)
.tilemap to .BINmap converter
struc sobject dim pos(1) as single dim size(1) as single dim value as integer dim sprite as integer endstruc
struc smap dim &tiles()() as integer dim tilemap as integer dim texture(50) as integer dim size(1) as integer dim &colltiles() as integer dim object(100) as sobject endstruc
function LoadNewTexture(filename as string,&texture) texture = loadtex(filename) return 0 endfunction
function LoadObject(file,&object as sobject) readtext(file,true) object.pos = vec2(val(readtext(file,true)),val(readtext(file,true))) readtext(file,true) object.size = vec2(val(readtext(file,true)),val(readtext(file,true))) readtext(file,true) object.value = val(readtext(file,true)) return 0 endfunction
'function SetObject(&object as sobject) ' ' object.sprite = newsprite(map.texture(object.value)) ' sprsetpos(object.pos) ' sprsetsize(object.size) ' sprsetzorder(5) ' ' return 0 ' 'endfunction
dim objs as integer dim num as integer dim texnames(100) as string dim texturecount dim collisiontiles
function LoadMap(&map as smap,filename as string)
dim file = openfileread(filename) dim x,y dim word as string dim name as string dim texnum as integer
if fileerror() <> "" then printr fileerror() drawtext() END else map.size(0) = val(readtext(file,true)) map.size(1) = val(readtext(file,true)) alloc map.tiles,map.size(0),map.size(1)
do word = lcase$(readtext(file,true)) if word = "data" then for y = 0 to map.size(1) for x = 0 to map.size(0) map.tiles(x,y) = val(readtext(file,true)) next next elseif word = "num" then num = val(readtext(file,true)) elseif word = "colltiles:" then if num > 0 then collisiontiles = num alloc map.colltiles,num-1 for x = 0 to num-1 map.colltiles(x) = val(readtext(file,true)) next endif elseif word = "texture:" then texnum = texnum + 1 name = readtext(file,true) texnames(texnum-1) = name LoadNewTexture(name,map.texture(texnum)) elseif word = "object" then objs = objs + 1 LoadObject(file,map.object(objs)) endif loop until EndOfFile(file) closefile(file) endif texturecount = texnum-1 return 0 endfunction
dim filename as string input "filename(w/o ext):",filename
dim smap map, x, y loadmap(map,filename+".tilemap") printr "Saving binary map as "filename+".BINmap" dim file = openfilewrite(filename+".BINmap") writebyte(file,map.size(0)+1) writebyte(file,map.size(1)+1) for y = 0 to map.size(1) for x = 0 to map.size(0) writebyte(file,map.tiles(x)(y)-1) next next writebyte(file,texturecount+1) for x = 0 to texturecount writebyte(file,1) for y = 1 to len(texnames(x)) writebyte(file,asc(mid$(texnames(x),y,1))) next writebyte(file,0) next writebyte(file,collisiontiles) for x = 0 to collisiontiles-1 writebyte(file,map.colltiles(x)-1) next closefile(file) print "done" drawtext()
and here is the include file for loading a .BINmap file
Struc _TileTexture attrib size(1) name as string end struc
Struc _STileMap TexCount _TileTexture Tex(19) texload file end struc
Struc BinTilemap texturecount &Collision() &texture() &Tiles()() size(1) end struc
dim _tilemaptemp dim _tilemaptemp2 dim _STilemap _tilemaptempload
sub gettexturename(file,_tiletexture &tex) tex.attrib = _tilemaptemp do _tilemaptemp = readbyte(file) if not _tilemaptemp = 0 then tex.name = tex.name + chr$(_tilemaptemp) endif loop until _tilemaptemp = 0 if tex.attrib = 2 then tex.size(0) = readbyte(file) tex.size(1) = readbyte(file) endif end sub
sub getimagestrip(&texture(), &texturecount,name as string, x, y) dim temp(texstripframes(name,x,y)-1) = loadtexstrip(name,x,y) for _tilemaptemp2 = 0 to arraymax(temp) texture(texturecount) = temp(_tilemaptemp2) texturecount = texturecount + 1 next end sub
Sub Loadtilemap(BinTileMap &texture,filename as string) _tilemaptempload.file = openfileread(filename) for _tilemaptemp = 0 to 1 texture.size(_tilemaptemp) = readbyte(_tilemaptempload.file) next alloc texture.tiles, texture.size(0)-1, texture.size(1)-1 for _tilemaptemp2 = 0 to texture.size(1)-1 for _tilemaptemp = 0 to texture.size(0)-1 texture.tiles(_tilemaptemp,_tilemaptemp2) = readbyte(_tilemaptempload.file) next next _tilemaptempload.texload = readbyte(_tilemaptempload.file) for _tilemaptemp2 = 0 to _tilemaptempload.texload-1 _tilemaptemp = readbyte(_tilemaptempload.file) if _tilemaptemp = 1 then gettexturename(_tilemaptempload.file,_tilemaptempload.tex(_tilemaptempload.texcount)) _tilemaptempload.texcount = _tilemaptempload.texcount + 1 'print 1 elseif _tilemaptemp = 2 then gettexturename(_tilemaptempload.file,_tilemaptempload.tex(_tilemaptempload.texcount)) _tilemaptempload.texcount = _tilemaptempload.texcount + 1 'print 2 endif next _tilemaptempload.texload = readbyte(_tilemaptempload.file) alloc texture.collision, _tilemaptempload.texload-1
for _tilemaptemp = 0 to _tilemaptempload.texload-1 texture.collision(_tilemaptemp) = readbyte(_tilemaptempload.file) next closefile(_tilemaptempload.file) for _tilemaptemp = 0 to _tilemaptempload.texcount-1 if _tilemaptempload.tex(_tilemaptemp).attrib = 1 then texture.texturecount = texture.texturecount + 1 elseif _tilemaptempload.tex(_tilemaptemp).attrib = 2 then texture.texturecount = texture.texturecount + imagestripframes(_tilemaptempload.tex(_tilemaptemp).name,_tilemaptempload.tex(_tilemaptemp).size(0),_tilemaptempload.tex(_tilemaptemp).size(1)) - 1 endif next alloc texture.texture, texture.texturecount-1 texture.texturecount = 0 for _tilemaptemp = 0 to _tilemaptempload.texcount-1 if _tilemaptempload.tex(_tilemaptemp).attrib = 1 then texture.texture(texture.texturecount) = loadtex(_tilemaptempload.tex(_tilemaptemp).name) texture.texturecount = texture.texturecount + 1 elseif _tilemaptempload.tex(_tilemaptemp).attrib = 2 then getimagestrip(texture.texture,texture.texturecount,_tilemaptempload.tex(_tilemaptemp).name,_tilemaptempload.tex(_tilemaptemp).size(0),_tilemaptempload.tex(_tilemaptemp).size(1)) endif next end sub
|
|
|
Post by shadow008 on Feb 16, 2010 22:09:17 GMT -5
sorry i havent been on the forums lately. My schools F \_/ ( K ! |\| G blocking system decided these forums suddenly werent allowed to be accesed, along with almost every other site out there. (P I S S E S M E O F F !!!!! ) back to what adam said. I CEE WHUT U DID THAR !!! .... memory saver, right? um... ok, ill try that.... (about 20 min later) omg.... almost got the save to bin file done.... (10 min later) what the hell?! stupid error - 2 min later - kk it saves to bin file but has no name?! (10 min later) F*** it. ill finish it tomorrow.... i started writing this post about 50 min ago... @ 9:25... its now 10:18 lolz anyways.... ill see if i can get this last part implemented in, i havent really touched this code for about a month now so i had to go back and remember the variable names.
|
|
|
Post by shadow008 on Feb 18, 2010 21:38:32 GMT -5
ok, thats it, im getting pissed. anyone know of a working D-mirror? The one i use to use (http://67.15.34.225/dmirror/www/*name of website*) finally came to an end...it makes me sad : ( ...
|
|
|
Post by crazynate on Feb 18, 2010 22:50:02 GMT -5
can you get on basic4gl's wiki at school? i could possibly embed the forum on one of the wiki's pages (i did this with my forum and wiki, sadly my wiki is blocked at my school ) edit: add this to the wiki(or possibly an html code tester?) as an "other" widget <iframe src="http://basic4gl.proboards.com" frameborder="1" scrolling="auto" width="100%" height="1200"></iframe> this might work...
|
|
|
Post by crazynate on Feb 19, 2010 16:38:42 GMT -5
... it doesnt stupid blocks
|
|
|
Post by twasik4 on Feb 20, 2010 0:07:17 GMT -5
Way to ask your friend who sits next to you like everyday for his webbrowser? Fail on your part much? for that you lose the game.
|
|
|
Post by crazynate on Feb 20, 2010 0:23:37 GMT -5
What the heck are you talking about twasik?
|
|
|
Post by shadow008 on Feb 20, 2010 22:49:27 GMT -5
Way to ask your friend who sits next to you like everyday for his webbrowser? Fail on your part much? for that you lose the game. yeah, it does work, but i really dont want to change the name every time to use it... .... and, yeah, i did just lose the game...
|
|
|
Post by twasik4 on Mar 4, 2010 9:50:32 GMT -5
only reason it got caught is cause im redflagged and they read the log to everything i do >.>
|
|