I'm really sorry guys, I've been incredibly busy. I've added player inventories. Don't forget to include it as inventory.bb. It's a start... you can move around and select certain items.
Whenever you pick up an item, use: InvItem_Create(name$,weight,p.player,image,frame)
to add it to a player's inventory. You can specify an image and frame to be drawn.
Players have backpack sizes. Items have sizes as well.
And to see it in action I'm using the action button to open/close it.
Add this to the start of the player_create function as it'll set the player's backpack size and add some temporary objects. The size could be set using the readItem functions.
Change this in player.bb->Player_UpdateAll() function.
By the way, nice new weapon graphics, rob. very nice.
Whenever you pick up an item, use: InvItem_Create(name$,weight,p.player,image,frame)
to add it to a player's inventory. You can specify an image and frame to be drawn.
Players have backpack sizes. Items have sizes as well.
; inventory Const INVITEM_WIDTH = 70 Type invItem Field owner.player Field name$,weight Field x,y,image,imageFrame End Type Function useInventoryItem(p.player,i.invItem) End Function Function InvItem_Create(name$,weight,p.player,image,frame) i.invitem=New invItem i\name=name i\weight=weight i\image=image i\imageFrame=frame addInvItem(p,i) End Function Function setPlayerInvLevels(p.player,maxWeight) p\maxWeight=maxWeight p\weight=0 p\itemsCarrying=0 p\showingInv=0 p\overWait=MilliSecs() End Function Function showInventory(p.player) p\showingInv=1-p\showingInv End Function Function UpdateInventories(p.player) ; this handles the controls If p=First player max=(GraphicsWidth()/2)-10 Else max=(GraphicsWidth()) EndIf If (MilliSecs()-p\overWait) > 200 If control(pright,p\id) p\over=p\over+1 p\overWait=MilliSecs() ElseIf control(pleft,p\id) p\over=p\over-1 p\overWait=MilliSecs() EndIf EndIf If p\over<0 Then p\over=p\itemsCarrying-1 If p\over>p\itemsCarrying-1 Then p\over=0 End Function Function addInvItem(p.player,item.invItem) If p=Null Then Return If item= Null Then DebugLog "Inv Item is NULL" Return EndIf If p\weight+item\weight <= p\maxWeight ; pickup item\owner=p p\inv[p\itemsCarrying]=item p\weight=p\weight+item\weight p\itemsCarrying=p\itemsCarrying+1 refreshInvItems() Else DebugLog "Cannot pick up "+item\name+". It's too heavy" Return EndIf End Function Function refreshInvItems() For p.player=Each player If p = First player min=5 x=min max=(GraphicsWidth()/2)-10 Else min=(GraphicsWidth()/2)+10 x=min max=(GraphicsWidth()) EndIf y=10 If p\itemsCarrying>0 For i=0 To p\itemsCarrying-1 inv.invItem=p\inv[i] If inv<>Null If x > max-INVITEM_WIDTH x=min y=y+INVITEM_WIDTH EndIf inv\x=x inv\y=y x=x+INVITEM_WIDTH EndIf Next EndIf Next End Function Function drawInvItems(p.player) If p\showingInv=0 Then Return If p=First player max=(GraphicsWidth()/2)-10 ; player one Color 150,150,150:Rect 0,0,max,GraphicsHeight() Color 200,200,200:Rect max,0,1,GraphicsHeight() btext 10,GraphicsHeight()-10,p\weight+" / "+p\maxWeight Else max=(GraphicsWidth()/2)-10 Color 150,150,150:Rect max,0,GraphicsWidth()/2,GraphicsHeight() Color 200,200,200:Rect max,0,GraphicsWidth()/2,GraphicsHeight() btext (GraphicsWidth()/2)+10,GraphicsHeight()-10,p\weight+" / "+p\maxWeight EndIf If p\itemsCarrying>0 For i=0 To p\itemsCarrying-1 inv.invItem=p\inv[i] If inv<>Null If inv\image<>0 DrawImage inv\image,inv\x,inv\y,inv\imageFrame EndIf Color 255,255,255 Rect inv\x,inv\y,INVITEM_WIDTH,INVITEM_WIDTH,0 Color 0,0,0 bText inv\x+INVITEM_WIDTH/2,inv\y+INVITEM_WIDTH/2,inv\name,1,1 If i=p\over Color 255,0,0 Rect inv\x,inv\y,INVITEM_WIDTH,INVITEM_WIDTH,0 EndIf EndIf Next EndIf End Function
And to see it in action I'm using the action button to open/close it.
Add this to the start of the player_create function as it'll set the player's backpack size and add some temporary objects. The size could be set using the readItem functions.
setPlayerInvLevels(pl,500) For i=1 To 5 InvItem_Create("A_"+i,"50",First player,0,0) Next
Change this in player.bb->Player_UpdateAll() function.
If control(paction,pl\id) Then showInventory(pl) If pl\showingInv=0 ; get input If control(pright,pl\id) And pl\x<7552 Then mr=True If control(pleft,pl\id) And pl\x>0 Then ml=True If control(pup,pl\id) And pl\y>0 Then mu=True If control(pdown,pl\id) And pl\y<7552 Then md=True ; weapons (player specific) If control(p_weapon1,pl\id) Then EquipWeapon(pl\id,getWeaponFromName("Machine Gun")) If control(p_weapon2,pl\id) Then EquipWeapon(pl\id,getWeaponFromName("Shot Gun")) If control(p_weapon3,pl\id) Then EquipWeapon(pl\id,getWeaponFromName("Flame Thrower")) If control(p_weapon4,pl\id) Then EquipWeapon(pl\id,getWeaponFromName("Grenade Launcher")) If control(p_weapon5,pl\id) Then EquipWeapon(pl\id,getWeaponFromName(weaponStyrling)) If control(p_weapon6,pl\id) Then EquipWeapon(pl\id,getWeaponFromName(weaponImpact)) If control(pAction,pl\id) Then runActionScript(pl) ; action key If control(pfire1,pl\id) fireWeapon(pl,pl\dir*22.5) firing = True EndIf Else UpdateInventories(pl) EndIf
By the way, nice new weapon graphics, rob. very nice.