Arrays with Type

Started by Hotshot, June 18, 2019, 18:20:17

Previous topic - Next topic

Hotshot

It really old code and I could done random names and skills to save coding space


Graphics 640,480

Positions=1
Defence=0

Type test
    Global Position$
    Global Defence
Field val:Int[]

Method New()
val = New Int[11]
Local cnt=1
For Local i:Int=0 To val.length-1
val[i] = cnt
cnt=cnt+1
Next
End Method

Method draw()
Local x:Int=100
Local y:Int=100
SetColor 255,255,255


For Local i:Int=EachIn val
DrawText i,x,y

Select Positions
Case 0
     Position$="GK"
     Player$="Jame Heywoods"
     Skills=75
Case 1
Position$="DL"
Player$="Craig Ducking"
     Skills=82

Case 2
     Position$="DC"
     Player$="Damien Right"
     Skills=78

Case 3
    Position$="DC"
             Player$="Sam Square"
     Skills=85

Case 4
     Position$="DR"
     Player$="Dean Stauart"
     Skills=72

Case 5
             Position$="ML"
                 Player$="Craig Deeker"
     Skills=87

Case 6
     Position$="MC"
     Player$="Steve Leather"
     Skills=85

Case 7
     Position$="MC"
     Player$="Micheal Potter"
     Skills=80

Case 8
     Position$="MR"
     Player$="Jason Steven"
     Skills=92

Case 9
     Position$="ST"
     Player$="Martin Apple"
     Skills=87

Case 10
     Position$="ST"
     Player$="Graham Hill"
     Skills=95
End Select

DrawText Position$,35+x,y

DrawText Player$,75+x,y

DrawText Skills,205+x,y

y=y+15
        Positions=Positions+1
       
Next
End Method

End Type

Local team:test =New test
While Not KeyHit(KEY_ESCAPE)
Cls
team.draw()
Flip
Wend
[\code]