In this example code I am creating some cards both red and black.
For the life of me I cannot figure out how to remove, lets say all red cards or all black cards.
I've mucked around with things like RemoveFirst and RemoveEach, with no luck at all. Can anyone help me with this?
Strict
Import mojo
Global card_count:Int
Class Game Extends App
Field cards := New Stack<Card>'all cards
Method OnCreate:Int()
SetUpdateRate(60)
For card_count = 0 Until 10'85'create all cards
cards.Push New Card
Next
Return 0
End Method
Method OnUpdate:Int()
Return 0
End Method
Method OnRender:Int()
Cls()
Local y:Int = 0
For Local card := Eachin cards'cycle through all cards
DrawText(card.name, 0, y)
y = y + 10
Next
Return 0
End Method
End
Class Card'class for all cards
Field name:String'name
Method New()'create full deck, 84 cards
If card_count >= 0 And card_count <= 5
name = "Red"
End
If card_count > 4
name = "Black"
End
End Method'end method - New Card
End Class'class card
Function Main:Int()
New Game()
Return 0
End
For the life of me I cannot figure out how to remove, lets say all red cards or all black cards.
I've mucked around with things like RemoveFirst and RemoveEach, with no luck at all. Can anyone help me with this?
Strict
Import mojo
Global card_count:Int
Class Game Extends App
Field cards := New Stack<Card>'all cards
Method OnCreate:Int()
SetUpdateRate(60)
For card_count = 0 Until 10'85'create all cards
cards.Push New Card
Next
Return 0
End Method
Method OnUpdate:Int()
Return 0
End Method
Method OnRender:Int()
Cls()
Local y:Int = 0
For Local card := Eachin cards'cycle through all cards
DrawText(card.name, 0, y)
y = y + 10
Next
Return 0
End Method
End
Class Card'class for all cards
Field name:String'name
Method New()'create full deck, 84 cards
If card_count >= 0 And card_count <= 5
name = "Red"
End
If card_count > 4
name = "Black"
End
End Method'end method - New Card
End Class'class card
Function Main:Int()
New Game()
Return 0
End