SuperStrict Graphics 800 , 600 SetClsColor 255 , 255 , 255 SetMaskColor 255,255,255 Global Units_img:Timage = LoadAnimImage("units_img.bmp",64,64,0,1) Global Tree_img:Timage = LoadAnimImage("tree_img.bmp",64,64,0,3) Global grass_img:Timage = LoadImage("grass.bmp") Type Tgame Field name:String Field player1:Tplayer Field player2:Tplayer Field TreeList:Tlist Field _exit:Int =0 Function Create:Tgame(_name:String) Local game:Tgame = New Tgame game.name = _name game.TreeList:Tlist = New Tlist game.player1:Tplayer = Tplayer.Create("Player1" , 100 , 47 , 300 , LoadImage("player1.bmp") ) game.player2:Tplayer = Tplayer.Create("Player2",100,753,300,LoadImage("player2.bmp")) Return game End Function Method update() If KeyHit(key_escape) _exit = 1 End If player1.update() player2.update() Local treecount:Int For Local Tree:Ttree = EachIn TreeList treecount = treecount + 1 Next If treecount < 10 TreeList.addlast(Ttree.Create(200 , 376 , 0) ) End If End Method Method render() player1.render() player2.render() DrawImage grass_img , 0 , 398 For Local tree:Ttree = EachIn TreeList render() Next Flip Cls End Method Method play() While _exit = 0 update() render() Wend End Method End Type Type Tplayer Field name:String Field money:Int Field x:Int , y:Int Field img:Timage Field UnitList:Tlist = New Tlist Field ArtileryList:Tlist = New Tlist Field ProtectorList:Tlist = New Tlist Field BulletList:Tlist = New Tlist Function Create:Tplayer(_name:String , _money:Int , _x:Int , _y:Int , _img:Timage) Local player:Tplayer = New Tplayer player.name = _name player.money = _money player.x = _x player.y = _y player.img = _img MidHandleImage( _img ) Return player End Function Method update() End Method Method render() DrawImage img , x , y End Method End Type Global game:Tgame = Tgame.Create("game") game.play()
Well I have this code(some parts are taken out)
If i run it it gives me a "Unhandled Exception: Unhandled Memory Exception Eror"
Weir thing is that this error apears on drawimage(on the render from player type) but if I remove the Treelist.addlast thing it works ok
I also made a similar code witch works well
SuperStrict Type Tstuff Field list:Tlist = New Tlist Function Create:Tstuff() Local stuff:Tstuff = New Tstuff Return stuff End Function Method addtolist() Local thing:Tthing = New Tthing list.addlast(thing) End Method End Type Type Tthing Field da:Int End Type Global test:Tstuff = Tstuff.Create() test.addtolist()
Please help me and tell me if this is a bug or my error