New [C:\bmx\regaa/littleShooter.bmx;49;1]
BlitzMax Forums/BlitzMax Programming/New [C:\bmx\regaa/littleShooter.bmx;49;1]
| ||
| What does this line mean? Here s some code: Strict Const GWIDTH=800 Const GHEIGHT=600 Type starfield Extends Spiel Field x Field y Method Create:StarField(x:Int=0, y:Int=0) If x=0 Then x=rnd(0,GWIDTH) If y=0 Then y=rnd(0,GHEIGHT) End method Method Draw() End Method End Type Type Screen Field w=800 Field h=600 Method Create:screen(width=800,height=600) If width<>w Then width=w If height<>h Then height=h Graphics width,height,0,60 End Method End Type Type Spiel Field Bild:Screen=New Screen Field Bg:Starfield=New Starfield Method Init() Bild.Create() End Method Method Render() Cls Bg.Draw() FlushMem() Flip() End method End type Local Game:Spiel=New Spiel '<----- BUG? IAMSTUPID? IAMANEWB? Print "Initialisiert" Game.Init() While Not KeyDown(KEY_ESCAPE) Game.Render() Wend |
| ||
BlitzMax clearly doesn't like it if you use "New" in a field definition. It's those "New"s that are causing the problem, not the "New" you have commented. I don't know why this is, but I'm sure someone will be along in a minute to explain. Anyway, change the beginning of Spiel to this:Type Spiel
Field Bild:Screen
Field Bg:Starfield
Method Init()
Bild = New Screen
Bild.Create()
Bg = New Starfield
End Method
... |
| ||
| Ahhh, now i got it :). Thx |
| ||
| You can define new objects in the field definition. Surely creating something of type Spiel that has a field of type Starfield that extends type Spiel would cause issues though? |
| ||
| I don't see why? |
| ||
| I don't see why? Because it's recursive? |
| ||
| Ah, of course, now I see. |