Programming Help
Monkey Forums/Monkey Programming/Programming Help
| ||
[Codebox] 'importing modules' Import mechanics Import menu 'writing constants' Const STATE_MENU:Int = 0 Const STATE_GAME:Int = 1 Const STATE_UPGRADES:Int = 2 Const STATE_SHOP:Int = 3 Class ClickingGame Extends App 'Defining variables' 'Defining automatic increments Field auto Field menu:Image Field menuX:Float Field menuY:Float Field bike:Image Field shoe:Image Field mouseclicks:Int = 0 Field shoeX:Float = 325.0 Field shoeY:Float = 250.0 Field clicktotal = 1 Field ding:Sound Field gameState:Int = STATE_MENU Method OnCreate() 'loading gamestate and images' gameState = STATE_MENU SetUpdateRate(60) shoe = LoadImage("shoe.png", 1, Image.MidHandle) ding = LoadSound("ding.wav") bike = LoadImage("Bicycle.gif", 1, Image.MidHandle) menu = LoadImage("menu.jpg", 1, Image.MidHandle) End Method OnUpdate() Select gameState Case STATE_MENU 'Registering menu hotkeys' If KeyHit(KEY_ENTER) gameState = STATE_GAME End Case STATE_GAME If KeyHit(KEY_ESCAPE) gameState = STATE_MENU Else If KeyHit(KEY_U) gameState = STATE_UPGRADES Else If KeyHit(KEY_S) gameState = STATE_SHOP Else If MouseHit(MOUSE_LEFT) mouseclicks = mouseclicks + clicktotal PlaySound(ding,0, 0) End Case STATE_UPGRADES If KeyHit(KEY_ESCAPE) gameState = STATE_GAME Elseif KeyHit(KEY_S) gameState = STATE_SHOP End Case STATE_SHOP If KeyHit(KEY_ESCAPE) gameState = STATE_GAME Elseif KeyHit(KEY_U) gameState = STATE_UPGRADES End End End Method OnRender() Cls(0, 0, 0) Select gameState 'Inserting graphics within game states Case STATE_MENU DrawText("Dominate the Market!", 320, 100, 0.5) DrawText("Press Enter to Play!", 320, 400, 0.5) Case STATE_GAME Cls(100, 100, 100) DrawText("$" +mouseclicks, 300, 125, 0.5, 0.5) FontHeight() DrawText("$ Per Click: $" +clicktotal, 300, 375, 0.5, 0.5) Case STATE_UPGRADES Cls(100, 200, 200) Case STATE_SHOP Cls(200, 200, 200) End End End 'Starting app Function Main:Int() New ClickingGame() End This code which I'm not sure how I have implemented an error opens the browser but instead of running shows this error message! Monkey Runtime Error : TypeError: Unable to get property 'LoadSurface' of undefined or null reference P:/MonkeyXFree84f/modules/mojo/graphics.monkey<239> D:/MonkeyXPro86e/Testgames/PershoreProject/main.monkey<101> [Codebox/] |
| ||
Hard to say actually. Could you provide the full source code. I assume you posted the "main.monkey" file? I don't see an "Import mojo" there which is needed or do you import it in one of your other files? In addition I see that you want to load a gif. Don't know if this works at all but at least you have to adapt your config.monkey for the html5 target then (take a note at the line with #IMAGE_FILES), otherwise trans will NOT copy that gif into your data folder of the compiled project: #HTML5_WEBAUDIO_ENABLED=True #MOJO_AUTO_SUSPEND_ENABLED=True #OPENGL_GLES20_ENABLED=False #TEXT_FILES+="*.txt|*.xml|*.json" #IMAGE_FILES+="*.png|*.jpg|*.gif" #SOUND_FILES+="*.wav|*.ogg|*.mp3|*.m4a" #MUSIC_FILES+="*.wav|*.ogg|*.mp3|*.m4a" #BINARY_FILES+="*.bin|*.dat" |
| ||
Mojo is imported from mechanics however that is all that is in mechanics as of yet. |
| ||
[Code] Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. Build started 17-Jan-17 6:25:27 PM. Project "F:\MonkeyXPro86e\Testgames\PershoreProject\main.buildv86e\glfw3\msvc\MonkeyGame.sln" on node 1 (default targets). ValidateSolutionConfiguration: Building solution configuration "Debug|Win32". Project "F:\MonkeyXPro86e\Testgames\PershoreProject\main.buildv86e\glfw3\msvc\MonkeyGame.sln" (1) is building "F:\MonkeyXPro86e\Testgames\PershoreProject\main.buildv86e\glfw3\msvc\MonkeyGame.vcxproj" (2) on node 1 (default targets). F:\MonkeyXPro86e\Testgames\PershoreProject\main.buildv86e\glfw3\msvc\MonkeyGame.vcxproj(18,3): error MSB4019: The imported project "F:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. Done Building Project "F:\MonkeyXPro86e\Testgames\PershoreProject\main.buildv86e\glfw3\msvc\MonkeyGame.vcxproj" (default targets) -- FAILED. Done Building Project "F:\MonkeyXPro86e\Testgames\PershoreProject\main.buildv86e\glfw3\msvc\MonkeyGame.sln" (default targets) -- FAILED. Build FAILED. "F:\MonkeyXPro86e\Testgames\PershoreProject\main.buildv86e\glfw3\msvc\MonkeyGame.sln" (default target) (1) -> "F:\MonkeyXPro86e\Testgames\PershoreProject\main.buildv86e\glfw3\msvc\MonkeyGame.vcxproj" (default target) (2) -> F:\MonkeyXPro86e\Testgames\PershoreProject\main.buildv86e\glfw3\msvc\MonkeyGame.vcxproj(18,3): error MSB4019: The imported project "F:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. 0 Warning(s) 1 Error(s) Time Elapsed 00:00:00.03 TRANS FAILED: Error executing '"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" /p:Configuration=Debug', return code=1 Done. [/Code] |
| ||
GLFW doesn't seem to set up properly. Have you tried to build with MinGW instead of Visual Studio? The latter can sometimes pretty annoying when not correctly installed. What about HTML5? Did that change help I suggested? |