1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
Import mojo Global sprite:MyApp Function Main() sprite = New MyApp() End Function Class TColor Field r:Int,g:Int,b:Int Method Color() SetColor r,g,b End Method Method Set(rgb$) Self.r=255*(rgb[0]-48)/7 Self.g=255*(rgb[1]-48)/7 Self.b=255*(rgb[2]-48)/7 End Method End Class Class MyApp Extends App Field pixel:Int[256] Field palette:TColor[16] Method OnCreate() SetUpdateRate 50 For Local col:Int=0 To 15 palette[col]=New TColor palette[col].Set "000333555777300520742764003025247467020040160370"[col*3..col*3+3] Next For Local t:Int=0 To 255 pixel[t]=Rnd(16) Next End Method Method OnRender() Local i:Int For Local y:Int=0 To 15 For Local x:Int=0 To 15 palette[pixel[i]].Color DrawRect x*16,y*16,16,16 i=i+1 Next Next End Method Method OnUpdate() End Method End Class |