Diplaying drawtext from Tlist?
BlitzMax Forums/BlitzMax Beginners Area/Diplaying drawtext from Tlist?
| ||
..and actually be able to organize it into readable multilines. Example: I was using this tutorial:: Type TShip Field Name$,Score EndType 'Create some Ships '__________________________ Global Ship:TShip Ship = New TShip Ship.Name = "My First Ship" Ship.Score = 11 Global Ship2:TShip Ship2 = New TShip Ship2.Name = "My 2nd Ship " Ship2.Score = 3 Global Ship3:TShip Ship3 = New TShip Ship3.Name = "The 3rd Ship " Ship3.Score = 9 '___________________________ Global MyList:TList 'Define the List MyList = CreateList() 'Create a New List MyList.AddFirst(Ship) 'Add Object to List 'Now you could add to the top of the list 'MyList.AddFirst() 'Or add to the bottom MyList.AddLast(Ship2) MyList.AddLast(Ship3) For Local S:TShip = EachIn MyList Print "Name: "+S.Name+" Score:"+S.Score Next 'How many objects in the List? Print "Links/Objects in the List: "+MyList.Count() I can naturally substitute Print with DrawText, but we have the issue where it's going to display all of that information on one line. Is there anyway to be able to print a list with DrawText and have it show everything in the list, or say DrawText the names into a list? What I'm initially shooting towards is something like the oldskool Final Fantasy games where your inventory is just a big catagorized text list you can scroll through. Last edited 2012 |
| ||
Global i% For Local S:TShip = EachIn MyList i=i+1 DrawText "Name: "+S.Name+" Score:"+S.Score, 30,30+i*50 Next i=i+1 DrawText "Links/Objects in the List: "+MyList.Count(),30,30+i*50 or more elegant: Global i% For Local S:TShip = EachIn MyList PrintText "Name: "+S.Name+" Score:"+S.Score Next PrintText "Links/Objects in the List: "+MyList.Count() Function PrintText(t$) i=i+1 DrawText t,30,30+i*50 End Function |
| ||
Thank you so very much! Now.. I understand that For is creating the loop, but I can't figure out how to just display this text once instead of creating a loop with the draw text. I'll keep cracking at it. |
| ||
Nvm I had to put my CLS at the top (for whatever reason). Thank you! |
| ||
If you want to draw text in different lines you always have to use a FOR/NEXT loop to get the y-parameter changed. So it is very comfortable to use the existing FOR/EACH loop to do it immediately here. It don't understand exactly what you plan to do... Of course, you could combine all phrases to one big string, but in the end you would have to separate it and use a FOR/NEXT to display it in lines. When you run this in a game loop, you have to reset i% before output to always get the same position: Repeat Cls Inventary() Flip 1 Forever Function Inventary() Local i%=0 For Local S:TShip = EachIn MyList i=i+1 DrawText "Name: "+S.Name+" Score:"+S.Score, 30,30+i*50 Next i=i+1 DrawText "Links/Objects in the List: "+MyList.Count(),30,30+i*50 End Function in the elegant way you have to send a RESET-Flag to the Print-Function: Repeat Cls Inventary() Flip 1 Forever Function Inventary() PrintText "", TRUE For Local S:TShip = EachIn MyList PrintText "Name: "+S.Name+" Score:"+S.Score Next PrintText "Links/Objects in the List: "+MyList.Count() End Function Function PrintText(t$, ResetFlag%=FALSE) Global i% If ResetFlag=TRUE i=0 Return Endif i=i+1 DrawText t,30,30+i*50 End Function Last edited 2012 |
| ||
Very helpful perspective, thank you. |