|
Post by Rod on Jun 9, 2020 7:18:46 GMT
If you use the quick response you wont see any panes, if you edit or respond in the thread you will see two panes a Preview pane and a BBCode pane. They are shown as tabs at the foot of the messagebox. Be sure you are in the BBCode pane before posting code using the [C] code tags. If you make a mistake and the code is double spaced move to the BBCode pane highlight all the code and either delete it or past over it.
|
|
|
Post by Enzo on Jun 21, 2020 20:21:06 GMT
' ' The Background seems to move, but I'm just changing the Images with the SpriteImage Command. ' It's faster and you don't need a large amount of sprites, allowing the creation of a ' big map. ' There are only 10*7 sprites composed by tiles (sprites). dim npc.x(100) dim npc.y(100) dim old.npc.x(100) dim old.npc.y(100) dim map$(100,100)
'NOMAINWIN TILESIZE = 64 : SCREENWIDTH = 11 : SCREENHEIGHT = 8 : OFFSET = TILESIZE GAMEWIDTH = SCREENWIDTH*TILESIZE-TILESIZE*2 GAMEHEIGHT = SCREENHEIGHT*TILESIZE-TILESIZE*2 WindowWidth = GAMEWIDTH : WindowHeight = GAMEHEIGHT+100 : BackgroundColor$ = "BLACK"
UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) graphicbox #main.gbx, 0, 0,GAMEWIDTH , GAMEHEIGHT textbox #main.textbox, 14, 400, 352, 25 open "JB-RPG" for window_nf as #main
#main.gbx "down; fill BLACK; flush" #main "trapclose [quit.main]"
#main.gbx "Getbmp empty.bmp 1 1 ";TILESIZE;" ";TILESIZE*2 [a] tile.list$ = "dirt water grass rock sand" For i = 1 To 5 loadbmp left$(word$(tile.list$,i),1);".bmp",word$(tile.list$,i);".bmp" #main.gbx "drawbmp ";left$(word$(tile.list$,i),1);".bmp 1 ";TILESIZE+1;" ; ";_ "Getbmp ";left$(word$(tile.list$,i),1);".bmp 1 1 ";TILESIZE;" ";TILESIZE*2 Next [b] player.list$ = "1.bmp 2.bmp 3.bmp 4.bmp ";_ "5.bmp 6.bmp 7.bmp 8.bmp" For i = 1 To 8 loadbmp "player";i;".bmp", Word$(player.list$,i) Next [c] #main.gbx "setfocus;" ;_ "When characterInput [keys]; ";_ "Getbmp back.bmp 1 1 10 10;" ;_ "Background back.bmp;" ;_ "DRAWSPRITES" [d] OPEN "map.txt" For input AS #mapfile
While not(eof(#mapfile)) line input #mapfile, itemdata$ id$=trim$(itemdata$) if left$(id$,1)<>"'" and id$<>"" Then Select case case instr(id$,"width") map.width = val( trim$(word$(id$,2,"="))) case instr(id$,"height") map.height = val( trim$(word$(id$,2,"="))) case instr(id$,"playerX") player.x = val( trim$(word$(id$,2,"="))) case instr(id$,"playerY") player.y = val( trim$(word$(id$,2,"="))) case instr(id$,"others") npc.n = val( trim$(word$(id$,2,"="))) IF npc.n>0 Then DIM npc.x(npc.n),npc.y(npc.n) DIM old.npc.x(npc.n),old.npc.y(npc.n) For L = 1 To npc.n line input #mapfile, id$ npc.sprite.name$(L) = WORD$(id$,1,";") npc.bmp.name$(L) = WORD$(id$,2,";") npc.x(L) = val(TRIM$(WORD$(id$,3,";"))) npc.y(L) = val(TRIM$(WORD$(id$,4,";"))) old.npc.x(L) = npc.x(L): old.npc.y(L) = npc.y(L) 'PRINT npc.bmp.name$ Next L End if case else DIM map$(map.width,map.height)
For y = 1 To map.height
For x = 1 To map.width
map$(x,y) = TRIM$(word$(id$,x,",")) 'PRINT map$(x,y) Next line input #mapfile, id$ if instr(id$,"END") Then exit FOR Next
end select End if Wend Close #mapfile
[e] ' 10 * 7 DIM tile(SCREENWIDTH*SCREENHEIGHT,2) for h = 1 To SCREENHEIGHT for w = 1 To SCREENWIDTH obj=obj+1 #main.gbx "addsprite obj";obj;" empty.bmp d.bmp w.bmp g.bmp r.bmp s.bmp" tile(obj,1)=w tile(obj,2)=h next:next [f] #main.gbx "addsprite player player1.bmp player2.bmp player3.bmp";_ " player4.bmp player5.bmp player6.bmp player7.bmp player8.bmp ;";_ "spritexy player ";player.x*TILESIZE-TILESIZE-OFFSET;" ";player.y*TILESIZE-TILESIZE-OFFSET [g] if npc.n Then For L = 1 To npc.n loadbmp npc.bmp.name$(L),npc.bmp.name$(L) #main.gbx "addsprite ";npc.sprite.name$(L);" ";npc.bmp.name$(L) #main.gbx "spritexy ";npc.sprite.name$(L);" ";npc.x(L)*TILESIZE-TILESIZE-OFFSET;_ " ";npc.y(L)*TILESIZE-TILESIZE-OFFSET Next End if
[reDo] text=loadtext() Timer 0 GOSUB [main.Branch] m=not(m) If m=-1 Then Gosub [npc.movement]
TIMER 23,[reDo]
WAIT
[main.Branch] GOSUB [moveMap]
player.y = player.y + INT(screen.y) map.y = map.y + INT(screen.y) player.x = player.x + INT(screen.x) map.x = map.x + INT(screen.x)
if abs(screen.y)>=1 Then screen.y = 0 if abs(screen.x)>=1 Then screen.x = 0 #main.gbx "DRAWSPRITES" RETURn
[keys] Timer 0 #main.gbx "When characterInput"
k$ = Inkey$ : keyValue = asc(right$(k$, 1))
' all the tiles will move before changing the array walk.val = .5'.5
select case keyValue
case _VK_DOWN
if player.y + 1 < map.height Then new.pos$ = map$(player.x,player.y+1) If new.pos$<>"r" and new.pos$ <>"w" Then screen.y = screen.y + walk.val Else screen.y=0 End if spi = abs(not(spi)) #main.gbx "spriteImage player player";1+spi;".bmp" End if
case _VK_UP
if player.y - 1 >0 Then new.pos$=map$(player.x,player.y-1) If new.pos$<>"r" and new.pos$ <>"w" Then screen.y = screen.y - walk.val Else screen.y=0 End if spi = abs(not(spi)) #main.gbx "spriteImage player player";3+spi;".bmp" End if case _VK_LEFT if player.x - 1 > 0 Then new.pos$ = map$(player.x-1,player.y) If new.pos$<>"r" and new.pos$ <>"w" Then screen.x = screen.x - walk.val Else screen.x = 0 End if spi = abs(not(spi)) #main.gbx "spriteImage player player";5+spi;".bmp" End if case _VK_RIGHT if player.x +1 < map.width Then new.pos$ = map$(player.x+1,player.y) If new.pos$<>"r" and new.pos$ <>"w" Then screen.x = screen.x + walk.val Else screen.x=0 End if spi = abs(not(spi)) #main.gbx "spriteImage player player";7+spi;".bmp" End if case _VK_ESCAPE goto [quit.main] case _VK_CONTROL
print #main.textbox, "!contents? textchat$"; textchatt$ = textchat$ print #main.textbox, "!disable" o$ = textfile(textchatt$) print #main.textbox, "" print #main.textbox, "!enable" 'admin commands 'if left$(char$) = @ then open admin commands
end select
' if npc.x(1) = player.x AND npc.y(1)=player.y Then ' PRINT "collision" 'End if 'For L = 1 To npc.n 'npc.x(L) = npc.x(L) - INT(screen.x) 'npc.y(L) = npc.y(L) - INT(screen.y) 'Next GOSUB [main.Branch] #main.gbx "When characterInput [keys]" GOTO [reDo]
WAIT
[moveMap]
For i =1 To obj SCAN w = tile(i,1) h = tile(i,2) if walk.val<1 Then #main.gbx "Spritexy obj";i;" ";_ w*TILESIZE-TILESIZE - (screen.x*TILESIZE) - OFFSET; " ";_ h*TILESIZE-TILESIZE - (screen.y*TILESIZE) - OFFSET End if If map.x+w< map.width AND map.x+w>0 AND _ map.y+h < map.height AND map.y+h>0 Then #main.gbx "SpriteImage obj";i;" "; map$(w+map.x,h+map.y);".bmp" For L=1 to npc.n #main.gbx "spritexy ";npc.sprite.name$(L);" ";_ (npc.x(L)-map.x-screen.x)*TILESIZE-TILESIZE - OFFSET ;" ";_ (npc.y(L)-map.y-screen.y)*TILESIZE-TILESIZE - OFFSET NEXT L
Else ' set the tiles to an empty image #main.gbx "SpriteImage obj";i;" empty.bmp"
End if Next
RETURN
[npc.movement] 'npc random movement: For L = 1 to npc.n
random.move.x= INT(rnd(0)*3)-1 random.move.y= INT(rnd(0)*3)-1 if random.move.x+npc.x(L)<map.width AND random.move.y+npc.y(L)<map.height AND _ random.move.x+npc.x(L)>0 AND random.move.y+npc.y(L)>0 Then
if INT(rnd(0)*2) =0 Then npc.x(L)=npc.x(L) + random.move.x Else npc.y(L)=npc.y(L) + random.move.y End if select case map$(npc.x(L),npc.y(L)) case "w","r" npc.x(L)=old.npc.x(L) npc.y(L)=old.npc.y(L) case else old.npc.x(L)=npc.x(L) old.npc.y(L) =npc.y(L) end select
End if
NEXT RETURN
'------------------------------------------------------------------------ '------------------------------------------------------------------------ ' ' '------------------------------------------------------------------------ '--. Function timemsg() lasttime=time time = time$("ms") timesg=lasttime-time 'display on disabled box End Function
Function textfile$(textchat$) if textchat$ <> "" then open "text.txt" for output as #uploads print #uploads, time$("ms") print #uploads, textchat$ close #uploads end if End Function
Function loadtext() open "text1.txt" for input as #text input #text, item$ input #text, item2$ close #text print item$ print item2$ End Function
[quit.main] unloadbmp "back.bmp" unloadbmp "empty.bmp" for i = 1 To 4 unloadbmp left$(word$(tile.list$,i),1);".bmp" Next for i = 1 TO 8 unloadbmp "player";i;".bmp" next
if npc.n Then FOr L = 1 To npc.n unloadbmp npc.bmp.name$(L) NExt End if
Close #main END
|
|
|
Post by Rod on Jun 22, 2020 18:14:38 GMT
Not really sure what you are showing us here.
|
|
|
Post by Enzo on Jun 22, 2020 20:05:28 GMT
was trying to understand how to add more tiles to map file, basically posted a clean copy of what im working on with a chat type input started, at least this will play via LAN Adding a 'object' / or NPC that doesn't move 'near support or "facing" object to pickup', inventory system array Seperate from Adding another player with integration for "output input file server loop", im fairly confident in JB's power to quickly operate reading and writing of files with number of LAN clients
|
|
|
Post by Enzo on Jun 22, 2020 20:15:10 GMT
A lot from there, can be done with a animation function system for gfx effects, multi-threaded though I haven't a clue how to start... but willing to learn!
This is the proof of concept chat-relay-script ment to run via .bas mainwin; [X] to close, to start properly one must rename player.list$ to match proper .bmps, run code, press CTRL after typing in the bar AND clicking back on screen (this last part is actually quite common of videogames with chats build in!), then starting the relaying-script, files need to be inplace before-hand.
print "chatscript" [loop] timer 51, [looper] wait
[looper] timer 0 open "text.txt" for input as #uploads input #uploads, currenttime$ input #uploads, textchat$ close #uploads array$(1)=currenttime$ array$(2)=textchat$ open "text1.txt" for append as #text print #text, array$(1) print #text, array$(2) close #text goto [loop]
|
|
|
Post by cundo on Jun 22, 2020 21:59:26 GMT
Where do you want to have more tiles? At screen, the numbers of drawn tiles?
|
|
|
Post by Enzo on Jun 23, 2020 3:14:12 GMT
map.txt file, I tried editing the mapwidth and height kept getting a out of range map$(30) even with dim map$(100,100), maybe I was off on my count, I did edit and add more data to correspond with the edited map width/height
I basically want to create a simple sprite creator-uploader included in seperate GUI to automatically add 100% into game arrays and loading file
nomainwin WindowWidth = 168 WindowHeight = 140 graphicbox #main.sixfour, 6, 6, 64, 64 button #main.button2, "Add", [gatherdataadd], UL, 78, 16, 64, 50 statictext #main.statictext4, "Credit to cundo", 6, 76, 144, 20 statictext #main.statictext5, "JB forums", 6, 91, 144, 20 statictext #main.statictext6, "JustBASIC 2.0", 70, 91, 144, 20 open "Add .bmp file to game" for dialog_nf_modal as #main print #main.sixfour,"down; fill black; flush" print #main, "trapclose [quit.main]" print #main, "font ms_sans_serif 10" 'FILEDIALOG "" wait [quit.main] Close #main END [gatherdataadd] 'LOAD BMP INTO ARRAY wait
~ Enzo
|
|
|
Post by Rod on Jun 23, 2020 11:25:03 GMT
Enzo, if you want folks to comment and participate or even help debug you are going to have to show runnable code. That might mean zipping everything and just posting a link to the .zip.
As it stands, without the resource files, text and bmps etc I don't think many folks will look at the code.
|
|
|
Post by Enzo on Jun 23, 2020 16:06:27 GMT
Rod, okay Updated, did not include chatscript as it's a infinity loop and not apart of the current code. Plus I believe those types of loops are not allowed on forums unless labeled and put in tags, however is there anyway to accept userinput in the loop to cancel, im guessing a simple GUI would do the trick here? Adds: - [labels] for start up int for easier editing purposes and for a realistic loading screen - Command, example "@map XXYY VAR$" (need intergration into editing input into game arrays$(), commands for objects and NPCs) -.bmp loader screen and button (needs to load bmp and turn into sprite) -Chat input box and coding to file (not sure if going to have chat window or just display above character) Need to work on: - Pickup object and object support - Tile sensor - Mass sprite tool 64 x 64 *-Timer function prepration for networking I left out NPC chat because thats minor, adding in the GFX I hope can be done via "playing the game" with 'admin commands', without slaughtering up the code layout, as some type of combat type magic maybe player to player; is going to need theaded, animation and keeping the loop simple is key, to adding a few ms here, and there where it "feels" good to play. *Also my timer(debug) function was not working properly so I took it out, seems like simple math; however, this is the same spot I got hung up on years ago when first attempting this Attachments:draft.zip (30.33 KB)
|
|
|
Post by Enzo on Jun 24, 2020 22:28:17 GMT
Updated:
Looking for a mass sprite tool that was created by a user here, a Mod or Admin I believe, was on conforums, basically the hard part was converting simple images with true black into a slightly different color RGB wise 001, unless JustBasic sprite support is different now?
EDITED: I was ABLE to swap a tile ingame with a simple line change
At the bottom of nested _VK CONTROL include map$(xmap,ymap)=mapcommandtile$ and ingame input @map 0101 g
It will change upper left tile from water to grass
~ Enzo
|
|
|
Post by cundo on Jun 25, 2020 0:59:08 GMT
' The Background seems to move, but I'm just changing the Images with the SpriteImage Command. ' It's faster and you don't need a large amount of sprites, allowing the creation of a ' big map. ' There are only 10*7 sprites composed by tiles (sprites). dim npc.x(100) dim npc.y(100) dim old.npc.x(100) dim old.npc.y(100) dim map$(100,100) timesetup=1
'NOMAINWIN TILESIZE = 64 : SCREENWIDTH = 11 : SCREENHEIGHT = 8 : OFFSET = TILESIZE GAMEWIDTH = SCREENWIDTH*TILESIZE-TILESIZE*2+64 GAMEHEIGHT = SCREENHEIGHT*TILESIZE-TILESIZE*2 WindowWidth = GAMEWIDTH : WindowHeight = GAMEHEIGHT+100 : BackgroundColor$ = "BLACK"
UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) button #main.bmpbutton, "bmp", [bmp], UL, 10, 10 graphicbox #main.gbx, 64, 0,GAMEWIDTH , GAMEHEIGHT textbox #main.textbox, 14, 400, 352, 25 open "JB-RPG" for window_nf as #main
#main.gbx "down; fill BLACK; flush" #main "trapclose [quit.main]"
#main.gbx "Getbmp empty.bmp 1 1 ";TILESIZE;" ";TILESIZE*2 [a] tile.list$ = "dirt water grass rock sand" For i = 1 To 5 loadbmp left$(word$(tile.list$,i),1);".bmp",word$(tile.list$,i);".bmp" #main.gbx "drawbmp ";left$(word$(tile.list$,i),1);".bmp 1 ";TILESIZE+1;" ; ";_ "Getbmp ";left$(word$(tile.list$,i),1);".bmp 1 1 ";TILESIZE;" ";TILESIZE*2 Next [b] player.list$ = "1.bmp 2.bmp 3.bmp 4.bmp ";_ "5.bmp 6.bmp 7.bmp 8.bmp" For i = 1 To 8 loadbmp "player";i;".bmp", Word$(player.list$,i) Next [c] #main.gbx "setfocus;" ;_ "When characterInput [keys]; ";_ "Getbmp back.bmp 1 1 10 10;" ;_ "Background back.bmp;" ;_ "DRAWSPRITES" [d] OPEN "map.txt" For input AS #mapfile
While not(eof(#mapfile)) line input #mapfile, itemdata$ id$=trim$(itemdata$) if left$(id$,1)<>"'" and id$<>"" Then Select case case instr(id$,"width") map.width = val( trim$(word$(id$,2,"="))) case instr(id$,"height") map.height = val( trim$(word$(id$,2,"="))) case instr(id$,"playerX") player.x = val( trim$(word$(id$,2,"="))) case instr(id$,"playerY") player.y = val( trim$(word$(id$,2,"="))) case instr(id$,"others") npc.n = val( trim$(word$(id$,2,"="))) IF npc.n>0 Then DIM npc.x(npc.n),npc.y(npc.n) DIM old.npc.x(npc.n),old.npc.y(npc.n) For L = 1 To npc.n line input #mapfile, id$ npc.sprite.name$(L) = WORD$(id$,1,";") npc.bmp.name$(L) = WORD$(id$,2,";") npc.x(L) = val(TRIM$(WORD$(id$,3,";"))) npc.y(L) = val(TRIM$(WORD$(id$,4,";"))) old.npc.x(L) = npc.x(L): old.npc.y(L) = npc.y(L) 'PRINT npc.bmp.name$ Next L End if case else
DIM map$(map.width,map.height) ' print map.width, map.height For y = 1 To map.height
For x = 1 To map.width print x, id$ map$(x,y) = TRIM$(word$(id$,x,",")) 'PRINT map$(x,y) Next line input #mapfile, id$ if instr(id$,"END") Then exit FOR Next
end select End if Wend Close #mapfile
[e] ' 10 * 7 DIM tile(SCREENWIDTH*SCREENHEIGHT,2) for h = 1 To SCREENHEIGHT for w = 1 To SCREENWIDTH obj=obj+1 #main.gbx "addsprite obj";obj;" empty.bmp d.bmp w.bmp g.bmp r.bmp s.bmp" tile(obj,1)=w tile(obj,2)=h next:next [f] #main.gbx "addsprite player player1.bmp player2.bmp player3.bmp";_ " player4.bmp player5.bmp player6.bmp player7.bmp player8.bmp ;";_ "spritexy player ";player.x*TILESIZE-TILESIZE-OFFSET;" ";player.y*TILESIZE-TILESIZE-OFFSET [g] if npc.n Then For L = 1 To npc.n loadbmp npc.bmp.name$(L),npc.bmp.name$(L) #main.gbx "addsprite ";npc.sprite.name$(L);" ";npc.bmp.name$(L) #main.gbx "spritexy ";npc.sprite.name$(L);" ";npc.x(L)*TILESIZE-TILESIZE-OFFSET;_ " ";npc.y(L)*TILESIZE-TILESIZE-OFFSET Next End if
[reDo] 'text=loadtext() Timer 0 GOSUB [main.Branch] m=not(m) If m=-1 Then Gosub [npc.movement]
TIMER 17,[reDo]
WAIT
[main.Branch] GOSUB [moveMap]
player.y = player.y + INT(screen.y) map.y = map.y + INT(screen.y) player.x = player.x + INT(screen.x) map.x = map.x + INT(screen.x)
if abs(screen.y)>=1 Then screen.y = 0 if abs(screen.x)>=1 Then screen.x = 0 #main.gbx "DRAWSPRITES" RETURN
[keys] Timer 0 #main.gbx "When characterInput"
k$ = Inkey$ : keyValue = asc(right$(k$, 1))
walk.val = .5'adds stepped input
select case keyValue
case _VK_DOWN
if player.y + 1 <= map.height Then new.pos$ = map$(player.x,player.y+1) If new.pos$<>"r" and new.pos$ <>"w" Then screen.y = screen.y + walk.val Else screen.y=0 End if spi = abs(not(spi)) #main.gbx "spriteImage player player";1+spi;".bmp" End if
case _VK_UP
if player.y - 1 >0 Then new.pos$=map$(player.x,player.y-1) If new.pos$<>"r" and new.pos$ <>"w" Then screen.y = screen.y - walk.val Else screen.y=0 End if spi = abs(not(spi)) #main.gbx "spriteImage player player";3+spi;".bmp" End if case _VK_LEFT if player.x - 1 > 0 Then new.pos$ = map$(player.x-1,player.y) If new.pos$<>"r" and new.pos$ <>"w" Then screen.x = screen.x - walk.val Else screen.x = 0 End if spi = abs(not(spi)) #main.gbx "spriteImage player player";5+spi;".bmp" End if case _VK_RIGHT if player.x +1 <= map.width Then new.pos$ = map$(player.x+1,player.y) If new.pos$<>"r" and new.pos$ <>"w" Then screen.x = screen.x + walk.val Else screen.x=0 End if spi = abs(not(spi)) #main.gbx "spriteImage player player";7+spi;".bmp" End if case _VK_ESCAPE goto [quit.main] case _VK_CONTROL 'chat input CTRL instead of ENTER" print #main.textbox, "!contents? textchat$"; outputchat$ = textchat$ print #main.textbox, "!disable" o = outputchat(outputchat$) print #main.textbox, "" print #main.textbox, "!enable" 'admin commands need to be restyled into funtionableility if left$(outputchat$, 4) = "@map" then n = n + 1 inputmap$(n) = word$(outputchat$,2) inputmap$ = inputmap$(n) xmap= val(left$(inputmap$, 2)) ymap= val(right$(inputmap$, 2)) mapcommandtile$ = word$(outputchat$, 3) command$ = str$(xmap);" ";str$(ymap);" ";mapcommandtile$ 'update data print ":COMMANDISSUED:SET>MAP X Y tileRefID$: ";command$ end if textchat$="" end select
' if npc.x(1) = player.x AND npc.y(1)=player.y Then ' PRINT "collision" 'End if 'For L = 1 To npc.n 'npc.x(L) = npc.x(L) - INT(screen.x) 'npc.y(L) = npc.y(L) - INT(screen.y) 'Next GOSUB [main.Branch] #main.gbx "When characterInput [keys]" GOTO [reDo]
WAIT
[moveMap]
For i =1 To obj SCAN w = tile(i,1) h = tile(i,2) if walk.val<1 Then #main.gbx "Spritexy obj";i;" ";_ w*TILESIZE-TILESIZE - (screen.x*TILESIZE) - OFFSET; " ";_ h*TILESIZE-TILESIZE - (screen.y*TILESIZE) - OFFSET End if If map.x+w<= map.width AND map.x+w>0 AND _ map.y+h <= map.height AND map.y+h>0 Then #main.gbx "SpriteImage obj";i;" "; map$(w+map.x,h+map.y);".bmp" For L=1 to npc.n #main.gbx "spritexy ";npc.sprite.name$(L);" ";_ (npc.x(L)-map.x-screen.x)*TILESIZE-TILESIZE - OFFSET ;" ";_ (npc.y(L)-map.y-screen.y)*TILESIZE-TILESIZE - OFFSET NEXT L
Else ' set the tiles to an empty image #main.gbx "SpriteImage obj";i;" empty.bmp"
End if Next
RETURN
[npc.movement] 'npc random movement: For L = 1 to npc.n
random.move.x= INT(rnd(0)*3)-1 random.move.y= INT(rnd(0)*3)-1 if random.move.x+npc.x(L)<map.width AND random.move.y+npc.y(L)<map.height AND _ random.move.x+npc.x(L)>0 AND random.move.y+npc.y(L)>0 Then
if INT(rnd(0)*2) =0 Then npc.x(L)=npc.x(L) + random.move.x Else npc.y(L)=npc.y(L) + random.move.y End if select case map$(npc.x(L),npc.y(L)) case "w","r" npc.x(L)=old.npc.x(L) npc.y(L)=old.npc.y(L) case else old.npc.x(L)=npc.x(L) old.npc.y(L) =npc.y(L) end select
End if
NEXT RETURN
[bmp] WindowWidth = 168 WindowHeight = 140 graphicbox #bmp.sixfour, 6, 6, 64, 64 statictext #bmp.credit1, "Credit to cundo", 6, 76, 144, 20 statictext #bmp.credit2, "JB forums", 6, 91, 144, 20 statictext #bmp.credit3, "JustBASIC 2.0", 70, 91, 144, 20 open "Add .bmp file to game" for dialog_nf_modal as #bmp print #bmp.sixfour,"down; fill white; flush" print #bmp, "trapclose [quit.bmp]" print #bmp, "font ms_sans_serif 10" [startbmpdialog] FILEDIALOG "Open & add new .bmp to game!", "*.bmp", bmpfile$ 'display bmp
confirm "Keep .BMP?"; yesno$ if yesno$ = "no" then goto [quit.bmp] else keep$=yesno$ end if
'turn into sprite 'add to new tile data array 'wait for admin command to change value '@map XXYY aVar$ = command$
[quit.bmp] Close #bmp goto [reDo]
[quit.main] unloadbmp "back.bmp" unloadbmp "empty.bmp" for i = 1 To 4 unloadbmp left$(word$(tile.list$,i),1);".bmp" Next for i = 1 TO 8 unloadbmp "player";i;".bmp" next
if npc.n Then FOr L = 1 To npc.n unloadbmp npc.bmp.name$(L) NExt End if
Close #main END '------------------------------------------------------------------------ '------------------------------------------------------------------------ ' ' Functions '------------------------------------------------------------------------
Function outputchat(textchat$) if textchat$ <> "" then open "text.txt" for output as #uploads print #uploads, time$("ms");" ";textchat$ close #uploads end if End Function
|
|
|
Post by cundo on Jun 25, 2020 1:03:44 GMT
I have changed the comparison lines from:
map.x+w < map.width to map.x+w <= map.width Did the same with the height and player movement boundaries. Now change map.txt, change the width and height parameters then edit the map lines adding grass for example ie: ,g
|
|
|
Post by Enzo on Jun 25, 2020 3:39:20 GMT
Any idea on a very simple object support?
|
|
|
Post by Rod on Jun 25, 2020 14:37:37 GMT
An object is just another player in the game though more static. Can be lifted, owned, moved, used, given up or dropped. So just player data/status.
|
|
|
Post by Enzo on Jun 25, 2020 20:50:04 GMT
You are right, I was able to add these lines in the [moveMap] under "NEXT L"
for items = 1 to itemcount #main.gbx "spritexy ";npc.sprite.name$(items);" ";_ (item.x(items)-map.x-screen.x)*TILESIZE-TILESIZE - OFFSET ;" ";_ (item.y(items)-map.y-screen.y)*TILESIZE-TILESIZE - OFFSET next items
item.x(1)= 4 item.y(1)= 4 itemcount=1
Added a 'king' to the outside egde of map
~ Enzo
|
|