HELP!!! Error : Type 'CGameEngine' not found
Monkey Forums/Monkey Beginners/HELP!!! Error : Type 'CGameEngine' not found
| ||
I am getting the following error on the Free Version of Monkey X: "C:/MonkeyX77a/bin/transcc_winnt" -target=Desktop_Game -config=Debug -run "C:/MonkeyX77a/projects/geometry_game.monkey" TRANS monkey compiler V1.62 Parsing... Semanting... C:/MonkeyX77a/projects/geometry_game.monkey<7> : Error : Type 'CGameEngine' not found Done. I am creatinhg the simplist app that only creates a window. Game.monkey Strict Import CGameEngine Function Main:Int() ' Create an instance of the cGame class and store it inside the global var '_g' _g = New CGameEngine Return 0 End CGameEngine.monkey Strict Import mojo ' The cGame class controls the app Class CGameEngine Extends App '------------------------------------------ Method OnCreate:Int() ' Set the update rate of Mojo's OnUpdate to 60 FPS. SetUpdateRate(60) ' Set the device window on platforms that support it SetDeviceWindow (1280,600,4) Return 0 End '------------------------------------------ Method OnUpdate:Int() If KeyHit(KEY_ESCAPE) Then Error("") Return 0 End '------------------------------------------ Method OnRender:Int() ' Clear the screen with a random color Cls Rnd(0,255),Rnd(0,255),Rnd(0,255) Return 0 End End I am new to this and am very interested in buying the pro version. Any assistance in this matter would be greatly appreciated. Sincerely, Guest |
| ||
Your module name is the same as the class name. The compiler tends to be pretty paranoid about doing that. Your options are adding the module-name as a prefix, using an alias, or a different name for the module (Different from elements in the module). The "standard" way of handling this is to use lowercase file names. Otherwise, you'd need to write: The thing is, that's not preferable, so you'll probably want to use an alias in this case: Ideally, you should keep your file/module names lowercase, this will reduce naming conflicts. Also note that you haven't defined a global variable named '_g', so you'll get an error here. Unless you want to hack together game-instance detection, you should probably stick to a local variable for this. Or, if you need to pass around the object (Which is semi-common), pass it as an argument or parameter to another object. It's just cleaner that way. And, you don't have to worry about it being in some place in the executable, it'll just be on the stack (Or referenced in an object). Other than that, everything should work as expected. Just to confirm to anyone running Guest's code, this will have a new color each frame, so beware if you're epileptic. |