I am new to max, and was working on this, with the end result hopefully being something where explosions underground will affect the "top soil".'
...It is SLOW ...Any Ideas?
Also, is there a way to sort items in lists? It would be nice if the soil would all move together when the layer beneath it is wiped out...
Strict Global objects:TList = New TList Global walkability[800,600] Const move_speed# =1 ' used by fps code Local old_ms=MilliSecs() Local renders Local fps Type dirt Field x#,y#,xPos,yPos Function start_game(pheta#) Local Width% = 800, Gravity# = 9.8 Local V0# = Sqr(((width/2)*Gravity)/(Sin(pheta)*Cos(pheta))) Local T# = 2*V0*Sin(pheta)*.5 For Local i# = 0 To T Step .01 Local x# = V0*Cos(pheta)*i Local y# = 600-((V0*Sin(pheta)*i) - (gravity*i*i*.5)) While y < 599 And x < 799 dirt.create(x,y) y = y+1 Wend Next EndFunction Function create(x#,y#) Local temp:dirt = New dirt temp.x = x temp.y = y temp.xPos = Floor(temp.x) temp.yPos = Floor(temp.y) walkability[temp.xPos,temp.yPos] = True objects.addlast(temp) EndFunction Function _Delete(x,y) For Local temp:dirt = EachIn objects If temp.xPos = x And temp.yPos = y Then walkability[temp.xPos,temp.yPos] = False objects.remove(temp) Exit EndIf Next EndFunction Method update() If walkability[xPos,yPos+1] = False Then walkability[xPos,yPos] = False y:+move_speed If y > 598 Then y = 598 xPos = Floor(x) ; yPos = Floor(y) walkability[xPos,yPos] = True EndIf Plot x,y EndMethod EndType Graphics 800,600 dirt.start_game(60) Repeat Cls For Local temp:dirt = EachIn objects temp.update() Next If MouseDown(1) Then For Local i = -20 To 20 For Local k = -20 To 20 dirt._delete(MouseX()+i,MouseY()+k) Next Next EndIf renders=renders+1 ' calculate fps If MilliSecs()-old_ms>=1000 old_ms=MilliSecs() fps=renders renders=0 EndIf DrawText fps,10,10 Flip Until KeyDown(1) Or AppTerminate() End
...It is SLOW ...Any Ideas?
Also, is there a way to sort items in lists? It would be nice if the soil would all move together when the layer beneath it is wiped out...