About Monkey 2 › Forums › Monkey 2 Projects › Miralon Farm Game completed
This topic contains 6 replies, has 3 voices, and was last updated by 
 cocon 1 year, 9 months ago.
- 
		AuthorPosts
 - 
		
			
				
June 23, 2017 at 1:43 pm #8881
https://adamstrange.itch.io/miralonfarm

ok. This little number was created in 10 days for the Mirror Jam. And I’m all plum-tuckered out now.
The audio didn’t go to plan and I needed to revert back to very simple wav playback ;(
AI was nasty – and I know I’m not good at it either. so I need to improve a lot there.




Been a good learning process with my 3d stuff though. Needed to learn how to deal with things very quickly. Now I have time I can slow down and get the 3d stuff optimised and better thought out.
Hex based games look nice, but are a complete pig to program…
June 23, 2017 at 1:51 pm #8882Adam, you’re a machine! Incredible how fast you create those nice looking games!
June 23, 2017 at 9:24 pm #8885Is there any secret to produce games fast? Refactoring and fixing bad code design sucks too much time.
June 24, 2017 at 5:57 am #8886the simple answer is TOOLS! Let me expand on that using Maralon farm
This is the first dev image:

It’s a custom openGL system for monkey2 based on shaders. and based on Cocons base code. I took the framework nd rewrote it to support stuff I needed and then added a 3do model importer (3do is the model format I created for a 3d modeller I wrote called Rameses).
To use the monkey2 version you will need these 3 files:
Ramese3d.monkey2
matrix.monkey2
textural.monkey2
and finally the demo file:
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156#import "rameses3d"#import "assets/grid.3do"'the size of our windowConst Size := New Vec2i( 950,720 )'And some nice stuffconst PI:float = 3.14159265359const PIHALF:float = PI * 0.5const SHOW_TEX:float = 1const HIDE_TEX:float = 0const USE_LIGHT:float = 1const NO_LIGHT:float = 0Class MyWindow Extends GLWindow'this is the 3d systemfield my3d:Rameses3d'we need at lest one shaderfield myShader:GLShader'and this is the 3d objectfield r3d_Grid:int'we dont need this, but it is the texture that can be fed into rameses3dfield tex:TextureGLMethod New()'create a windowSuper.New( "My Window", Size.X, Size.Y, WindowFlags.Resizable )'this is a timer. it will 'tick' 60 times a second. calling OnUpdate_timer = New Timer( 60, OnUpdate )'if you want a constant canvas size use this' Layout = "letterbox"'or If you want the canvas to always fill the window use thisLayout = "fill"'get the shaders. we are not using any user defined ones, but we wil need to get a basic oneInitShaders()'next initalize Ramesesmy3d = New Rameses3d( Width, Height )'and set a light. Think of you the observer as position 0, 0, 0.' with x being left/right' y being up/down' and z being in/out z starts at 0, and goes minus away from you, plus towards you' so... 0, 1, -1 is centered, above and into the screenmy3d.SetLight( 0, 1, -2 )'load the texture - we are not using' tex = TextureGL.Load( "asset::ship32x32_font.png", TextureFlagsGL.Dynamic )'now we load the 3d shape from the assetsr3d_Grid = my3d.Load( "asset::grid.3do", myShader )'and finally some opengl'set the clear color of the screen to blackglClearColor(0, 0, 0, 1.0)'cull the face drawing and add depthglEnable(GL_CULL_FACE)glEnable(GL_DEPTH_TEST)Endmethod InitShaders()'first get the basic internal shader from Rameses3dmyShader = New GLShader()End methodMethod OnUpdate()'this 'ticks' at 60 fps'use it For your master updating system_gameTime = Millisecs()'lets update the rotation_objectRotate += 0.005'finally call everything to render'the render is done:OnRenderGL first then standard monkey2 OnRenderRequestRender()End MethodMethod OnRender(canvas:Canvas) OverrideApp.RequestRender()'this will call the opengl renderSuper.OnRender(canvas)canvas.DrawText( "FPS="+App.FPS,Width,0,1,0 )canvas.DrawText("Monkey2 OpenGL", 10, 10)canvas.Color = Color.Bluecanvas.DrawRect( 210, 10, 10, 200 )EndMethod OnRenderGL() Override'clear the screen buffersglClearStencil( 0 )glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT )'Drawing area. You're always drawing to the entire window in GL regardless of Layout.glViewport( 0, 0 ,Frame.Width, Frame.Height )'initalize the texture - we are not using' local texint:GLuint = tex.GLTexture' tex.Bind( 0, TextureFilterGL.None )Local scale:float = 1.618'here's the format for the following drawing commands:'method DrawModel( model:int, x:float, y:float, z:float, lightMix:float, textureMix:float, baseColor:Color, scale:float = 1, yrot:float = 0, xrot:float = 0, zrot:float = 0 )my3d.DrawLines( r3d_Grid, 0, -1.5, -3.7, NO_LIGHT, HIDE_TEX, Color.Cyan, scale, 0 )my3d.DrawModel( r3d_Grid, 0, -1, -3.7, NO_LIGHT, HIDE_TEX, Color.Orange, scale*0.5, _objectRotate, _objectRotate )my3d.DrawLines( r3d_Grid, 0, -.5, -3.7, NO_LIGHT, HIDE_TEX, Color.Red, scale*0.25, 0, -_objectRotate )Endprivate'the timer ticks 60 times a second and handles the screen updateField _timer:Timer'global game time derrived from a single call to Millisecs()field _gameTime:intfield _objectRotate:float = 0EndFunction Main()Local cfg := New StringMap<String>cfg["GL_depth_buffer_enabled"] = 1cfg["GL_stencil_buffer_enabled"] = 1New AppInstance( cfg )New MyWindowApp.Run()EndI’ve included all the files in a zip for you. but I thought the main file was better to be seen. the assets folder has lots of .3do files to play with
Attachments:
June 28, 2017 at 3:01 am #8980This means that you can create any tool needed to generate content in the most fast and productive way right?
June 28, 2017 at 5:48 am #8982yep. the tools I used are these:
fontsprite to create 2d graphics (you can see version 2 of the font being used, with darker graphics for the cards):

and then fontmap to create the cards (showing version 1 of the font). You can see how the grey font is being used to create both the green and blue edges for the cards. it also shows that most of the layers are off.

and the maps (with the final version of the font). you can also see that the map display is offset allowing me to quickly work on hex based maps)

