void Update(IntPtr pParam) { bool prsd; pInput.GetKey(E_KEYBOARD_KEY_CODES.KEY_ESCAPE, out prsd); if (prsd) { pEngineCore.QuitEngine(); return; } TMouseStates states; pInput.GetMouseStates(out states); stMousePos = new TPoint2((float)states.iX, (float)states.iY); if (counter % 250 == 0) { ISoundChannel chan; pSndOwl.PlayEx(out chan, E_SOUND_SAMPLE_PARAMS.SSP_NONE); chan.SetPan((int)(owlX - cameraPosition.x)); chan.Unaquire(); } cameraPosition.x = (float)(GAME_VP_WIDTH / 2f + 250f + Math.Cos(counter / 200f) * 225f); cameraPosition.y = GAME_VP_HEIGHT / 2f + 300f; cameraAngle = (float)Math.Sin(counter / 200f) * 5f; cameraScale = (float)(1f + Math.Abs(Math.Sin(counter / 200f) * 0.25f)); lights[0].x = (float)(650f - Math.Cos(counter / 100f) * 100f); lights[0].y = (float)(700f - Math.Sin(counter / 150f) * 50f); if (owlX > 1500f) { owlGoLeft = true; } else if (owlX < 100f) { owlGoLeft = false; } owlX += (owlGoLeft ? -1f : 1f) * 4f; ++counter; }
void Init(IntPtr pParam) { // get subsystems pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RESOURCE_MANAGER, out p_sub_sys); pResMan = (IResourceManager)p_sub_sys; pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_INPUT, out p_sub_sys); pInput = (IInput)p_sub_sys; pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RENDER, out p_sub_sys); pRender = (IRender)p_sub_sys; pRender.GetRender2D(out pRender2D); // create arrays IEngineBaseObject pObj = null; pTextures = new ITexture[TexCount]; pShadows = new ITexture[ShadowCount]; pMeshes = new IMesh[MeshCount]; // loading data pResMan.Load(RESOURCE_PATH + "sounds\\helicopter.wav", out pObj, 0); pSound = (ISoundSample)pObj; pSound.PlayEx(out pSoundChannel, E_SOUND_SAMPLE_PARAMS.SSP_LOOPED); for (int i = 0; i < TexCount; i++) { uint flags = TexNames[i].Contains("grass") ? (uint)(E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR | E_TEXTURE_LOAD_FLAGS.TLF_COORDS_REPEAT) : (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D; pResMan.Load(RESOURCE_PATH + TexNames[i], out pObj, flags); pTextures[i] = (ITexture)pObj; } pTextures[6].SetFrameSize(256, 256); // zombie sprite splitting for (int i = 0; i < MeshCount; i++) { pResMan.Load(RESOURCE_PATH + MeshNames[i], out pObj, (uint)E_MESH_MODEL_LOAD_FLAGS.MMLF_FORCE_MODEL_TO_MESH); pMeshes[i] = (IMesh)pObj; } // render shadows for (int i = 0; i < MeshCount; i++) { RenderMeshToTexture(out pShadows[i], pMeshes[i], pTextures[i]); } // render rotor shadow pResMan.CreateTexture(out pShadows[5], null, 256, 256, E_TEXTURE_DATA_FORMAT.TDF_RGBA8, E_TEXTURE_CREATE_FLAGS.TCF_DEFAULT, E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR); pRender.SetRenderTarget(pShadows[5]); TPoint2 coords = new TPoint2(128f, 128f); TColor4 col = TColor4.ColorWhite(); pRender2D.DrawCircle(ref coords, 100, 64, ref col, E_PRIMITIVE2D_FLAGS.PF_FILL); pRender.SetRenderTarget(null); // gather, fill and init 3d-objects data MyMeshes = new MyMesh[8] { new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2( 900f, 500f), new TPoint3(400f, 400f, 500f), 225), new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2(-250f, 300f), new TPoint3(400f, 400f, 500f), 225), new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2( 800f, 200f), new TPoint3(400f, 400f, 400f), 225), new MyMesh(pMeshes[1], pTextures[1], pShadows[1], new TPoint2( 0f, 450f), new TPoint3(300f, 300f, 400f), 175), new MyMesh(pMeshes[1], pTextures[1], pShadows[1], new TPoint2( 50f, 750f), new TPoint3(300f, 300f, 300f), 175), new MyMesh(pMeshes[2], pTextures[2], pShadows[2], new TPoint2( 500f, 150f), new TPoint3(400f, 400f, 500f), 225), new MyMesh(pMeshes[3], pTextures[3], pShadows[3], new TPoint2( 180f, 150f), new TPoint3(400f, 400f, 600f), 200), new MyMesh(pMeshes[3], pTextures[3], pShadows[3], new TPoint2( 600f, 550f), new TPoint3(400f, 400f, 600f), 200, 90) }; copter = new Copter(new MyMesh(pMeshes[4], pTextures[4], pShadows[4], new TPoint2(), new TPoint3(600, 600, 600), 200, 0, true), pTextures[5], pShadows[5]); zombie = new Zombie(pTextures[6]); }
void Init(IntPtr pParam) { // get subsystems pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RESOURCE_MANAGER, out p_sub_sys); pResMan = (IResourceManager)p_sub_sys; pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_INPUT, out p_sub_sys); pInput = (IInput)p_sub_sys; pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RENDER, out p_sub_sys); pRender = (IRender)p_sub_sys; pRender.GetRender2D(out pRender2D); // create arrays IEngineBaseObject pObj = null; pTextures = new ITexture[TexCount]; pShadows = new ITexture[ShadowCount]; pMeshes = new IMesh[MeshCount]; // loading data pResMan.Load(RESOURCE_PATH + "sounds\\helicopter.wav", out pObj, 0); pSound = (ISoundSample)pObj; pSound.PlayEx(out pSoundChannel, E_SOUND_SAMPLE_PARAMS.SSP_LOOPED); for (int i = 0; i < TexCount; i++) { uint flags = TexNames[i].Contains("grass") ? (uint)(E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR | E_TEXTURE_LOAD_FLAGS.TLF_COORDS_REPEAT) : (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D; pResMan.Load(RESOURCE_PATH + TexNames[i], out pObj, flags); pTextures[i] = (ITexture)pObj; } pTextures[6].SetFrameSize(256, 256); // zombie sprite splitting for (int i = 0; i < MeshCount; i++) { pResMan.Load(RESOURCE_PATH + MeshNames[i], out pObj, (uint)E_MESH_MODEL_LOAD_FLAGS.MMLF_FORCE_MODEL_TO_MESH); pMeshes[i] = (IMesh)pObj; } // render shadows for (int i = 0; i < MeshCount; i++) { RenderMeshToTexture(out pShadows[i], pMeshes[i], pTextures[i]); } // render rotor shadow pResMan.CreateTexture(out pShadows[5], null, 256, 256, E_TEXTURE_DATA_FORMAT.TDF_RGBA8, E_TEXTURE_CREATION_FLAGS.TCF_DEFAULT, E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR); pRender.SetRenderTarget(pShadows[5]); TPoint2 coords = new TPoint2(128f, 128f); TColor4 col = TColor4.ColorWhite(); pRender2D.DrawCircle(ref coords, 100, 64, ref col, E_PRIMITIVE2D_FLAGS.PF_FILL); pRender.SetRenderTarget(null); // gather, fill and init 3d-objects data MyMeshes = new MyMesh[8] { new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2(900f, 500f), new TPoint3(400f, 400f, 500f), 225), new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2(-250f, 300f), new TPoint3(400f, 400f, 500f), 225), new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2(800f, 200f), new TPoint3(400f, 400f, 400f), 225), new MyMesh(pMeshes[1], pTextures[1], pShadows[1], new TPoint2(0f, 450f), new TPoint3(300f, 300f, 400f), 175), new MyMesh(pMeshes[1], pTextures[1], pShadows[1], new TPoint2(50f, 750f), new TPoint3(300f, 300f, 300f), 175), new MyMesh(pMeshes[2], pTextures[2], pShadows[2], new TPoint2(500f, 150f), new TPoint3(400f, 400f, 500f), 225), new MyMesh(pMeshes[3], pTextures[3], pShadows[3], new TPoint2(180f, 150f), new TPoint3(400f, 400f, 600f), 200), new MyMesh(pMeshes[3], pTextures[3], pShadows[3], new TPoint2(600f, 550f), new TPoint3(400f, 400f, 600f), 200, 90) }; copter = new Copter(new MyMesh(pMeshes[4], pTextures[4], pShadows[4], new TPoint2(), new TPoint3(600, 600, 600), 200, 0, true), pTextures[5], pShadows[5]); zombie = new Zombie(pTextures[6]); }