Compile Error

BlitzMax Forums/BlitzMax Beginners Area/Compile Error

Blitzogger(Posted 2006) [#1]
When i attempt to compile my game i get this error:

Compile Error:
Unable to open file '.bmx/SpaceXScape.bmx.release.win32.x86.i'

The source can be downloaded at this link:
http://spacexscape.freepgs.com/beta.zip

Note: I have written all the source myself, however the game is Community Open Source and you are allowed to modify it however you like.


H&K(Posted 2006) [#2]
You are trying to import a file that hasnt been compiled yet. (Total guess)


Dreamora(Posted 2006) [#3]
Yupp sounds like quick build enabled but manually cleared the .bmx folder


Blitzogger(Posted 2006) [#4]
Thank You


Blitzogger(Posted 2006) [#5]
Bad News, I Tried Unchecking Quick Build And I'm Still Getting This Error.


Dreamora(Posted 2006) [#6]
I just checked the source.

the problem is that you have cyclic import!

You can't do the follow

File A

import B


File B

import A



If both need to use stuff from the other, you must use include. (or do abstract base types which both then import)


Blitzogger(Posted 2006) [#7]
I have reuploaded a new version of the source. This time i get Identifier StartGame not found. However if you look at GameEngine.bmx there is a method called StartGame(). Also at the very top of SpaceXscape.bmx you will notice that i am including GameEngine.bmx, which should make it work. Any ideas?


H&K(Posted 2006) [#8]
Startgame is a method. and as such needs an instance of TGameEngine to run. You can only do TGameEngine then a function
TGameEngine.MemberFunction <---- WIll work
TGameEngine.MemberMethod <----Will not work


(I still get an error like, just a different one)


Blitzogger(Posted 2006) [#9]
I changed StartGame from a method to a function and have uploaded the changes. The link remains the same. However I get the following error when i turn on debug:
Unhandled Exception:Attempt to access field or method of null object. Any ideas?


H&K(Posted 2006) [#10]
You probably have no objects in ths "GameObjects"


Blitzogger(Posted 2006) [#11]
I don't understand what you mean. I have 1 file which includes every single source file. I shouldn't be missing anything.


H&K(Posted 2006) [#12]
There are no objects in the list GameObjects


Blitzogger(Posted 2006) [#13]
How is this possible?

' ---------------------------------------------------------------------------------------------------
' Game Object Type
' Contains The Fields That All Other Objects Will Extend From
'----------------------------------------------------------------------------------------------------
Type TGameObject

    Field X_Position:Int
    Field Y_Position:Int
	Field X_Start_Position:Int    
	Field Y_Start_Position:Int
	Field X_Velocity:Float
    Field Y_Velocity:Float
	Field X_Start_Velocity:Float=3
    Field Y_Start_Velocity:Float=3    
	Field Image:TImage
    Field X_Scale:Float
    Field Y_Scale:Float
	Field Rotation:Int=0
	
' ----------------------------------------------------------------------------------------------------
' Method Draw
' Draws The Game Object To The Screen
' --------------------------------------------------------------------------------------------------
    Method Draw()
	SetScale X_Scale, Y_Scale    
	SetRotation Rotation
    DrawImage Image, X_Position, Y_Position
    End Method     

' ----------------------------------------------------------------------------------------------------
' Method Reset
' Resets all the Game Objects To Their initial Position
' --------------------------------------------------------------------------------------------------
    Method Reset()
        X_Position = X_Start_Position
		Y_Position = Y_Start_Position
		X_Velocity = X_Start_Velocity
		Y_Velocity = Y_Start_Velocity        
    End Method

'---------------------------------------------------------------------------------------------------
' Method Update
' Updates the Game Objects On The Screen
' --------------------------------------------------------------------------------------------------
     Method Update() Abstract

'---------------------------------------------------------------------------------------------------
' Fuction CreateObject
' Creates the Game Object
'---------------------------------------------------------------------------------------------------
	Function CreateObject(Obj:TGameObject, Image:TImage, New_X_Start_Position:Int,New_Y_Start_Position:Int, New_Scale:Float=1.0)

        Obj.X_Start_Position = New_X_Start_Position
        Obj.y_start_position = New_Y_Start_Position
        Obj.X_Scale = New_Scale
        Obj.Y_Scale = New_Scale
        Obj.Image = Image

       If Obj.Image=Null
           Print "Not able to load image file. Program aborting"
           End
       EndIf
		
		Obj.Reset()
		
        ListAddLast GameObjects, Obj 
	End Function


Type TGameEngine Extends TGameObject
	
	Function Create:TGameEngine(Image:TImage)
        Local GameEngine:TGameEngine = New TGameEngine
        CreateObject(GameEngine, Image, 0, 0, 1.0)
        Return GameEngine
    End Function
	
    Method Update()
	'not needed at the moment
   	End Method
	
	Function StartGame()

	TBall.Create(LoadImage(Data_Path + "ball.png"), Screen_Width/2, 400)

	Repeat
     Cls
     For Local o:TGameObject = EachIn GameObjects
         o.Draw()
         o.Update()
     Next
     Flip 
  	Until KeyDown(KEY_ESCAPE) Or AppTerminate()
    
	End
	End Function

	End Type


Type TBall Extends TGameObject

    Function Create:TBall(Image:TImage, X_Start_Position:Int, Y_Start_Position:Int)
        Local Ball:TBall = New TBall
        CreateObject(Ball, Image, X_Start_Position, Y_Start_Position, 2.0)
        Return Ball
    End Function

    Method Update()

        X_Position :+ X_Velocity  'The Ball Moves By Its X_Velocity In The X Direction
        Y_Position :+ Y_Velocity  'The Ball Moves By Its Y Velocity In The Y Direction     
       
		'If A Collision With The Left Or Right Walls Has Occured
        If X_Position > Screen_Width Or X_Position < 0 Then
           X_Velocity =- X_Velocity     'Reverse The Balls X Velocity
        EndIf
        
		'If A Collision With The Top or Bottom Walls Has Occured
		If Y_Position > Screen_Height Or Y_Position < 0 Then
           Y_Velocity =- Y_Velocity     'Reverse The Balls Y Velocity
        EndIf
   
		Rotation :+ 10
        If Rotation >= 360 Then Rotation = 0
   End Method

End Type


SuperStrict

Include "GameObject.bmx"
Include "Ball.bmx"
Include "Brick.bmx"
Include "GameEngine.bmx"
Include "Paddle.bmx"
Include "Score.bmx"

AppTitle$ = "Space Xscape v0.1"

Global GameObjects:TList=CreateList()
Global Screen_Width:Int=640
Global Screen_Height:Int=480
Global Data_Path:String=BlitzMaxPath()+"/samples/Breakout/media/"

Graphics Screen_Width, Screen_Height
AutoMidHandle True
HideMouse()

TGameEngine.Create(LoadImage(DATA_PATH + "back1.png"))
TGameEngine.StartGame()


As you can see all the objects call Create which is a call to CreateObject which creates the object and adds it to the GameObjects List. I don't see why this is happening.


H&K(Posted 2006) [#14]
There are no objects in the list GameObjects


How is this possible?

Well Im going to vote for that yestrday when you asked the question the download was
Include "Ball.bmx"
Include "Brick.bmx"
Include "GameEngine.bmx"
Include "Paddle.bmx"
Include "Score.bmx"

AppTitle$ = "Space Xscape v0.1"

Global GameObjects:TList=CreateList()
Global Screen_Width:Int=640
Global Screen_Height:Int=480
Global Data_Path:String=BlitzMaxPath()+"/samples/Breakout/media/"

Graphics Screen_Width, Screen_Height
AutoMidHandle True
HideMouse()

TGameEngine.StartGame()


BUt anyway I was just guessing


Blitzogger(Posted 2006) [#15]
TGameEngine.Create(LoadImage(DATA_PATH + "back1.png"))
TGameEngine.StartGame()


I changed it so GameEngine was an object of TGameObject as you can see from the above code. Therefore The GameEngine becomes an object and is added to the GameObjects list first, making it 1 object in the GameObjects List before the ball is even loaded.


H&K(Posted 2006) [#16]
Ive changed
Global Data_Path:String=BlitzMaxPath()+"/samples/Breakout/media/"
to
Global Data_Path:String="/samples/Breakout/media/"
And it worked, (well it compiled and didnt crash)


Blitzogger(Posted 2006) [#17]
I am still getting the error even when i fixed the path AND add the correct file checking code as we talked about in my previous topic. As such i have uploaded a new zip with all the media and fixed code. This is very frusterating for me.


H&K(Posted 2006) [#18]
Space, it works on mine. nice little bouncy ball, with a square in the corner. What I would do if I was you, is Unzip the folder to somewhere it isnt normaly and see if it works then. Other than that I cannot help.


Blitzogger(Posted 2006) [#19]
Nope, didn't work. Can anyone else check and see if it works on theirs?


tonyg(Posted 2006) [#20]
Compiles for me.


Blitzogger(Posted 2006) [#21]
It compiles but, when i run it it locks up and all i get is a bar at the bottom of my windows toolbar showing that it is running.


tonyg(Posted 2006) [#22]
I get the bouncing ball.


H&K(Posted 2006) [#23]
MAke sure quick build isnt on. Other than that, Im stuppmed, make sure youve got the latest Bmax update. Sync mods. After that Im afraid we are down to check video drivers, (and I always think saying that is a copout)


Blitzogger(Posted 2006) [#24]
This is most likely it. Why is it Blitz3D gives a graphics error, and BlitzMax just crashes without no warnings?


H&K(Posted 2006) [#25]
Duplicate Post

I said check your driver, and I pointed out that I thought that it was cheating to say it, because its the same as saying "Its someone elses fault"

I assume that you took my advice about the "quick build off", and about relocating the whole thing to somewhere else. (different dir)?

Global MyGraphics:TGraphics =Graphics (Screen_Width, Screen_Height)
If MyGraphics = NULL then print "ohoh";End
(No offence to Mark, who code is doing the same thing)

Also if it was a graphics driver problem, the error would be in max2d or somwhere, it wouldnt be in your code, and you at no point have said this is so, Even thou I asked you several times to post the exact line the error happend on