|
Post by Enzo on Nov 6, 2020 22:55:50 GMT
Lol this crashes instantly on code added from another JB window that worked
'credit to cundo for the framework, JustBASIC.proforums.com/ -2020 October 29th 9PM 'r]pg game base by Enzo
'Copy and Paste code for var * a second ; debug pauser of 10 seconds: gosub [debugpause] global var var = 10
'study the code to learn how to play\
global mapX, mapY, totalitems, objcount, div, clientcount clientcount = 10 'number of max clients mapX=100:mapY=100:totalitems=10:objcount=10:div=2:lag=100 '5 sprites of 10 images each
dim npc.x(100) dim npc.y(100) dim old.npc.x(100) dim old.npc.y(100) dim map$(mapX,mapY) dim tile(20,20)'testxy
dim room(3) room(1) = 1 room(2) = 2 room(3) = 3
dim attacktime(5) 'attack rythm medium, short, long, mid, very short, medium, short, long, mid, ect. attacktime(1)=15 attacktime(2)=-10 attacktime(3)=20 attacktime(4)=10 attacktime(5)=-20
'dim mapitems(MAPX,MAPY) dim item(totalitems,3) '1 =unsed 2=type 3=unsed dim mapitem(mapX,mapY) dim itemdisplay(totalitems, 2)
dim objdisplay(objcount, 2) dim objdisplay2(objectcount, 2)
dim inventory(8) dim bank(10)
dim specialattack(4)
dim playerfiles$(clientcount, 4) '1=health, 3=hit, 2=npc graphic
global playerfile$, downloadfile$, PID, myPID, x, y, player.x, player.y, yes, debug, startup, frames, PIDid, command$, commandtype$, inputcommand$, playercount,_ playerpos$, ms, luck, buffer, null, map.x, map.y, screen.x, screen.y, TILESIZE, OFFSET, loopx, time, fps, base10, debugnull,_ set, playeraccuracy, skill, luck, health, currentplayercount, frames, timerstatement, timestatement, time1, time2,_ loopcount, id, clickms, npc.n, spi, obj, tile.list$, i, L, map.width, map.height, SCREENWIDTH, SCREENHEIGHT, GAMEWIDTH, GAMEHIEGHT,UpperLeftX,DisplayWidth,WindowWidth,UpperLeftY,DisplayHeight,WindowHeight global MouseX, MouseY, TileX, TileY, TileXY$,_ Bankspace, currentbankcount, inventory, selected,_ mana, magicklevel, specialbar, specialtimer, attacktime, defendtimer,_ lastselected$,selecteditem$, selected$, action$,_ attack, defend, attacktimer, defendtimer, defend1, defend2, attacktime1, attacktime2,_ combines, combinations
myPID = 1 ms = 119 'for timerloop (1000/ms frames = 10 'desired fps; actual fps may very use 'display() = fps()' function to find fps base10=10
'\\ basic debug/building data combinations = 10 'item combines, to new itemid here=item(itemid,2) npcname$ = "player.bmp"' add to keys after playeraccuracy = 10' 1 - 10 low-high skill = .9 ' .5 - .9 high level, .10 - .40 low level luck = .9 '.01-.99 seconds = 3 'desired debug run amount in seconds of 10 frames a second
health = 100
player(1,2) = health player(2,2) = health'input from file on server-client 'function for loading health from playerfiles
null = 0 null = null
id = 2 'set max hit calculated by point system divided '\\
'set = skill * 7 'unsed
tile.list$ = " dirt water grass rock sand "
buffer = 10 'ms buffer to bad loop yes = 1 '1 operator for debug startup = 1
[debugdata] ' debug(debug$) at bottom of code, select case debug$ confirm "debug = 1 (yes)?";answer$ if answer$ = "yes" then debugnull = 1 end if
if debugnull < null then 'NOMAINWIN end if
[splashscreen] percentage=1 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 'load bmp file to game import as new sprite uploadsprite() graphicbox #main.gbx, 64, 0,GAMEWIDTH , GAMEHEIGHT textbox #main.textbox, 14, 400, 352, 25 'not sure where text will be displayed currently saving for last open "r]pg - client" 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 start=splashscreen(percentage,TILESIZE, SCREENWIDTH, SCREENHEIGHT, OFFSET, GAMEWIDTH, GAMEHEIGHT,BackgroundColor$,UpperLeftY, UpperLeftX)'basic gui data below, using on screen sprites for icons for menus 'timer 350, [minus1] 'wait [minus1] 'timer 0 startserverdata$ = globalint$(playerfile$,downloadfile$,offline$) [0] update=splashscreen(percentage,TILESIZE, SCREENWIDTH, SCREENHEIGHT, OFFSET, GAMEWIDTH, GAMEHEIGHT,BackgroundColor$,UpperLeftY, UpperLeftX) 'import screen objects sprites for menus [1a]'tile import -10%'loading bar noftication for start splash screen update=splashscreen(percentage,TILESIZE, SCREENWIDTH, SCREENHEIGHT, OFFSET, GAMEWIDTH, GAMEHEIGHT,BackgroundColor$,UpperLeftY, UpperLeftX) callfunction$ = loadmaptiles$(i, tile.list$, TILESIZE) [2b]'user/player files -20%'loading bar noftication for start splash screen update=splashscreen(percentage,TILESIZE, SCREENWIDTH, SCREENHEIGHT, OFFSET, GAMEWIDTH, GAMEHEIGHT,BackgroundColor$,UpperLeftY, UpperLeftX) callfunction$=playerbmpload$(player.list$,i) [3c]'start int -30%'loading bar noftication for start splash screen update=splashscreen(percentage,TILESIZE, SCREENWIDTH, SCREENHEIGHT, OFFSET, GAMEWIDTH, GAMEHEIGHT,BackgroundColor$,UpperLeftY, UpperLeftX) loadsettings=setup() [4d] '40%'loading bar noftication for start splash screen update=splashscreen(percentage,TILESIZE, SCREENWIDTH, SCREENHEIGHT, OFFSET, GAMEWIDTH, GAMEHEIGHT,BackgroundColor$,UpperLeftY, UpperLeftX) callfunction$=loadmap$(itemdata$,id,map.width,map.height, player.x, player.y, npc.n, L) [5e] '60%'loading bar noftication for start splash screen update=splashscreen(percentage,TILESIZE, SCREENWIDTH, SCREENHEIGHT, OFFSET, GAMEWIDTH, GAMEHEIGHT,BackgroundColor$,UpperLeftY, UpperLeftX) callfuntion=loadscreenobj(SCREENWIDTH,SCREENHEIGHT,h,w,obj) [6f] update=splashscreen(percentage,TILESIZE, SCREENWIDTH, SCREENHEIGHT, OFFSET, GAMEWIDTH, GAMEHEIGHT,BackgroundColor$,UpperLeftY, UpperLeftX) callfunction=loadplayersprite(player.x,player.y,TILESIZE,OFFSET) [7g] update=splashscreen(percentage,TILESIZE, SCREENWIDTH, SCREENHEIGHT, OFFSET, GAMEWIDTH, GAMEHEIGHT,BackgroundColor$,UpperLeftY, UpperLeftX) callfunction=npcload(npc.n,L,TILESIZE,OFFSET) [8h] '70% update=splashscreen(percentage,TILESIZE, SCREENWIDTH, SCREENHEIGHT, OFFSET, GAMEWIDTH, GAMEHEIGHT,BackgroundColor$,UpperLeftY, UpperLeftX) 'currentplayercount = startplayercount(startup)'move to below : [m] timer 0 : for cycling in new players timer 50, [reDo] 'pause only for timer 0 at top of client branch function wait
[timer] ' [reDo] Timer 0 [branch] #main.gbx "When characterInput" debug=1000: debug=debug(debug)
time1 = time$("ms") debug = 3:debug = debug(debug)
'download every users file of "XX YY" 'add more data here gosub [moveMap] 'now$ = uploadtolan$(updateXY$,npcname$,healthnull,myg) currentplayercount$ = playercount$(playerfile$,count$,playercount) for PID = 1 to val(currentplayercount$) 'download every users file of "XX YY" 'add more data here cache$ = downloadplayerfile$(PID, currentplayercount) 'function downloads pid file and updates npc.x(pid) npc.y(pid) playerfiles$(PID) = cache$ next PID 'next playercount loop updateXY$ = playerpos$(player.x,player.y, screen.y, screen.x, map.x, map.y) 'drawing once every 237ms printf = fps(fps,time1,loopx) 'draw frame and inventory #main.gbx "DRAWSPRITES"
'debug 'timer time2 = time$("ms") timestatement = limiter(time2,time1,ms,buffer,timestatement) debug = 5:debug = debug(debug) debug = 4:debug = debug(debug) TIMER timestatement, [reDo] ' 1 game tic = ms #main.gbx "When characterInput [keys]" 'bread and butter Scan WAIT
[moveMap] 'credit to cundo for i =1 To obj SCAN'this might allow for extra input, not desired on metered game w = tile(i,1) h = tile(i,2)
if mapitem(w,h)>0 then ' #main.gbx "spritexy ";item.sprite.name$(items);" ";(w)-map.x-screen.x)*TILESIZE-TILESIZE - OFFSET ;" ";(h)-map.y-screen.y)*TILESIZE-TILESIZE - OFFSET '[debugg] end if
if walk.val=.5 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" Else ' set the tiles to an empty image #main.gbx "SpriteImage obj";i;" empty.bmp" End if
Next return [attackloop] attacktime1 = time$("ms") attacktimer = attackime1 attacktime2 = time$("ms")
callfunction = attack(attacktime, attacktimer, attacktime1, attacktime2, luck) if gotoattack = 1 then gotoattack = 0 goto [attack] end if
goto [branch]
[attack] Timer 0 #main.gbx "When characterInput"
probabilityvariable = rnd(10)*10 + playeraccuracy + luck * base10 'rnd with positive additive of player trained skill variable = probabilityvariable if variable > base10 then 'adds bonus if exptionale accurate, directly from the RND for realisitic play hitbonus = 10 - variable '10 point buffer for allowing not to powerful end if if variable < 5 then 'see if 50/50 with accuracy added(max up to 1 to 13-29 "i think") gives hit or not print "miss" goto [branch] end if debug=101:debug=debug(debug) hit = int(rnd(10)*10)*10+ int(rnd(10)*10)*base10 + hitbonus 'basically grabs postive handi capped "55+" RND adds bonus if accuracy is expectionale accurate over 100, to the handicap with a max of unknown, this gives base 55+/45- type RND sets, allowing for a positive gameplay without "sluggish" hits then times this number by your decimcal (skill level * 7) and divides by 3, this part is hard to explain how it linearized RND to be RND still, it just is because the seed is RND, now out of 100 this is not random, there is a positive value frequency to this code as stated before hit = hit*skill hit = hit / 3 + (luck + skill)
'add a little 'luck' here players will gain small amount of luck thru out game and its added to a hidden hit value that could "stack" or add up after every hit if hit < 1 then hit = 5*luck*luck end if debug = 8:debug=debug(debug)
goto [branch]
[defend] 'space bar defendtime = time$("ms") defendvar = defend(defendtimer, defendtime1, defendtime2, luck) if defendtime < defendvar and defendtime > defendvar then blocknexthit = 1 defendvar = 0 defendtime = 0 end if goto [branch]
[keys] 'credit to cundo 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" 'pidid 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" 'pidid 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" 'pidid 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" 'PIDid End if
case _VK_ESCAPE '[escape] to quit or [trapclose] goto [quit.main]
case _VK_INSERT 'attack [f] [g] keys and space bar goto [attackloop]
case _VK_CONTROL 'chat input CTRL instead of ENTER"
print #main.textbox, "!contents? textchat$"; print #main.textbox, "!disable" outputchat$ = textchat$ print #main.textbox, "PRINT #M lol nato sending...." send = loadtext(outputchat$) print #main.textbox, "" if debug = 1 then 'debug for adding tiles print #main.textbox, "~" check$ = commands$(outputchat$) else check$ = commands$(outputchat$) end if print #main.textbox, "!enable" 'admin commands restyled into funtionableility end select
GOTO [branch]
'------------------------------------------------------------------------ '------------------------------------------------------------------------
[quit.bmp]'credit: cundo Close #bmp goto [reDo]
[quit.main] unloadbmp "back.bmp" unloadbmp "empty.bmp" for i = 1 To 5 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 notice "Framework credit, justBasic proforums . com / Member: cundo" END
'------------------------------------------------------------------------ '------------------------------------------------------------------------ ' ' Functions '------------------------------------------------------------------------
Function mousehandler(MouseX, MouseY) TileXY$ = MouseXY.Tilefinder$(MouseX, MouseY)
clickarea$ = left$(TileXY$,1)
selected = val(right$(TileXY$,2))
pos$ = right$(TileXY$,1);" ";right$(TileXY$,2) pos = val(pos$)
select case clickarea$
case "inventory" retur$ = inventory.handler$(selected, pos)
case "special" reset = click(lastselected, selected) prime = specialbar(specialbar)
case "four tiles" if pos > 0 and pos < 4 then 'check rotation, if selected = 2 then [attackloop]
'if selected = 3 then '3 = quest item ' 'end if
if selected = 1 then '1 = item newitem = pickup(selected,pos) end if end if
case "other" reset = click(lastselected, selected) end select
End Function
function click(lastselected,selected) 'resets selected when click on non clickable area of game/map if lastselected <> 0 then lastselected=0 selected=0 end if
if incombat = 1 then incombat = stopcombat() end if
delay = pause(lag) debug = 9:debug=debug(debug)
end function
function pause(lag) startpausetime = time$("ms") for lagg = 1 to lag/div null = null 'add a bit of lag here next lagg pause = time$("ms")-startpausetime end function
Function activate(pos) incombat = stopcombat() 'or after obj either; or obj = room(pos) End Function
Function pickup(selected, pos) func = deleteitem(selected, pos) 'delete item 'server exchange data null = null 'prevent from double pickup null = null
func = newitem(selected) 'create new item in inventory End function
Function deleteitem(selected, pos) ' TileX = val(left$(pos,1) ' TileY = val(right$(pos,2)) mapitems(TileX,TileY)=null 'reset area array End Function
Function newitem(selected) for inventoryslot = 1 to 10 if inventory(inventoryslot) > null then 'check if slot is free if not null = null else it is a free slot null = null else inventory(inventoryslot) = selected 'inputs selected data here for new item on next draw inventoryslot = 10'11? end if 'make sure draw sprites command renews graphics next inventoryslot End Function
Function item.handler(selecteditem) 'here we use a parsing parse parser parsing = inventory(selecteditem) parser = parse(parsing)' find item type id if parser = 2 then '2 = food 'DELETE ITEM, ADD HEALTH delete = deleteitem(selecteditem, pos) end if if lastselected = 0 then lastselected = selecteditem selecteditem = 0 else if item(selecteditem,2) = item(lastselected,2) then 'if items second entry id matches nulled= deleteitem(selecteditem, pos)' pos unsed nulled= deleteitem(lastselected, pos)'pos unsed reset = click(lastselected, selected) 'reset click memory new=item(lastselected,2) retur = newitem(new) 'create new item from matched id end if end if End Function
Function parse(selecteditem) parse = item(selecteditem,2) 'find itemtypeid 1= item 2=food 3= End Function
Function MouseXY.Tilefinder$(MouseX, MouseY) 'get mouse sx mouse y input prase through the 8 inventory post four tiles around player, special bar 'select case <> for each area 'return as three part string item position area string$
MouseX = MX : MouseY = MY
'right hand side if MX > 400 and MX < 500 then if MY >100 and MY < 200 then pos = 5 end if end if
if MX > 400 and MX < 500 then if MY >300 and MY < 400 then pos = 6 end if end if
if MX > 400 and MX < 500 then if MY >400 and MY < 500 then pos = 7 end if end if
if MX > 400 and MX < 500 then if MY >500 and MY < 600 then pos = 8 end if end if 'right handside/ 'bottom of screen
if MY > 500 and MY < 600 then if MX > 100 and MX < 200 then pos = 9 end if end if
if MX > 400 and MX < 500 then if MY > 200 and MY < 300 then pos = 10 end if end if
if MX > 400 and MX < 500 then if MY > 300 and MY < 400 then pos = 11 end if end if
if MX > 400 and MX < 500 then if MY >400 and MY < 500 then pos = 12 end if end if
'end bottom/
'four tiles
'special
if pos = 0 then pos = -1 end if
if pos > 0 and pos < 4 then clickarea$ = "four tiles" end if
if pos > 4 and pos < 13 then clickarea$ = "inventory" end if
if pos = 14 then clickarea$ = "special" end if
if pos = 15 then clickarea$ = "null" end if
if pos = -1 then clickarea$ = "other" end if MouseXY.Tilefinder$ = clickarea$'+string$(pos) End Function
Function inventory.handler$(selected, pos) 'returns item id of inventory item at position pos selecteditem = inventory(pos) if selecteditem = 0 then inventory.handler$="0" else retur$ = item.handler$(selecteditem) end if End Function
Function bank()
End Function
'combat
Function stopcombat() stopcombat = null 'return 0 as if then not allowing combat next loop End Function
Function attack(attacktime, attacktimer, attacktime1, attacktime2, luck)'via button if attacktime1 > 0 then if a = 5 then a = 0 end if end if a = a + 1 attacktime = attacktime(a) - luck*luck '16-18 15-19 if attacktime+attacktimer<attacktime2+attacktime+luck and attacktime+attacktimer>attacktime2+attacktime+luck then '* gotoattack = 1 attacktime = 0 : attacktimer = 0 : attacktime2 = 0 : attacktime1 = 0 end if End Function
Function defend(defendtimer, defendtime1, defendtime2, luck)'via space bar or key
if defendtime1 > 0 then if b = 5 then b = 0 end if end if b = b + 1
defendtime = attacktime(b) - luck*luck '16-18 15-19 using array for both if defendtime+defendtimer<defendtime2+defendtime+luck and defendtime+defendtimer>defendtime2+defendtime+luck then defend = (defendtime2-defendtime1)/2+luck' defendtime = 0 : defendtimer = 0 : defendtime2 = 0 : defendtime1 = 0 end if End Function
Function specialbar(specialbar) 'mouse click if weaponspecial < special then 'see if there's enough special left special = special - weaponspecial 'subtract special end if incombat = stopcombat() ' require reclick? specialbar = special End Function
'luck
Function limiter(time2,time1,ms,buffer,timestatement) if time2-time1 < ms then timestatement = (time2-time1)-int(luck*3+1) limiter = timestatement end if End Function
'filesystem
Function startplayercount$(startup, playerfile$, count$, playercount, PID) 'gets current player count and updates open playerfile$+".txt" for input as #1 'open playercount file needs to have starting data of a single "0" zero count$ = input$(#1,lof(#1)) playercount = val(count$) playercount = playercount + 1 close #1
'add satefy for adding new file filecheck() to not allow new user until files been appeneded A B swap for infomation and x2 time ms
PID = playercount 'keep track of position in file or clients PID myPID = PID 'duplicate variable for <> loops of PID
open playerfile$+".txt" for append as #playercount print #playercount, myPID close #playercount End Function
'regular loop function playercount$(playerfile$,count$,playercount) open playerfile$+".txt" for input as #2 'open playercount file count$ = input$(#2,lof(#2)) playercount = val(count$) close #2
npc.n = playercount
End Function
Function uploadtolan$(updateXY$,npcname$,healthnull,myPID) open playerfile$+str$(myPID);".txt" for output as #outputupload print #outputupload, playerpos$;" ";npcname$ close #outputupload uploadtolan$ = "1" End Function
Function downloadplayerfile$(PID,currentplayercount) if PID <> myPID then string$ = downloadfile$+str$(PID);".txt" open string$ for input as #download 'open file by player log in order ID or PID playerpagefile$ = input$(#download,lof(#download)) downloadplayerfile$=playerpagefile$ 'read line close #download npcx=val(left$(downloadplayerfile$,1)) npcy=val(right$(downloadplayerfile$,3)) npcname$ = right$(downloadplayerfile$,2) ' heathnull = val(right$(downloadplayerfile$,1)) 'hit npc.x(PID) =npcx 'update game data here npc.y(PID) =npcy npc.name$(npcx,npcy) = npcname$ 'health 'hit
end if End Function
function playerpos$(player.x,player.y, screen.y, screen.x, map.x, map.y) 'updates player position into string$ for output to be downloaded by pid npcgraphics and health incombatpid = otherplayer pid and hit 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
playerpos$=str$(player.x);" ";str$(player.y)';" ";npcname$;" ";player(myPID,healthnull)
debug = 7:debug = debug(debug)
end function
Function loadtext(textchat$) 'multiuse databasefiles? open "text.txt" for output as #uploads print #uploads, time$("ms");" ";textchat$ close #uploads End Function
'extras
Function fps(fps,time,loopx) 'print #main.gbx, "/text fps(";int(actualfps) End Function
'commands Function commands$(inputcommand$) 'EXAMPLE: ctrl+map/npc/oject 0X 0Y refID$ ctrl$ = "1" 'COMMAND KEY INT. -> "1" if left$(outputchat$, 1) = ctrl$ then commands = commands + 1 'keep track of commands commandsarray$(commands) = word$(outputchat$,1) commandtype$ = commandsarray$(commands) xmap= val(word$(inputmap$, 2)) ymap= val(word$(inputmap$, 3)) mapcommandtile$ = word$(outputchat$, 4)
print ":COMMANDISSUED:SET>";left$(outputchat$, 4);" ";str$(xmap);" ";str$(ymap);"<"; word$(outputchat$,4) ;">tileRefID$: "
select case commandtype$ case "1map" map$(xmap,ymap)=mapcommandtile$ 'actual input line command here case "1npc" ' = val(mapcommandtile$) npc.x(null) =xmap 'update game data here npc.y(null) =ymap 'npc object commands case "1object"
end select
commands$=commandtype$ 'for ref end if End Function
'int function npcload(npc.n,L,TILESIZE,OFFSET) 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 End Function
function loadplayersprite(player.x,player.y,TILESIZE,OFFSET) 'credit to cundo #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 end function
function setup() 'credit to cundo #main.gbx "setfocus;" ;_ "When characterInput [keys]; ";_ "Getbmp back.bmp 1 1 10 10;" ;_ "Background back.bmp;" ;_ "DRAWSPRITES" end function
function playerbmpload$(player.list$,i) 'credit to cundo 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 end function
function loadscreenobj(SCREENWIDTH,SCREENHEIGHT,h,w,obj) 'credit to cundo ' 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 end function
function loadmaptiles$(i, tile.list$, TILESIZE) 'credit to cundo for this function For i = 1 To 5 loadbmp word$(tile.list$,i);".bmp ",word$(tile.list$,i);".bmp" #main.gbx "drawbmp ";word$(tile.list$,i);".bmp 1 ";TILESIZE+1;" ; ";_ "Getbmp ";word$(tile.list$,i);".bmp 1 1 ";TILESIZE;" ";TILESIZE*2 Next end function
function loadmap$(itemdata$,id,map.width,map.height, player.x, player.y, npc.n, L) 'credit to cundo for map file type; system function 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
end function
function globalint$(playerfile$,downloadfile$,offline$) playerfile$="player" downloadfile$=playerfile$+"A" 'attribute to files, will add "offline" to name if player is not online offline$="OFFLINE"' not used currently end function
'debug Function debug(debug) if debugnull = 1 then select case debug
case 2 notice frames;" x ";seconds;" seconds / frames (Double Click) [ENTER]" notice "Continue [enter]" 'pause break case 3 print currentplayercount;" current player count" case 4 print (time2-time1);" ms game compiled frame in pause of no input, ";timestatement;" lag/wait until next frame of scaaning input, enter pauses here for verifying SCAN and Input [keys]" timerstatement = timerstatement' - buffer case 5 timerstatement = timerstatement + 1000 * seconds ' wait for debug next frame case 6 print "closing for now 0% upload not featured in code yet" case 7 print playerpos$ 'debug case 8 print hit case 9 print delay delay = 0 case 101 print time$("ms") - clickms case 1000 loopx = loopx + 1 clientloop = clientloop + 1
if clientloop = frames*seconds then 'frames = 10 FPS, refer fps() for actual fps clientloop = 0
debug = 2:debug = debug(debug)
timer 1000*seconds, [timer] wait
' text=loadtext() 'load text once per second end if end select debug = 0 'reset debug end if End Function
'animations
Function loadanimations() 'search playerfiles$() for animation tag character 'display x y starts and stops 'step program thru loop 8 frames; (4) animation frames twice per theoretical slowed down second 1000ms / 8 'count 'aninum = count ' readnow= loadanimations() 'for ani = 0 to readnow ' print #w.g, "addsprite ";animation$;" "animation1$;" ";animation2$;" "animation3$ ' print #w.g, "cyclesprite ";animation$;" 1" ' print #w.g, "spritemovexy ";animation$;" 4 0" ' loadnanimations = aninum End Function
'splashscreen loading menu
function splashscreen(percentage,TILESIZE, SCREENWIDTH, SCREENHEIGHT, OFFSET, GAMEWIDTH, GAMEHEIGHT,BackgroundColor$,UpperLeftY, UpperLeftX) select case percentage case 1 '11 bmps. 10 with percentages
'start first screen case 5 '5, ect. case 10
case 20
case 30
case 40
case 60
case 67
case 70
case 95
case 98
delay=pauses(lag) 'a bit of epic pause here, hopefully be used later in-game delay=pauses(lag) case 100
'case else errornumber = 1 null = noticeerror(errornumber,percentage,null) end end select end function
'pause function null function pauses(lag) for paus = 1 to 4 'ready game window delay=pauses(lag) next paus end function
'fail to load error notice function noticeerror(errornumber,percentage,null) select case errornumber case 1 notice "ERROR ";errornumber;" ";percentage;" loaded." case 2 notice "ERROR ";errornumber;" ";null;" loaded." case 3 notice "ERROR ";errornumber;" ";null;" loaded." case else notice "ERROR ";Err$;" ";null;"null number" end select end function
'COPY PASTE MATERIAL; gosub [debugpause] [debugpause] 'pause of debug for var * 1000 ms - 1 second if debugnull = 0 then [returndebug] codenuller = var * 1000 timer codenuller, [returndebug] #main.gbx "When characterInput" wait [retundebug] return
|
|