Missing type specifier?
BlitzMax Forums/BlitzMax Beginners Area/Missing type specifier?
| ||
I get a missing type specifier in this function.Function CreateBalloon:Int(balloon.BalloonCount:Int) For Local xiter:Int = 0 To balloon.BalloonCount Local b:balloon = New balloon b.XLoc = GraphicsWidth()/2 b.YLoc = GraphicsHeight()/2 b.Speed = Rand(3,10) b.BFrame = Rand(0,4) b.Direction = Rand(0,359) ListAddLast BalloonList,(b) If xiter => balloon.MaxBalloons Exit End If Return b Next BLIde points to the parameter section of the function as the problem part. Any help appreciated? [edit] I'm in SuperStrict mode. |
| ||
| I fixed it. New problem. I'm getting a "can't find b" in the following listremove section. Method UpdateBalloons() DrawImage AllBalloons,xloc,yloc,BFrame xloc:+ Cos(Direction) * Speed yloc:+ Sin(Direction) * Speed If xloc > 1050 or xloc < -50 ListRemove BalloonList,b End If If yloc > 790 or yloc < - 50 ListRemove BalloonList,b EndIf End Method [edit] Hang on. I have to redesign how I destroy things. |
| ||
I don't know what I'm doing. Can someone point me in the right direction on how to properly code this type?
Type balloon
Global List:TList
Field Link:TLink
Field xloc:Int
Field YLoc:Int
Field Speed:Int
Field BFrame:Int
Field Direction:Int
Global BalloonCount:Int = 0
Global MaxBalloons:Int = 20
Method New()
If List=Null
List=New TList
End If
Link=List.AddLast(Self)
End Method
Method Kill()
Link.Remove()
Link=Null
End Method
Function CreateBalloon:Int(BalloonCount:Int)
For Local xiter:Int = 0 To balloon.BalloonCount
Local b:balloon = New balloon
b.XLoc = GraphicsWidth()/2
b.YLoc = GraphicsHeight()/2
b.Speed = Rand(3,10)
b.BFrame = Rand(0,4)
b.Direction = Rand(0,359)
If balloon.BalloonCount >= balloon.MaxBalloons
Exit
End If
Return BalloonCount
Next
If balloon.BalloonCount => balloon.MaxBalloons Then balloon.BalloonCount = balloon.MaxBalloons
End Function
Method UpdateBalloons()
DrawImage AllBalloons,xloc,yloc,BFrame
xloc:+ Cos(Direction) * Speed
yloc:+ Sin(Direction) * Speed
If xloc > 1050 or xloc < -50
balloon.Kill
End If
If yloc > 790 or yloc < - 50
balloon.Kill
EndIf
End Method
End Type
I want to be able to remove a balloon when it exceeds it's boundaries. I'm still not that good with OOP. :/ |
| ||
maybe something along the lines of...Type balloon Global BalloonList:TList = New TList Global BalloonCount:Int = 0 Const MaxBalloons:Int = 20 Field xloc:Int Field YLoc:Int Field Speed:Int Field BFrame:Int Field Direction:Int Method Kill() BalloonList.Remove(Self) End Method Function CreateBalloon:Int(count:Int) ' trim count to fit... If BalloonCount + count > MaxBalloons Then count = MaxBalloons - BalloonCount ' add balloons For Local xiter:Int = 0 To count Local b:balloon = New balloon b.XLoc = GraphicsWidth()/2 b.YLoc = GraphicsHeight()/2 b.Speed = Rand(3,10) b.BFrame = Rand(0,4) b.Direction = Rand(0,359) ListAddLast BalloonList, b BalloonCount :+ 1 Next Return BalloonCount End Function Method UpdateBalloon() DrawImage AllBalloons,xloc,yloc,BFrame xloc:+ Cos(Direction) * Speed yloc:+ Sin(Direction) * Speed If xloc > 1050 Or xloc < -50 Kill End If If yloc > 790 Or yloc < - 50 Kill EndIf End Method Function UpdateBalloons() For Local b:balloon = EachIn BalloonList b.updateBalloon() Next End Function End Type |
| ||
| Nice one. Thanks. Works perfectly. :) |