I also used a bit of photoshop to do the other graphics.
All the tools are monkey2. But NOT MojoX. I wrote a custom GUI system that allows much better and simpler UI design.
coming on to the GUI of Miralon, I rewrote the above custom gui for game use. it’s a very small system that allows for fast prototyping:

You can see it here with the grid showing and 6 controls. they can use standard text, bitmaps, or graphics. and can be simply subclassed to write other handlers for any purpose. In this case I added the ability to use 3 images for a button: Off, over and top (the top text)
Here’s a snippet of code direct from miralon showing how I create a button:
Monkey1234567891011121314_button2 = New UXImageButton3( "Begin", _imageButton2, _imageButton1, _imageButton3 )_button2.SetGridLayout( 18, 16, 5, 2 )_button2.ImageColor = Color.Orange_button2.TextBold = True_button2.TextColor = Color.Black_button2.MouseEnter = Lambda()MouseEnter()End_button2.Clicked = Lambda()MouseClicked()OKClicked()EndAddControl( _button2 )You can see there is still code to do with Text that I should remove as its not being used, but it show how the code was quickly taken from another project and reused
The MouseEnter and MouseClicked signal back to the main program that it needs a sound. so when you hover a sound plays and when you click another sound plays
June 29, 2017 at 1:01 pm #9042Amazing stuff!
 - 
		AuthorPosts
 
You must be logged in to reply to this topic.