|
Post by Enzo on Feb 15, 2021 10:12:33 GMT
Quick question, DO I NEED to use sprites can I use draw bmp?? if im okay with no toggle thru animations I can simply use arrays and counter variables to track animation, Must be Liberty basic full for sprite mask .bas or do I need for transpency
|
|
|
Post by Enzo on Feb 15, 2021 10:15:29 GMT
Why on earth any sprite mask would not mask the white around the object is beyond me what is the point then of the tranpency but to already manually set
I'm confused how these programs work/don't work
|
|
|
Post by Enzo on Feb 15, 2021 10:23:17 GMT
Seems like its a 3 part toggle of a pixel read, white square = black black squares = white and non black white squares = black, not sure why all this fancy code I think my previous attempt is close on previous page...
|
|
|
Post by Rod on Feb 15, 2021 10:55:12 GMT
Sprites are fast. Loading sprites is fast so I dont know where these delays are coming from. Sprites are easy and take a lot of graphic management off your hands. You can use draw bmp but you wont get transparency unless you upgrade to Liberty BASIC and use the blitter.
But sprites and Just BASIC are more than capable for what youvare doing. We just need to better understand where these delays you speak of come from.
|
|
|
Post by Enzo on Feb 15, 2021 13:52:23 GMT
The delay is in loading the array from map file, maybe picking a faster read method such as .db (if that allows for faster) I guess the wait is tolerable for a 500x500 any bigger it would be unrealistic as the delay is at least one minute long. Maybe if data was stored in my complied code and not a external file would give access to even bigger maps? Ideally we'd would be looking for a 1000x1000 or 1500x1500
|
|
|
Post by Rod on Feb 15, 2021 14:33:27 GMT
You are using line input to suck text into an array. That's fairly slow. Two things you could do. Just hold the map as a single big string, it will load instantly with map$=input$(#file,lof(#file)) and parse out what you need with mid$ when you need it. Or, keep your map as a RAF file. Then you just SEEK the location you want and GET the data. No loading at all.
|
|
|
Post by Enzo on Feb 15, 2021 15:30:21 GMT
This bypass, Hmm what is the max character count for JB? 250,000?
Do I just loop till 500 character length of line (a variable stop) until var= 500 mid$(map$, var, 2) putting array data into rem and 500 columns worth map$(var, Ycounttill500) = mid$(map$, var, 2)
I suppose the comma could be left with a modifier for input reading to ignore the comma in all cases at display parse
|
|
|
Post by Enzo on Feb 15, 2021 15:51:56 GMT
Seems im rendering data at 500x500 per 2.8 seconds, couldn't be any happier, gonna try and add to engine now, here's snippet
dim map$(500,500)
open "v.txt" for input as #file
time2 = time$("ms")
map$=input$(#file,lof(#file))
print time$("ms")-time2
time1 = time$("ms") for xx = 1 to 500 for yy = 1 to 500 var = var + 1 map$(xx,yy) = mid$(map$, var, 2)
'print map$(xx,yy)
next yy next xx
print time$("ms")-time1;" completed in ms"
wait
For reference I am splitting map.txt into two files for now, will hard code header from orginal map.txt into program should header not be useful for mass adding formatted data
|
|
|
Post by Enzo on Feb 15, 2021 21:33:56 GMT
I'd like to be able to convert a .bmp file into w,s,r,d based on color of pixel, it would be manageable to use while having 1000x1000 grid to edit in MSPaint
I seem to be missing something no values are given everything is at 0
dim bmp$(1000,1)
global Blue,Green,Red,x,y,Pixel$,s$,pointer,bits,mult,padding,bmph,bmpw,bytes 'nomainwin [loadfile] bmph =0 bmpw =0 red =0 blue =0 green=0 x =0 y=0 Pixel$="" s$="" file$ = "" y$=""
filedialog "", ".bmp", file$ if file$ = "" then end end if 'null=null null open file$ for binary as #bmp
'analyse the file header bytes seek #bmp,10 'picture data offset, where the color data starts 4 bytes of data offset=asc(input$(#bmp,1))+asc(input$(#bmp,1))*256+asc(input$(#bmp,1))*65536+asc(input$(#bmp,1))*16777216 seek #bmp,18 'width 4 bytes of data bmpw=asc(input$(#bmp,1))+asc(input$(#bmp,1))*256+asc(input$(#bmp,1))*65536+asc(input$(#bmp,1))*16777216 seek #bmp,22 'height 4 bytes of data bmph=asc(input$(#bmp,1))+asc(input$(#bmp,1))*256+asc(input$(#bmp,1))*65536+asc(input$(#bmp,1))*16777216 seek #bmp,28 'bits per pixel, ie color depth 2 bytes of data bits=asc(input$(#bmp,1))+asc(input$(#bmp,1))*256
'work out start of picture data and how to move through file pointer=offset
'work out how many bytes in the bits per pixel 24=3 bgr 32=4 abgr bytes=bits/8
'work out padding each raster line must be a 4byte multiple mult=bits/8*bmpw/4 padding = 4*(1-(mult-int(mult))) mod 4 close #bmp
redim bmp$(bmph,bmpw) for var = 1 to bmph bmp$(var,1)=" " next var
open file$ for binary as #bmp
for xx = 1 to bmph for yy = 1 to bmpw
Pixel$ = getPixel$( x, y) parse$ = Parse$(Pixel$, x ,y)
next yy variable = variable +1 print variable;"/";bmph next xx close #bmp [output] for var = 1 to bmph print bmp$(var,1) next var
notice "" goto [loadfile]
Function getPixel$( x, y)
y=(bmph-1)-y pointer=offset+x*bytes+y*(bmpw*bytes+padding) 'get pixel color stored as BGR Liberty needs RGB seek #bmp, pointer Blue=asc(input$(#bmp,1)) Green=asc(input$(#bmp,1)) Red=asc(input$(#bmp,1))
Pixel$ = str$(Red)+" "+str$(Green)+" "+str$(Blue)
End Function
Function Parse$(Pixel$, x, y)
if Pixel$ = "0 255 0" then bmp$(x,1)= bmp$(x,1)+"g," end if if Pixel$ = "255 255 0" then bmp$(x,1) = bmp$(x,1)+"s,"
end if if Pixel$ = "128 64 0" then bmp$(x,1) = bmp$(x,1)+"d," end if if Pixel$ = "0 0 255" then bmp$(x,1)= bmp$(x,1)+"w,"
end if
End Function
|
|
|
Post by Rod on Feb 15, 2021 22:48:54 GMT
Well why not store the texture in just one of the colours. Say the blue color. That lets you store 256 textures. You could just have an 8 bit bmp but it’s probably easier to leave it as a 24 bit bmp and ignore the red and blue or perhaps store other items in them.
But why bring it all into an array? Just leave it open on disc and use the getpixel function to query the map location. It will be super fast and save a lot of processing. You can also save or amend data live in the file.
Have not had time to debug what is wrong but you know it works so just take it a line at a time till you see the bug.
|
|
|
Post by Enzo on Feb 16, 2021 2:29:42 GMT
My file saving skills are beyond terrible I just tried to use your sprite creator code and cannot seem to get anything to save or it did save and my OS renders no access and im admin
|
|
|
Post by Rod on Feb 16, 2021 9:41:44 GMT
Ok, these three routines are all that you need to manage a large pixel based map. Open the bmp/map at the start of the program. Then use the getpixel and setpixel routines to know what texture to draw. I have not tested them but they are extracts from working code.
I would use blue to store the textures, that leaves green and red as bytes to store whatever you want in them, objects at a location say.
The map will load instantly and access during the program run will be very fast as you only access a few pixels at a time. You probably don't need any other array in your program.
global file$,mapw,maph,padding,offset,bytes,Blue,Green,Red
[loadbmp] file$="test.bmp" 'now open the bmp file for binary read/write access open file$ for binary as #bmp
'analyse the file header bytes seek #bmp,10 'picture data offset, where the color data starts 4 bytes of data offset=asc(input$(#bmp,1))+asc(input$(#bmp,1))*256+asc(input$(#bmp,1))*65536+asc(input$(#bmp,1))*16777216 seek #bmp,18 'width 4 bytes of data mapw=asc(input$(#bmp,1))+asc(input$(#bmp,1))*256+asc(input$(#bmp,1))*65536+asc(input$(#bmp,1))*16777216 seek #bmp,22 'height 4 bytes of data maph=asc(input$(#bmp,1))+asc(input$(#bmp,1))*256+asc(input$(#bmp,1))*65536+asc(input$(#bmp,1))*16777216 seek #bmp,28 'bits per pixel, ie color depth 2 bytes of data bits=asc(input$(#bmp,1))+asc(input$(#bmp,1))*256
'work out start of picture data and how to move through file pointer=offset
'work out how many bytes in the bits per pixel 24=3 bgr 32=4 abgr bytes=bits/8
'work out padding each raster line must be a 4byte multiple mult=bits/8*mapw/4 padding = 4*(1-(mult-int(mult))) mod 4 'close #bmp
function setpixel(x,y,r,g,b) 'raster lines are stored bottom up so we invert y y=(maph-1)-y pointer=offset+x*bytes+y*(mapw*bytes+padding) 'set pixel color seek #bmp, pointer #bmp chr$(b);chr$(g);chr$(r); end function
function getpixel(x,y) 'raster lines are stored bottom up so we invert y y=(maph-1)-y pointer=offset+x*bytes+y*(mapw*bytes+padding) 'get pixel color stored as BGR Liberty needs RGB seek #bmp, pointer Blue=asc(input$(#bmp,1)) Green=asc(input$(#bmp,1)) Red=asc(input$(#bmp,1)) end function
|
|
|
Post by Enzo on Feb 16, 2021 20:53:12 GMT
If setpixel and getpixel dont join logic wise how is Red and r, Blue and b gonna register?
I have not clue how to register data it seems data still at 0
Does setpixel 'set' the seek to the correct X Y, then how do I render the data to use
on second glance their the same function with only one difference do not see how using both is even possible?
|
|
|
Post by Enzo on Feb 16, 2021 21:00:57 GMT
Kinda sad JB can't be programmed to simple output a 1x1 .bmp file with a black square to be read as such
All these fancy code snippets and data still does not even be read from file correctly to be parsed
I might just ace this idea and start from fresh with a graphic box and array filled with "w" and edit array on mouse X Y into graphic box, seems more reliable then functions that are duplicates
|
|
|
Post by Enzo on Feb 16, 2021 21:19:23 GMT
Whole thing is making me feel stupid, its been a week and i havent done any coding or adding to game data because i cannot get a working sprite program made in JB or LB to produce a sprite to use in such IDEs programs seems like a dead language with non working to help updates.
I'm about to delete my thread contents and switch to another language this is beyond ridiculous
I have a friend who cannot walk or move his four fingers on each hand from an accident he had when he was 13. I am trying full-time to produce a second income for my friend and these hangups aren't helping considering im going down dead ends after dead ends. I remember a simple getpixelXYrbgfunction() that worked in earlier versions of JB not sure why we've gone the other way as a community of resources, currently I am seeking a new language I do not like feeling stupid because of the lack of complier error fixes, maybe sprites and bmps just wont load correctly in JB now has anyone produced a real program from 2.0 or am I the first idiot?
|
|