|
Post by Rod on Jan 27, 2021 8:07:36 GMT
Enzo if you get back to coding you will be very welcome here. We should try a new start, keep it simple and get each stage working as you want it. Coding is good for you! Stick at it.
|
|
|
Post by Enzo on Feb 13, 2021 4:40:35 GMT
*link edited*
0.5 alpha heavily commented
|
|
|
Post by Rod on Feb 13, 2021 9:38:16 GMT
I did not see any .bas in that link so I just used the last one you posted.
I had a quick look. I think a lot of the problems stem from the GLOBAL values you have set. You are both setting as GLOBAL and passing to functions and subs. Take this example that was failing.
function loadmaptiles$(i, tile.list$, TILESIZE) 'credit to cundo for this function For n = 1 To 5 loadbmp word$(tile.list$,n),word$(tile.list$,n)+".bmp" #main.gbx "drawbmp ";word$(tile.list$,n);" 1 ";TILESIZE+1;" ; ";_ "Getbmp ";word$(tile.list$,n);" 1 1 ";TILESIZE;" ";TILESIZE*2 Next end function
There was a couple of things wrong. You had added ".bmp" in places it was not needed. Good tip is to print out those types of command line to see what they actually look like. Also you passed in i, a global variable, so there was no need to pass it and you also set i as the for next index. So the compiler gets confused. No need to pass in i, though it probably should not be global anyway. I set the for next index to n and got rid of the extra ".bmp" and it works now.
I think you have the same problem in other places.
|
|
|
Post by Enzo on Feb 13, 2021 21:18:10 GMT
*sigh* I had to upload twice due to a misclick and did indeed forget to click on the .bas because I was having a lot of trouble finding a upload site that allows for multiple file selection. Go figure it was one at a time, here's the .bas link and should be last file needed, all bugs figured out as of right now.
*link edited*
Even now globals are not 'true' to syntax but that area you pointed to Rod has been revised, I believe anything un global'd or function called is a non-used function currently, no item support or attacking npcs, have movement, map, objects, starting with items
I am having trouble with my sprites and mask creators, I've tried two and they all give the same output, as you can see ingame they're just not true masks, I might need to edit a mask creator to a any non white pixel, give the mask and reverse for solid white pixels. Maybe this has already been done?
I've revised map creation and going to make a parse program for a bmp; colors = different types of squares i.e green = grass blue = water ect.
bmphX bmpwY = mapX mapY
|
|
|
Post by Enzo on Feb 13, 2021 22:03:23 GMT
Also theory of concept but if the direction$() function could have a parse for any 1 point away of X Y but still have directions pair up, i.e. up to down left to right because the map does not rotate I think this would allow for a
OXX XOX XXX
Type attacks, where 0 is each npc/player has to at least face the person, 'far attacks like magic and bow arrow animations will be done differently, most likely a traveling sprite that's static like an npc, until it hits something or 'wears our'
|
|
|
Post by Enzo on Feb 14, 2021 0:08:13 GMT
'Sprite Mask
dim bmp$(1000,1000) global blue,green,red,x,y,Pixel$ nomainwin [loadfile] bmph =0 bmpw =0 red =0 blue =0 green=0 x =0 y=0 Pixel$="" s$="" string$ = "" y$=""
filedialog "", ".bmp", string$ if string$ = "" then confirm "";y$ if y$="y" then string = 2 string = string + 1 if string=2 then end end if end if 'null=null null open string$ for binary as #bmp seek #bmp,10 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)) pointer=offset bytes=bits/8 mult=bits/8*bmpw/4 padding = 4*(1-(mult-int(mult))) mod 4 close #bmp
redim bmp$(bmph,bmpw) open string$ for input as #gpv s$ = input$(#gpv, lof(#gpv)) close #gpv [main] for x = 1 to bmph for y = 1 to bmpw
Pixel$ = Pixel$(s$, y, x) parse$ = Parse$(Pixel$, x ,y)
next y next x
[output] bmpstring$=string$ loadbmp bmpstring$, string$ WindowWidth = bmpw+10 : WindowHeight = bmph*2+15 : BackgroundColor$ = "BLACK" UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) graphicbox #handle.g, 0, 0,bmpw , bmph open "Sprite" for window_nf as #handle
print #handle.g, "drawbmp ";bmpstring$;" 0 ";bmph*2 'draw image print #handle.g, "goto 1 1" for x = 1 to bmph for y = 1 to bmpw
print #handle.g, "goto ";x;" ";y print #handle.g, "color ";bmp$(x,y) print #handle.g, "down" print #handle.g, "UP"
next y next x
count = count + 1 count$= str$(count) bmpsave count$, count$;".bmp"
notice "yes" close #main
goto [loadfile]
Function Pixel$(s$, x, y)
if asc(mid$(s$, 29, 1)) = 32 then red = asc(mid$(s$, 69, 1)) green = asc(mid$(s$, 68, 1)) blue = asc(mid$(s$, 67, 1)) end if
Pixel$ = str$(red)+" "+str$(green)+" "+str$(blue)
End Function
Function Parse$(Pixel$, x, y)
if Pixel$ = "0 0 0" then bmp$(x,y)= "255 255 255" print "255 to 0" end if if Pixel$ = "255 255 255" then bmp$(x,y) = "0 0 0" print "0 to 255" else bmp$(x,y)= "0 0 0" print "non 255 0 to 0" end if
End Function
How do I remove the front part of an opened .bmp filename will not let me show from name picked from file dialog
string$='C:/folder/file.bmp" string$ will not allow for bmp draw
|
|
|
Post by Enzo on Feb 14, 2021 0:47:46 GMT
Update
'Sprite Mask
dim bmp$(1000,1000) global blue,green,red,x,y,Pixel$ nomainwin [loadfile] count = 20 bmph =0 bmpw =0 red =0 blue =0 green=0 x =0 y=0 Pixel$="" s$="" string$ = "" y$=""
filedialog "", ".bmp", string$ if string$ = "" then confirm "";y$ if y$="y" then string = 2 string = string + 1 if string=2 then end end if end if 'null=null null open string$ for binary as #bmp seek #bmp,10 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)) pointer=offset bytes=bits/8 mult=bits/8*bmpw/4 padding = 4*(1-(mult-int(mult))) mod 4 close #bmp
redim bmp$(bmph,bmpw) open string$ for input as #gpv s$ = input$(#gpv, lof(#gpv)) close #gpv [main] for x = 1 to bmph for y = 1 to bmpw
Pixel$ = Pixel$(s$, y, x) parse$ = Parse$(Pixel$, x ,y)
next y next x
[output] var = var + 1 bmpstring$=str$(var) loadbmp bmpstring$+".bmp", string$ WindowWidth = bmpw : WindowHeight = bmph*2 : BackgroundColor$ = "BLACK" UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) graphicbox #handle.g, 0, 0, bmpw , bmph open "Sprite" for window_nf as #handle
print #handle.g, "drawbmp ";bmpstring$;".bmp 0 ";bmph*2 'draw image
print #handle.g, "goto 1 1" for x = 1 to bmph for y = 1 to bmpw
print #handle.g, "goto ";x;" ";y print #handle.g, "color ";bmp$(x,y) print #handle.g, "down" print #handle.g, "UP"
next y next x notice ""
count$= str$(count) print #handle.g, "getbmp ";count$;" 0 0 ";bmpw;" ";bmph*2 bmpsave count$, count$;".bmp"
count = count + 1 notice "yes" close #handle
goto [loadfile]
Function Pixel$(s$, x, y)
if asc(mid$(s$, 29, 1)) = 32 then red = asc(mid$(s$, 69, 1)) green = asc(mid$(s$, 68, 1)) blue = asc(mid$(s$, 67, 1)) end if
Pixel$ = str$(red)+" "+str$(green)+" "+str$(blue)
End Function
Function Parse$(Pixel$, x, y)
if Pixel$ = "0 0 0" then bmp$(x,y)= "255 255 255" print "255 to 0" end if if Pixel$ = "255 255 255" then bmp$(x,y) = "0 0 0" print "0 to 255" else bmp$(x,y)= "0 0 0" print "non 255 0 to 0" end if
End Function
|
|
|
Post by Rod on Feb 14, 2021 9:20:41 GMT
I got the latest .bas but it is missing the map.txt file. While you are debugging and asking for help it would be a good idea to do this. Put all of the files that your program uses including the .bas file into a folder, call that folder PixelMud. Check that it runs ok by running the copy of the .bas you have in PixelMud. Make sure you have not used any paths in your code. If all the files are in one folder they wont be needed. That really helps when you distribute the game because no one will have the same directory structure as you.
Now you have it all in PixelMud and checked that it runs, do this. Right click on the PixelMud folder and select Send To then Compressed zipped folder. Windows will create anew .zip file that looks like a folder called PixelMud.zip
Now all you have to do is distribute that one file. Put that one file on your file share site.
Second thing is that I rarely create sprites live. There is a good utility that ships with Just BASIC called SpriteMask. It will take the bmp and create the correct mask doubling the height of the .bmp. Save that .bmp away as your sprite image. Then you simply need to loadbmp it and use it as a sprite. Nothing else required. Sprites need a black and white mask the exact same shape as the colors to function correctly. This will take a lot of hassle out of your code.
|
|
|
Post by Rod on Feb 14, 2021 9:22:21 GMT
I am not sure what is working for you and what is not. If you still have a bug .zip it bug and all as I explained above. Then we will find it a lot easier to help you.
|
|
|
Post by Enzo on Feb 14, 2021 21:30:57 GMT
Okay I was trying to give people the option of a non-zip file, but heres a zip, thats been confirmed, extracted, and compiled verison 0.7 alpha. filebin.net/qzvlty9cl6tyn9ql
|
|
|
Post by Enzo on Feb 14, 2021 21:49:30 GMT
Can't seem to find sprite mask in jb folder
I'd like to find one I can edit to a flashy console input for an entire directory and resave with new file name and location, this way I can set and forget the 700 .bmp sprites come back to index'd folders with copy and paste code to add to my engine, i.e. array data and sprite bmp load.
|
|
|
Post by Rod on Feb 15, 2021 8:08:45 GMT
Open explorer, key in %appdata% to the search box at the top. Now navigate to Just BASIC v2 folder. That’s the app data folder you are in. The sprite mask .bas should be in there. Forget the idea of distributing .bmp and then making sprites on the users pc. Making masks for 700 .bmps is going to take a long time. Do that on your pc then simply distribute sprite.bmp. To automate the process you need to code in the Files statement. Have a browse here, I show how to list file names. Use each name to feed the sprite ask code and output the sprite to a new directory. libertybasiccom.proboards.com/thread/1505/files-commandWill code a demo when I get a bit of time. Not had a look at your .zip yet. Anything not working that you need help with?
|
|
|
Post by Enzo on Feb 15, 2021 9:09:09 GMT
Seems my direction$() function may not be 100% working correctly? Was getting some off numbers
I might relabel sprites from 1-700.bmp and load via for next loop for simplicity, a lot of sprites need to be open and cropped anyways. It'll be a few hours work, and im not sure if justbasic has ram support over 100MB for sprites in which case im locked in at max items.
Hmm im running windows xp thru oracle virtual box installed JB 2.0 and still see no sprite mask bas could someone copy and paste the infomation, maybe carl has added a new verison update and forgot to add? Recent download from JB main site a couple days ago to install fresh onto a fresh Virtual OS nothing with the word Mask in it. I am viewing C:/programfiles/justbasic2.0/
|
|
|
Post by Rod on Feb 15, 2021 9:20:08 GMT
My mistake, sprite mask is a Liberty BASIC utility and uses an API call. An alternative is here jbfilesarchive.com/phpBB3/download/file.php?id=1644You could probably tweak Andy's code. I also have Sprite Creator and there is code in that for masking sprites. If I get time I will hack out the mask creation code and front it with a files command. The sprites and .bmp remain on disc in the main so there is no memory limit to trouble you. During the game you should load and unload .bmp resources to manage memory.
|
|
|
Post by Enzo on Feb 15, 2021 9:37:43 GMT
Any idea on how to make a large map load faster, a 500x500 map takes a long time to load..
Alas it did load!And its fast! Took 60 + seconds, also experienced a lockout "non" responsive around when it read the map file.
Maybe at least updating a graphic on screen to show its still loading will prevent lockout? Ah yes I needed a refresh on unload bmps and mem swap, should be no problem then.
I will try the sprite creator now.
For reference it took about 40 seconds to reach a couple hundred tiles deep, then my sea( function dimmed at 500 gave an error, non the less making it a larger number will stop that.
Edit still same error outlines with white, im gonna try and edit it to work, or take a look at your sprite creator and use partial snippet
|
|