No worries about the font - just having a play to see if I could squeeze a bit more in. I think we might need to go wide-screen plasma style!!!
Have made a bit more progress on the Intex System (bit more of a tidy also) as you can now go in and buy some of the stuff from the tool supplies - check it out below.
Also with the weapons - I think we need to store the ammo for each weapon separately, which would also mean we need to have a number of different ammo collections - what does everyone think? If so, I will have a look.
Intex-new.bb - replace
Function Player_Create.player add:
Have made a bit more progress on the Intex System (bit more of a tidy also) as you can now go in and buy some of the stuff from the tool supplies - check it out below.
Also with the weapons - I think we need to store the ammo for each weapon separately, which would also mean we need to have a number of different ammo collections - what does everyone think? If so, I will have a look.
Intex-new.bb - replace
;Images Global intexBackground = LoadImage("gfx\intexbg.png") Global intexFrame = LoadImage("gfx\intex-frame.png") Global intexText = LoadAnimImage("gfx\intex-text-sm4.png",8,10,0,41) MaskImage intexText,255,0,255 ;Global intexWeapon = LoadAnimImage("gfx\intex-weapons.png",320,88,0,6) ;MaskImage intexWeapon,255,0,255 ; INTEX Const intexHandMapCost = 500 Const intexAmmoCost = 1000 Const intexFirstAidCost = 2000 Const intexKeysCost = 4000 Global bfont = LoadAnimImage("gfx\bitfnt.png",5,5,0,100) Function btext(x,y,t$,hcentre=False,vcentre=False) If hcentre Then x=x-(Len(t)*3) If vcentre Then y=y-3 For n=1 To Len(t) DrawImage bfont,x,y,Asc(Mid(t,n,1))-32 x=x+6 Next End Function Global intexChars$ = "*ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:?!" Const pauseMax = 75 Const maxLines = 20 Const draw_char_delay_time=5 Const charWidth = 7 Const xOffset = 160 Const yOffset = 112 Type MenuSystem Field id Field build Field bChar Field bLine Field menuText$[maxLines] Field x[maxLines] Field y[maxLines] Field subMenu[maxLines] Field highlight[maxLines] Field total Field pauseCounter Field cursorRow Field cursorX Field cursorY Field bCharCounter Field selectionCursorShow Field selectionCursorX End Type Global intexMenu.MenuSystem Global gotr Global gotg Global gotb Function GetRGB(image_name,x,y) argb=ReadPixelFast(x,y,ImageBuffer(image_name)) gotr=(ARGB Shr 16) And $ff gotg=(ARGB Shr 8) And $ff gotb=ARGB And $ff End Function Function WriteRGB(image_name,x,y,red,green,blue) argb=(blue Or (green Shl 8) Or (red Shl 16) Or ($ff000000)) WritePixelFast x,y,argb,ImageBuffer(image_name) End Function Function halfbright(source1,x1,y1,bias#) result = CreateImage(ImageWidth(source1),ImageHeight(source1)) source2 = CreateImage(ImageWidth(source1),ImageHeight(source1)) GrabImage source2,x1,y1 LockBuffer ImageBuffer(source1) LockBuffer ImageBuffer(source2) LockBuffer ImageBuffer(result) For x=0 To ImageWidth(source1)-1 For y=0 To ImageHeight(source1)-1 GetRGB(source1,x,y) r1#=gotr g1#=gotg b1#=gotb GetRGB(source2,x,y) r2#=gotr g2#=gotg b2#=gotb r3#=(r1*bias)+(r2*(1-bias)) g3#=(g1*bias)+(g2*(1-bias)) b3#=(b1*bias)+(b2*(1-bias)) WriteRGB(result,x,y,r3,g3,b3) Next Next UnlockBuffer ImageBuffer(source1) UnlockBuffer ImageBuffer(source2) UnlockBuffer ImageBuffer(result) Return result End Function Function IntexMenu(pl.player) Local currentMenu = 0 Local exitMenu = False Local preBootCounter = 0 Local menuUpdateCounter Local ammoInClip ;Create a menu store intexMenu.MenuSystem = New MenuSystem ;Get the boot text GetMenuText(currentMenu,pl) ;Set background to lower brightness ibg = halfbright(intexbackground,xoffset,yoffset,.8) While Not exitMenu = True ;Set buffer SetBuffer BackBuffer() ;Draw DrawBlock intexFrame,xOffset-15,yOffset-12 DrawBlock ibg,xOffset,yOffset ;Individual menu functions If intexMenu\build = False Then Select currentMenu Case 0 ;Intex Boot ;Set menu to Main Menu currentMenu = 1 GetMenuText(currentMenu,pl) Case 4 ;Radar Service ;Draw map DrawMapPlan() Case 3 ;Tool Service ;Purchase item? If control(pfire1,pl\id) Then Select intexMenu\cursorRow ; intexMenu\subMenu[intexMenu\highlight[intexMenu\cursorRow]] Case 1 ; Buy map Case 2 ; Buy Ammo If pl\credits > intexAmmoCost Then ;Decrease credits pl\credits = pl\credits - intexAmmoCost ;Update ammo by 2 clips givePlayerAmmo(pl,pl\weapon\ammo_in_a_clip * 2) ;Reset menu for new credits GetMenuText(currentMenu,pl,False) End If Case 3 ; Buy first aid If pl\credits > intexFirstAidCost Then ;Decrease credits pl\credits = pl\credits - intexFirstAidCost ;Update health to max Player_GiveHealth(pl,100) ;Reset menu for new credits GetMenuText(currentMenu,pl,False) End If Case 4 ;Buy keys End Select ;Clear key press ;FlushKeys() End If Case 10 ;Disconnect exitMenu = True End Select End If ;Drawtext ProcessMenuText(pl) ;Menu select If intexmenu\build = False Then ;Fire If control(pfire1,pl\id) Then ;Determine where to go If intexMenu\subMenu[intexMenu\highlight[intexMenu\cursorRow]] > 0 Then ;Get menu to activate currentMenu = intexMenu\subMenu[intexMenu\highlight[intexMenu\cursorRow]] GetMenuText(currentMenu,pl) ElseIf intexmenu\selectionCursorShow = False Then ;Return to main menu currentMenu = 1 GetMenuText(currentMenu,pl) End If End If ;Update cursor position If intexmenu\selectionCursorShow = True Then ;Menu Up/Down If menuUpdateCounter = 0 Then If control(pUp,pl\id) And intexMenu\cursorRow > 1 Then intexMenu\cursorRow = intexMenu\cursorRow - 1 menuUpdateCounter = 10 ElseIf control(pDown,pl\id) And intexMenu\highlight[intexMenu\cursorRow + 1] <> 0 Then intexMenu\cursorRow = intexMenu\cursorRow + 1 menuUpdateCounter = 10 End If Else ;Control the speed of the menu movement If menuUpdateCounter > 0 Then menuUpdateCounter = menuUpdateCounter - 1 End If End If ;Show selection cursor DrawImage intexText,intexmenu\selectionCursorX,intexMenu\y[intexMenu\highlight[intexMenu\cursorRow]], 0 End If End If ;Draw Flip True Wend ;Clear keys FlushKeys() ;Tidyup Delete Each menuSystem End Function Function GetMenuText(menu, pl.player,reset=True) Local totalLines, lines Local lineText$, x, y, subMenu, max Local highlight Local selectionCursorOn, selectionCursorX ;Wait until no fire keys pressed While control(pfire1, pl\id) Wend ;Set fields If reset = True Then intexMenu\build = True intexMenu\bChar = 0 intexMenu\bLine = 1 intexMenu\id = menu intexMenu\pauseCounter = 0 intexMenu\cursorRow = 1 intexMenu\bCharCounter = 0 End If Select menu Case 0 ;Intex Boot Restore menuIntexBoot Case 1 ;Menu Restore menuIntexMain Case 2 ;Weapon Supplies Restore menuIntexWeaponsSupply Case 3 ;Tool Supplies Restore menuIntexToolSupply Case 4 ;Radar Service Restore menuIntexRadarService Case 7 ;Statistics Restore menuIntexStatistics Case 10 ;Disconnect Restore menuIntexDisconnect End Select ;Clear For lines = 1 To maxLines intexMenu\highlight[lines] = 0 intexMenu\menuText$[lines] = "" Next ;Read the data Read totalLines ;Selection cursor Read selectionCursorOn, selectionCursorX intexmenu\selectionCursorShow = selectionCursorOn intexmenu\selectionCursorX = selectionCursorX + xOffset For lines = 1 To totalLines Read lineText, x, y, subMenu, highlight intexMenu\menuText$[lines] = UpdateTags(Upper(lineText), pl) intexMenu\x[lines] = x + xOffset intexMenu\y[lines] = y + yOffset intexMenu\subMenu[lines] = subMenu ;Set line selection If highlight <> -1 Then intexMenu\highlight[highlight] = Lines End If Next ;Set remaining fields intexMenu\total = totalLines + 1 ;Clear keys FlushKeys() End Function Function UpdateTags$(lineText$, pl.player) ;Update tags lineText = Replace(lineText,"%PLSCORE%",LSet(pl\score,6)) lineText = Replace(lineText,"%PLKILLS%",pl\kills) lineText = Replace(lineText,"%CVHANDMAP%",RSet(intexHandMapCost,5)) lineText = Replace(lineText,"%CVAMMO%",RSet(intexAmmoCost,5)) lineText = Replace(lineText,"%CVFIRSTAID%",RSet(intexFirstAidCost,5)) lineText = Replace(lineText,"%CVKEYS%",RSet(intexKeysCost,5)) lineText = Replace(lineText,"%PLCREDITS%",pl\credits) lineText = Replace(lineText,"%PLSHOTS%",pl\shots) lineText = Replace(lineText,"%PLDOORS%",pl\doors) lineText = Replace(lineText,"%PLAMMO%",pl\clip) lineText = Replace(lineText,"%PLENERGY%","GOOD") lineText = Replace(lineText,"%PLCURRENTWEAPON%",Upper(pl\weapon\name)) ;Current lineText = Replace(lineText,"%WP1NAME%",LSet(WeaponName(1)+"...",29)) lineText = Replace(lineText,"%WP2NAME%",LSet(WeaponName(2)+"...",29)) lineText = Replace(lineText,"%WP3NAME%",LSet(WeaponName(3)+"...",29)) lineText = Replace(lineText,"%WP4NAME%",LSet(WeaponName(4)+"...",29)) lineText = Replace(lineText,"%WP5NAME%",LSet(WeaponName(5)+"...",29)) lineText = Replace(lineText,"%WP6NAME%",LSet(WeaponName(6)+"...",29)) lineText = Replace(lineText,"%WP1STATUS%",WeaponStatus(pl\ownedWeapons[1])) lineText = Replace(lineText,"%WP2STATUS%",WeaponStatus(pl\ownedWeapons[2])) lineText = Replace(lineText,"%WP3STATUS%",WeaponStatus(pl\ownedWeapons[3])) lineText = Replace(lineText,"%WP4STATUS%",WeaponStatus(pl\ownedWeapons[4])) lineText = Replace(lineText,"%WP5STATUS%",WeaponStatus(pl\ownedWeapons[5])) lineText = Replace(lineText,"%WP6STATUS%",WeaponStatus(pl\ownedWeapons[6])) ;Return Return lineText End Function Function WeaponStatus$(wp.weapon) If wp<>Null Then Return "YES" End If Return " NO" End Function Function WeaponName$(id) For wp.weapon = Each weapon If wp\id = id Then Return Upper(wp\name) End If Next End Function Function ProcessMenuText(pl.player) Local currentChar$,x,y,maxChar,char Local charCounter = 0 Local drawCursor = False Local finishProcess = False If intexMenu\build Then If intexMenu\bChar > 0 Then ;Get the current char Repeat currentChar = Mid(intexMenu\menuText[intexMenu\bLine],intexMenu\bChar,1) If currentChar = " " And intexMenu\bChar < Len(intexMenu\menuText[intexMenu\bLine]) - 1 Then ;Skip over any spaces intexMenu\bCharCounter = intexMenu\bCharCounter + 1 intexMenu\bChar = intexMenu\bChar + 1 ElseIf currentChar = "+" Then ;We need to pause intexMenu\pauseCounter = (intexMenu\pauseCounter +1) Mod pauseMax Exit Else ;Exit out Exit End If Forever End If ;Continue to process text If intexMenu\pauseCounter = 0 Then ;Increment number of shown characters intexMenu\bCharCounter = intexMenu\bCharCounter + 1 ;Increment char intexMenu\bChar = (intexMenu\bChar + 1) Mod Len(intexMenu\menuText[intexMenu\bLine]) If intexMenu\bChar = 0 Then ;Increment line intexMenu\bLine = (intexMenu\bLine + 1) Mod intexMenu\total If intexMenu\bLine = 0 Then finishProcess = True End If End If End If ;Speed up menu process (fire key) - temp? If KeyDown(1) Then finishProcess = True End If ;Finish? If finishProcess Then ;Set each item to it's max intexMenu\bLine = intexMenu\total - 1 intexMenu\bChar = Len(intexMenu\menuText[intexMenu\bLine]) ;Finish intexMenu\build = False FlushKeys() End If End If ;Draw text For drawLine = 1 To intexMenu\bLine ;Set co-ords for current line x = intexMenu\x[drawLine] y = intexMenu\y[drawLine] ;Draw current line For drawChar = 1 To Len(intexMenu\menuText[drawLine]) ;Increment letter count charCounter = charCounter + 1 ;Get current char char = Instr(intexChars, Mid(intexMenu\menuText[drawLine],drawChar,1)) - 1 If char > -1 Then DrawImage intexText,x,y,char End If ;Building the menu, if so pause on last char and display cursor If intexMenu\build Then ;Slight pause when first displaying character? If (charCounter = intexMenu\bCharCounter) Then Delay draw_char_delay_time intexMenu\cursorX = x intexMenu\cursory = y drawCursor = True Exit End If End If ;Increment x = x + charWidth Next ;Display cursor position? If drawCursor Then DrawImage intexText,intexMenu\cursorX,intexMenu\cursorY,0 Exit End If Next End Function ;Data Structure ;No of lines ;Show Cursor,CursorXPos ;Text$,X,Y,SubMenu,Position .menuIntexBoot Data 10 Data False,-1 Data "INTEX NETWORK CONNECT: CODE ABF01DCC60 ",8,48,-1,-1 Data "CONNECTING..................... ",8,60,-1,-1 Data "INTEX NETWORK SYSTEM V10.0 ",8,84,-1,-1 Data "2G RAM: OK ",8,96,-1,-1 Data "EXTERNAL DEVICE: OK ",8,108,-1,-1 Data "SYSTEM V1.10 CS: OK ",8,120,-1,-1 Data "VIDEODISPLAY: DAMAGED+ ",8,132,-1,-1 Data "EXECUTING DOS 5.0 ",8,156,-1,-1 Data "SYSTEM DOWNLOADING NETWORKDATA..... OK ",8,168,-1,-1 Data "INTEX EXECUTED!+ ",8,180,-1,-1 .menuIntexMain Data 8 Data True,32 Data "INTEX MAIN MENU ",96,32,-1,-1 Data "INTEX WEAPON SUPPLIES ",72,68,-1,1 Data "INTEX TOOL SUPPLIES ",80,80,3,2 Data "INTEX RADAR SERVICE ",80,92,4,3 Data "LEVEL INFORMATION UPDATE ",64,104,-1,4 Data "INTEX ENTERTAINMENT ",80,116,-1,5 Data "STATISTICS ",120,128,7,6 Data "EXIT INTEX NETWORK ",88,140,10,7 .menuIntexWeaponsSupply Data 2 Data True,32 Data "INTEX WEAPON SUPPLIES ",122,24,-1,-1 Data "WEAPON SUPPLIES REQUEST: ",24,48,-1,-1 .menuIntexToolSupply Data 7 Data True,24 Data "INTEX TOOL SUPPLIES ",88,36,-1,-1 Data "ELECTRONIC HAND MAP %CVHANDMAP% CR ",40,72,-1,1 Data "AMMO NYBBLE %CVAMMO% CR ",40,96,-1,2 Data "FIRST AID KIT %CVFIRSTAID% CR ",40,120,-1,3 Data "6 KEYS %CVKEYS% CR ",40,144,-1,4 Data "EXIT ",144,192,1,5 Data "YOUR CREDIT LIMIT IS: %PLCREDITS% CR ",40,216,-1,-1 .menuIntexRadarService Data 1 Data False,-1 Data "INTEX RADAR SERVICE ",88,32,-1,-1 .menuIntexStatistics Data 16 Data False,-1 Data "INTEX STATISTICS ",96,16,-1,-1 Data " PLAYER SCORES: %PLSCORE% PTS ",16,40,-1,-1 Data " ALIENS KILLED: %PLKILLS% ",16,52,-1,-1 Data " SHOTS FIRED: %PLSHOTS% BULLETS ",16,64,-1,-1 Data " CREDITS OWNED: %PLCREDITS% CR ",16,76,-1,-1 Data " DOORS OPENED: %PLDOORS% ",16,88,-1,-1 Data " AMMO OWNED: %PLAMMO% CLIP",16,100,-1,-1 Data " ENERGY STATE: %PLENERGY% ",16,112,-1,-1 Data "CURRENT WEAPON: %PLCURRENTWEAPON%",16,124,-1,-1 Data "WEAPONS STATUS: ",16,136,-1,-1 Data "%WP1NAME% %WP1STATUS% ",40,160,-1,-1 Data "%WP2NAME% %WP2STATUS% ",40,172,-1,-1 Data "%WP3NAME% %WP3STATUS% ",40,184,-1,-1 Data "%WP4NAME% %WP4STATUS% ",40,196,-1,-1 Data "%WP5NAME% %WP5STATUS% ",40,208,-1,-1 Data "%WP6NAME% %WP6STATUS% ",40,220,-1,-1 .menuIntexDisconnect Data 1 Data False,-1 Data "DISCONNECTING..............+ ",16,32,-1,-1
Function Player_Create.player add:
pl\credits = 20000