public static global::FilsDeBerger.SDL.MoveDirection FleeCharacters(SDL.Character curChar, int fleeDistance, SDL.Character[] charsToFlee) { SortTableOnNearestDistance(curChar, charsToFlee); if (charsToFlee.GetLength(0) > 0) { if (curChar.GetDistance(charsToFlee[0]) < fleeDistance) { // We will think of which direction to take as we fear player controlled Character if (Math.Abs(curChar.Position.X - charsToFlee[0].Position.X) > Math.Abs(curChar.Position.Y - charsToFlee[0].Position.Y)) { // Then it will be right or left if (curChar.Position.X < charsToFlee[0].Position.X) { // We are at the left of player controlled character, continue to the left return global::FilsDeBerger.SDL.MoveDirection.Left; } else { // We are at the right of player controlled character, continue to the right return global::FilsDeBerger.SDL.MoveDirection.Right; } } else { // It will be up or down if (curChar.Position.Y < charsToFlee[0].Position.Y) { // We are upper to player controlled character, continue to move up return global::FilsDeBerger.SDL.MoveDirection.Up; } else { // We are bottom to player controlled character, continue to move down return global::FilsDeBerger.SDL.MoveDirection.Down; } } } else { // We are not in the danger zone, let's just try to eat something return global::FilsDeBerger.SDL.MoveDirection.Stop; } } else { // There is a problem, stop the IA return global::FilsDeBerger.SDL.MoveDirection.Stop; } }
public static void SortTableOnNearestDistance(SDL.Character curChar, SDL.Character[] charsToFlee) { // 2. Find the nearest player Array.Sort<SDL.Character>( charsToFlee, delegate(SDL.Character a, SDL.Character b) { if (a != b) { return curChar.GetDistance(a).CompareTo(curChar.GetDistance(b)); } else { return 0; } }); }
public static void SetDisplayPosition(int x, int y) { SDL.SDL_SetWindowPosition(DisplHandle, x, y); }
static void Main(string[] args) { //Initialize SDL. A true value means initialization was successful. var isInitialized = Init(); _orangeTexturePtr = LoadTexture("OrangeBox"); _blueTexturePtr = LoadTexture("BlueBox"); SDL.SDL_QueryTexture(_orangeTexturePtr, out uint format, out int access, out _textureWidth, out _textureHeight); SDL.SDL_SetTextureColorMod(_orangeTexturePtr, 255, 255, 255); SDL.SDL_SetTextureAlphaMod(_orangeTexturePtr, 32); SDL.SDL_SetTextureBlendMode(_orangeTexturePtr, SDL.SDL_BlendMode.SDL_BLENDMODE_BLEND); SDL.SDL_SetTextureColorMod(_blueTexturePtr, 255, 255, 255); SDL.SDL_SetTextureAlphaMod(_blueTexturePtr, 32); SDL.SDL_SetTextureBlendMode(_blueTexturePtr, SDL.SDL_BlendMode.SDL_BLENDMODE_BLEND); Console.WriteLine("Press one of the arrow keys!"); Console.WriteLine(); //If successfully initialized. if (isInitialized) { //This can represent your game loop while (!_quit) { ProcessWindowEvents(); //Clear the screen SDL.SDL_RenderClear(_rendererPtr); var srcRect = new SDL.SDL_Rect() { x = 0, y = 0, w = _textureWidth, h = _textureHeight }; var destRect = new SDL.SDL_Rect() { x = _textureX, y = _textureY, w = _textureWidth, h = _textureHeight }; //Render texture to screen SDL.SDL_RenderCopy(_rendererPtr, _orangeTexturePtr, ref srcRect, ref destRect); destRect.x = _textureX + 60; SDL.SDL_RenderCopy(_rendererPtr, _blueTexturePtr, ref srcRect, ref destRect); //Update screen SDL.SDL_RenderPresent(_rendererPtr); } } else { Console.WriteLine("Failed to initialize!"); Console.ReadLine(); } }
// This is where we actually read in the controller input! private static GamePadState ReadState(PlayerIndex index, GamePadDeadZone deadZone) { IntPtr device = INTERNAL_devices[(int)index]; if (device == IntPtr.Zero) { return(GamePadState.InitializedState); } // Do not attempt to understand this number at all costs! const float DeadZoneSize = 0.27f; // SDL_GameController if (INTERNAL_isGameController[(int)index]) { // The "master" button state is built from this. Buttons gc_buttonState = (Buttons)0; // Sticks GamePadThumbSticks gc_sticks = new GamePadThumbSticks( new Vector2( (float)SDL.SDL_GameControllerGetAxis( device, SDL.SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_LEFTX ) / 32768.0f, (float)SDL.SDL_GameControllerGetAxis( device, SDL.SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_LEFTY ) / -32768.0f ), new Vector2( (float)SDL.SDL_GameControllerGetAxis( device, SDL.SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_RIGHTX ) / 32768.0f, (float)SDL.SDL_GameControllerGetAxis( device, SDL.SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_RIGHTY ) / -32768.0f ) ); gc_sticks.ApplyDeadZone(deadZone, DeadZoneSize); gc_buttonState |= READ_StickToButtons( gc_sticks.Left, Buttons.LeftThumbstickLeft, Buttons.LeftThumbstickRight, Buttons.LeftThumbstickUp, Buttons.LeftThumbstickDown, DeadZoneSize ); gc_buttonState |= READ_StickToButtons( gc_sticks.Right, Buttons.RightThumbstickLeft, Buttons.RightThumbstickRight, Buttons.RightThumbstickUp, Buttons.RightThumbstickDown, DeadZoneSize ); // Triggers GamePadTriggers gc_triggers = new GamePadTriggers( (float)SDL.SDL_GameControllerGetAxis(device, SDL.SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_TRIGGERLEFT) / 32768.0f, (float)SDL.SDL_GameControllerGetAxis(device, SDL.SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_TRIGGERRIGHT) / 32768.0f ); gc_buttonState |= READ_TriggerToButton( gc_triggers.Left, Buttons.LeftTrigger, DeadZoneSize ); gc_buttonState |= READ_TriggerToButton( gc_triggers.Right, Buttons.RightTrigger, DeadZoneSize ); // Buttons if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_A) != 0) { gc_buttonState |= Buttons.A; } if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_B) != 0) { gc_buttonState |= Buttons.B; } if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_X) != 0) { gc_buttonState |= Buttons.X; } if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_Y) != 0) { gc_buttonState |= Buttons.Y; } if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_BACK) != 0) { gc_buttonState |= Buttons.Back; } if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_GUIDE) != 0) { gc_buttonState |= Buttons.BigButton; } if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_START) != 0) { gc_buttonState |= Buttons.Start; } if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_LEFTSTICK) != 0) { gc_buttonState |= Buttons.LeftStick; } if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_RIGHTSTICK) != 0) { gc_buttonState |= Buttons.RightStick; } if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_LEFTSHOULDER) != 0) { gc_buttonState |= Buttons.LeftShoulder; } if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) != 0) { gc_buttonState |= Buttons.RightShoulder; } // DPad GamePadDPad gc_dpad; if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_DPAD_UP) != 0) { gc_buttonState |= Buttons.DPadUp; } if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_DPAD_DOWN) != 0) { gc_buttonState |= Buttons.DPadDown; } if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_DPAD_LEFT) != 0) { gc_buttonState |= Buttons.DPadLeft; } if (SDL.SDL_GameControllerGetButton(device, SDL.SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_DPAD_RIGHT) != 0) { gc_buttonState |= Buttons.DPadRight; } gc_dpad = new GamePadDPad(gc_buttonState); // Compile the master buttonstate GamePadButtons gc_buttons = new GamePadButtons(gc_buttonState); return(new GamePadState( gc_sticks, gc_triggers, gc_buttons, gc_dpad )); } // SDL_Joystick // We will interpret the joystick values into this. Buttons buttonState = (Buttons)0; // Sticks GamePadThumbSticks sticks = new GamePadThumbSticks( new Vector2( READTYPE_ReadFloat(INTERNAL_joystickConfig.AXIS_LX, device), -READTYPE_ReadFloat(INTERNAL_joystickConfig.AXIS_LY, device) ), new Vector2( READTYPE_ReadFloat(INTERNAL_joystickConfig.AXIS_RX, device), -READTYPE_ReadFloat(INTERNAL_joystickConfig.AXIS_RY, device) ) ); sticks.ApplyDeadZone(deadZone, DeadZoneSize); buttonState |= READ_StickToButtons( sticks.Left, Buttons.LeftThumbstickLeft, Buttons.LeftThumbstickRight, Buttons.LeftThumbstickUp, Buttons.LeftThumbstickDown, DeadZoneSize ); buttonState |= READ_StickToButtons( sticks.Right, Buttons.RightThumbstickLeft, Buttons.RightThumbstickRight, Buttons.RightThumbstickUp, Buttons.RightThumbstickDown, DeadZoneSize ); // Buttons buttonState = READ_ReadButtons(device, DeadZoneSize); // Triggers GamePadTriggers triggers = new GamePadTriggers( READTYPE_ReadFloat(INTERNAL_joystickConfig.TRIGGER_LT, device), READTYPE_ReadFloat(INTERNAL_joystickConfig.TRIGGER_RT, device) ); buttonState |= READ_TriggerToButton( triggers.Left, Buttons.LeftTrigger, DeadZoneSize ); buttonState |= READ_TriggerToButton( triggers.Right, Buttons.RightTrigger, DeadZoneSize ); // Compile the GamePadButtons with our Buttons state GamePadButtons buttons = new GamePadButtons(buttonState); // DPad GamePadDPad dpad = new GamePadDPad(buttons.buttons); // Return the compiled GamePadState. return(new GamePadState(sticks, triggers, buttons, dpad)); }
internal static void INTERNAL_AddInstance(int which) { if (which > 3) { return; // Ignoring more than 4 controllers. } // Clear the error buffer. We're about to do a LOT of dangerous stuff. SDL.SDL_ClearError(); // We use this when dealing with Haptic initialization. IntPtr thisJoystick; // Initialize either a GameController or a Joystick. if (SDL.SDL_IsGameController(which) == SDL.SDL_bool.SDL_TRUE) { INTERNAL_isGameController[which] = true; INTERNAL_devices[which] = SDL.SDL_GameControllerOpen(which); thisJoystick = SDL.SDL_GameControllerGetJoystick(INTERNAL_devices[which]); } else { INTERNAL_isGameController[which] = false; INTERNAL_devices[which] = SDL.SDL_JoystickOpen(which); thisJoystick = INTERNAL_devices[which]; } if (INTERNAL_devices[which] == IntPtr.Zero && thisJoystick == IntPtr.Zero) { // Crap, something went wrong. System.Console.WriteLine("JOYSTICK OPEN ERROR: " + SDL.SDL_GetError()); return; } // Add the index, better known as the instance ID, to the dictionary. int instance = SDL.SDL_JoystickInstanceID(thisJoystick); if (INTERNAL_instanceList.ContainsKey(instance)) { /* Some platforms (read: Windows) will try to open a joystick * multiple times. Fortunately, SDL2 covers this, but we need * our own set of checks to prevent duplicate entries. * -flibit */ return; } INTERNAL_instanceList.Add(instance, which); // Initialize the haptics for each joystick. if (SDL.SDL_JoystickIsHaptic(thisJoystick) == 1) { INTERNAL_haptics[which] = SDL.SDL_HapticOpenFromJoystick(thisJoystick); if (INTERNAL_haptics[which] == IntPtr.Zero) { System.Console.WriteLine("HAPTIC OPEN ERROR: " + SDL.SDL_GetError()); } } if (INTERNAL_haptics[which] != IntPtr.Zero) { if (SDL.SDL_HapticEffectSupported(INTERNAL_haptics[which], ref INTERNAL_effect) == 1) { SDL.SDL_HapticNewEffect(INTERNAL_haptics[which], ref INTERNAL_effect); } else if (SDL.SDL_HapticRumbleSupported(INTERNAL_haptics[which]) == 1) { SDL.SDL_HapticRumbleInit(INTERNAL_haptics[which]); } } // Check for an SDL_GameController configuration first! if (INTERNAL_isGameController[which]) { System.Console.WriteLine( "Controller " + which + ", " + SDL.SDL_GameControllerName(INTERNAL_devices[which]) + ", will use SDL_GameController support." ); } else { System.Console.WriteLine( "Controller " + which + ", " + SDL.SDL_JoystickName(INTERNAL_devices[which]) + ", will use generic MonoGameJoystick support." ); } }
/* ========================================================= */ public void Dispose() { SDL.SDL_DestroyRenderer(_ctx); }
public void DrawEllipse(int x, int y, int rx, int ry) { if (rx <= 0 || ry <= 0) { return; } int h, i, j, k; var ok = 0xFFFF; var oj = 0xFFFF; var oh = 0xFFFF; var oi = 0xFFFF; int ix, iy, xmi, xpi, xmj, xpj, ymi, ypi, xmk, xpk, ymh, yph; int ymj, ypj, xmh, xph, ymk, ypk; SDL.SDL_Point[] points = new SDL.SDL_Point[4]; if (rx > ry) { ix = 0; iy = rx * 64; h = (ix + 32) >> 6; i = (iy + 32) >> 6; while (i > h) { h = (ix + 32) >> 6; i = (iy + 32) >> 6; j = (h * ry) / rx; k = (i * ry) / rx; if (((ok != k) && (oj != k)) || ((oj != j) && (ok != j)) || (k != j)) { xph = x + h; xmh = x - h; if (k > 0) { ypk = y + k; ymk = y - k; points[0].x = xmh; points[0].y = ypk; points[1].x = xph; points[1].y = ypk; points[2].x = xmh; points[2].y = ymk; points[3].x = xph; points[3].y = ymk; SDL.SDL_RenderDrawPoints(_ctx, points, 4); } else { points[0].x = xmh; points[0].y = y; points[1].x = xph; points[1].y = y; SDL.SDL_RenderDrawPoints(_ctx, points, 2); } ok = k; xpi = x + i; xmi = x - i; if (j > 0) { ypj = y + j; ymj = y - j; points[0].x = xmi; points[0].y = ypj; points[1].x = xpi; points[1].y = ypj; points[2].x = xmi; points[2].y = ymj; points[3].x = xpi; points[3].y = ymj; SDL.SDL_RenderDrawPoints(_ctx, points, 4); } else { points[0].x = xmi; points[0].y = y; points[1].x = xpi; points[1].y = y; SDL.SDL_RenderDrawPoints(_ctx, points, 2); } oj = j; } ix += iy / rx; iy -= ix / rx; } } else { ix = 0; iy = ry * 64; h = (ix + 32) >> 6; i = (iy + 32) >> 6; while (i > h) { h = (ix + 32) >> 6; i = (iy + 32) >> 6; j = (h * rx) / ry; k = (i * rx) / ry; if (((oi != i) && (oh != i)) || ((oh != h) && (oi != h) && (i != h))) { xmj = x - j; xpj = x + j; if (i > 0) { ypi = y + i; ymi = y - i; points[0].x = xmj; points[0].y = ypi; points[1].x = xpj; points[1].y = ypi; points[2].x = xmj; points[2].y = ymi; points[3].x = xpj; points[3].y = ymi; SDL.SDL_RenderDrawPoints(_ctx, points, 4); } else { points[0].x = xmj; points[0].y = y; points[1].x = xpj; points[1].y = y; SDL.SDL_RenderDrawPoints(_ctx, points, 2); } oi = i; xmk = x - k; xpk = x + k; if (h > 0) { yph = y + h; ymh = y - h; points[0].x = xmk; points[0].y = yph; points[1].x = xpk; points[1].y = yph; points[2].x = xmk; points[2].y = ymh; points[3].x = xpk; points[3].y = ymh; SDL.SDL_RenderDrawPoints(_ctx, points, 4); } else { points[0].x = xmk; points[0].y = y; points[1].x = xpk; points[1].y = y; SDL.SDL_RenderDrawPoints(_ctx, points, 2); } oh = h; } ix += iy / ry; iy -= ix / ry; } } }
public void DrawLine(int x1, int y1, int x2, int y2) { SDL.SDL_RenderDrawLine(_ctx, x1, y1, x2, y2); }
public override void Draw(IntPtr rendererPtr, Camera camera) { //Orbit line //now we draw a line between each of the points in the translatedPoints[] array. float alpha = MaxAlpha; for (int i = 0; i < _numberOfDrawSegments - 1; i++) { var au = 1;//GameConstants.Units.MetersPerAu; int x1 = (int)(_drawPoints[i].x * au); int y1 = (int)(_drawPoints[i].y * au); int x2 = (int)(_drawPoints[i + 1].x * au); int y2 = (int)(_drawPoints[i + 1].y * au); //SDL.SDL_RenderDrawLine(rendererPtr, x1, y1, x2, y2); SDL.SDL_SetRenderDrawColor(rendererPtr, Red, Grn, Blu, (byte)alpha);//we cast the alpha here to stop rounding errors creaping up. SDL.SDL_RenderDrawLine(rendererPtr, x1, y1, x2, y2); //SDL.SDL_RenderDrawLine(rendererPtr, _drawPoints[i].x, _drawPoints[i].y, _drawPoints[i + 1].x, _drawPoints[i + 1].y); alpha -= _alphaChangeAmount; } //SOI filled circle area. SDL.SDL_SetRenderDrawColor(rendererPtr, 0, 50, 100, 100); //DrawPrimitive.DrawFilledCircle(rendererPtr ,ViewScreenPos.x , ViewScreenPos.y, (int)_soiViewRadius); //DrawPrimitive.DrawEllipse(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, _soiViewRadius, _soiViewRadius); var soipnts = CreatePrimitiveShapes.BresenhamCircle(0, 0, (int)_soiViewRadius); //SDL.SDL_RenderDrawPoints(rendererPtr, soipnts.ToArray(), soipnts.Count); var lasty = 0; for (int i = 0; i < soipnts.Count; i += 2) { var x = soipnts[i].x; var y = soipnts[i].y; if (y != lasty) { SDL.SDL_RenderDrawLine(rendererPtr, ViewScreenPos.x - x, ViewScreenPos.y - y, ViewScreenPos.x + x, ViewScreenPos.y - y); } lasty = y; } /* * for (int i = 0; i < soipnts.Count -1; i++) * { * //var err = SDL.SDL_GetError(); * //SDL.SDL_RenderDrawLine(rendererPtr, soipnts[i].x, soipnts[i].y, soipnts[i + 1].x, soipnts[i + 1].y); * if (SDL.SDL_RenderDrawPoint(rendererPtr, soipnts[i].x, soipnts[i].y) < 0) * { * var err = SDL.SDL_GetError(); * } * * //SDL.SDL_RenderDrawLine(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, soipnts[i].x, soipnts[i].y); * //var err2 = SDL.SDL_GetError(); * } */ //Planet Filled Circle SDL.SDL_SetRenderDrawColor(rendererPtr, 100, 0, 0, 255); DrawPrimitive.DrawEllipse(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, _targetViewRadius, _targetViewRadius); var plntPts = CreatePrimitiveShapes.BresenhamCircle(ViewScreenPos.x, ViewScreenPos.y, (int)_targetViewRadius); for (int i = 0; i < plntPts.Count - 1; i++) { SDL.SDL_RenderDrawLine(rendererPtr, plntPts[i].x, plntPts[i].y, plntPts[i + 1].x, plntPts[i + 1].y); } /* * SDL.SDL_SetRenderDrawColor(rendererPtr, 0, 100, 0, 160); * DrawPrimitive.DrawArc(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, 63, 63, 0, _loAN); //draw LoAN angle * * SDL.SDL_SetRenderDrawColor(rendererPtr, 50, 0, 100, 160); * DrawPrimitive.DrawArc(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, 64, 64, _loAN, _aoP); //draw AoP angle * * SDL.SDL_SetRenderDrawColor(rendererPtr, 100, 0, 0, 160); * DrawPrimitive.DrawArc(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, 66, 66, OrbitAngleRadians, _trueAnomaly); */ }
internal void InitializeOpenGL() { SetThreadAffinity(); context = SDL.SDL_GL_CreateContext(window.Window); if (context == IntPtr.Zero || SDL.SDL_GL_MakeCurrent(window.Window, context) < 0) { throw new InvalidOperationException("Can not create OpenGL context. (Error: {0})".F(SDL.SDL_GetError())); } OpenGL.Initialize(window.GLProfile == GLProfile.Legacy); OpenGL.CheckGLError(); if (OpenGL.Profile != GLProfile.Legacy) { OpenGL.glGenVertexArrays(1, out var vao); OpenGL.CheckGLError(); OpenGL.glBindVertexArray(vao); OpenGL.CheckGLError(); } OpenGL.glEnableVertexAttribArray(Shader.VertexPosAttributeIndex); OpenGL.CheckGLError(); OpenGL.glEnableVertexAttribArray(Shader.TexCoordAttributeIndex); OpenGL.CheckGLError(); OpenGL.glEnableVertexAttribArray(Shader.TexMetadataAttributeIndex); OpenGL.CheckGLError(); OpenGL.glEnableVertexAttribArray(Shader.TintAttributeIndex); OpenGL.CheckGLError(); }
public void SetVSyncEnabled(bool enabled) { VerifyThreadAffinity(); SDL.SDL_GL_SetSwapInterval(enabled ? 1 : 0); }
public void Present() { VerifyThreadAffinity(); SDL.SDL_GL_SwapWindow(window.Window); }
internal void EndRender() { SDL.SDL_RenderPresent(_renderer); }
public static void SetTitle(string title) { SDL.SDL_SetWindowTitle(DisplHandle, title); }
public bool EngineInit() { if (SDL.SDL_Init(SDL.SDL_INIT_VIDEO) < 0) return false; if (SDL.SDL_SetHint(SDL.SDL_HINT_RENDER_SCALE_QUALITY, "1") == SDL.SDL_bool.SDL_FALSE) { // some problem } // use opengl 3.3 core SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_MINOR_VERSION, 3); SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_PROFILE_MASK, SDL.SDL_GLprofile.SDL_GL_CONTEXT_PROFILE_CORE); var flags = SDL.SDL_WindowFlags.SDL_WINDOW_OPENGL | SDL.SDL_WindowFlags.SDL_WINDOW_SHOWN; if ((sdlWindow = SDL.SDL_CreateWindow("SDL Test", SDL.SDL_WINDOWPOS_UNDEFINED, SDL.SDL_WINDOWPOS_UNDEFINED, windowWidth, windowHeight, flags)) == IntPtr.Zero) { return false; } { // opengl sdlGlContext = SDL.SDL_GL_CreateContext(sdlWindow); if (sdlGlContext == IntPtr.Zero) { Console.WriteLine("OpenGL context could not be created! SDL Error: {0}", SDL.SDL_GetError()); } else { // use vsync if (SDL.SDL_GL_SetSwapInterval(1) < 0) { Console.WriteLine("Warning: Unable to set VSync! SDL Error: {0}", SDL.SDL_GetError()); } // configure OpenTK so it uses the OpenGL context made by SDL // https://github.com/mellinoe/ImGui.NET/issues/34#issuecomment-339567003 var contextHandle = new ContextHandle(sdlGlContext); GraphicsContext ___MOKAY___ = new GraphicsContext( contextHandle, (proc) => SDL.SDL_GL_GetProcAddress(proc), () => new ContextHandle(SDL.SDL_GL_GetCurrentContext()) ); // initialize bool openGlSuccess = true; if (!openGlSuccess) { Console.WriteLine("Unable to initialize OpenGL!"); return false; } } } // ---------- // wish: later: SDL.SDL_SetSystemTimerResolution(1); // need to update sdl? isSleepGranular = WinApi.TimeBeginPeriod(desiredSchedulerMs) == WinApi.TIMERR_NOERROR; Debug.Assert(isSleepGranular); SDL.SDL_Delay(128); // "wait for it to stabilize" (via stackoverflow) // also, prefer sdl // ---------- gameScreen = new HelloMultipleLights(); gameScreen.Init(); return true; }
// --- /*public void GameEvent(SDL.SDL_Event event_) { // todo: helloMulti.OnUpdate(event_); if (event_.type == SDL.SDL_EventType.SDL_MOUSEMOTION) { // todo: move to engine... just get mouse pos every frame int x, y; SDL.SDL_GetMouseState(out x, out y); Console.WriteLine("{0}, {1}", x, y); } else if (event_.type == SDL.SDL_EventType.SDL_MOUSEWHEEL) { } }*/ // --- // high resolution timer public UInt64 GetCounter() { UInt64 result = SDL.SDL_GetPerformanceCounter(); return result; }
public void DrawHLine(int x1, int x2, int y) { SDL.SDL_RenderDrawLine(_ctx, x1, y, x2, y); }
public int Execute(String[] args) { int monitorRefreshRate = 60; // todo: get with sdl? int gameUpdateRate = monitorRefreshRate; targetFrameDuration = 1f / gameUpdateRate; Debug.Assert(targetFrameDuration != 0); EngineInit(); // sdl & opengl UInt64 prevCounter = GetCounter(); SDL.SDL_Event event_; while (IsRunning) // main loop { UInt64 gaugeCounter = GetCounter(); // frame resets Input.FrameStart(); // events while (SDL.SDL_PollEvent(out event_) != 0) { switch (event_.type) { case SDL.SDL_EventType.SDL_QUIT: IsRunning = false; break; case SDL.SDL_EventType.SDL_KEYDOWN: Input.HandleKeyDown(event_); break; case SDL.SDL_EventType.SDL_KEYUP: Input.HandleKeyUp(event_); break; case SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN: Input.HandleMouseDown(event_); break; case SDL.SDL_EventType.SDL_MOUSEBUTTONUP: Input.HandleMouseUp(event_); break; case SDL.SDL_EventType.SDL_MOUSEWHEEL: Input.HandleMouseWheel(event_); break; default: break; } } //Console.WriteLine("^-a {0:0.0000}", GetCounterDeltaSeconds(gaugeCounter, GetCounter())); if (Input.WasPressed(SDL.SDL_Scancode.SDL_SCANCODE_Q)) { Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++"); Console.WriteLine("pressed Q..."); Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++"); } if (Input.WasReleased(SDL.SDL_Scancode.SDL_SCANCODE_Q)) { Console.WriteLine("--------------------------------------------"); Console.WriteLine("released Q..."); Console.WriteLine("--------------------------------------------"); } // update + render-prep EngineUpdate(targetFrameDuration); //Console.WriteLine("^-b {0:0.0000}", GetCounterDeltaSeconds(gaugeCounter, GetCounter())); // time since last frame, includes last frame's swap-window time plus the above GameUpdate and event handling code times double workSecondsElapsed = GetCounterDeltaSeconds(prevCounter, GetCounter()); // sleep for rest of frame time double frameSecondsElapsed = workSecondsElapsed; if (frameSecondsElapsed < targetFrameDuration) { if (isSleepGranular) { // how many ms left to wait, truncated, busy-wait remainder later UInt32 sleepMs = (UInt32) (1000 * (targetFrameDuration - frameSecondsElapsed)); //Console.WriteLine("sleepMs: {0}", sleepMs); // then we sleep if (sleepMs > 0) { SDL.SDL_Delay(sleepMs); } } double checkFrameSecondsElapsed = GetCounterDeltaSeconds(prevCounter, GetCounter()); if (checkFrameSecondsElapsed > targetFrameDuration) { Console.WriteLine("overshot target frame time, {0} / {1}", checkFrameSecondsElapsed, targetFrameDuration); }; // busy-wait the remaining time while (frameSecondsElapsed < targetFrameDuration) { // can optionally put the (isSleepGranular) block here, to be more robust in weird environments frameSecondsElapsed = GetCounterDeltaSeconds(prevCounter, GetCounter()); } //Console.WriteLine("^-d {0:0.0000}", GetCounterDeltaSeconds(gaugeCounter, GetCounter())); } else { // dropped a frame Console.WriteLine("--- dropped a frame, frameSecondsElapsed: {0:0.0000} | {0:0.0000} ---", frameSecondsElapsed, targetFrameDuration); } UInt64 endCounter = GetCounter(); double msPerFrame = 1000 * GetCounterDeltaSeconds(prevCounter, endCounter); prevCounter = endCounter; // RENDER HERE // Get sdlWindow Dimension & Render (SWAP BUFFER) SDL.SDL_GL_SwapWindow(sdlWindow); // SOUND OPTIONS: SDL (Basic), OpenAL (in OpenTK), FAudio (from FNA/SDLCS author) } // isRunning EngineCleanup(); return 1; }
public void FillEllipse(int x, int y, int rx, int ry) { if (rx <= 0 || ry <= 0) { return; } int h, i, j, k; var ok = 0xFFFF; var oj = 0xFFFF; var oh = 0xFFFF; var oi = 0xFFFF; SDL.SDL_Point[] points = new SDL.SDL_Point[2]; int ix, iy, xmi, xpi, xmj, xpj, xmh, xph, xmk, xpk; if (rx > ry) { ix = 0; iy = rx * 64; h = (ix + 32) >> 6; i = (iy + 32) >> 6; while (i > h) { h = (ix + 32) >> 6; i = (iy + 32) >> 6; j = (h * ry) / rx; k = (i * ry) / rx; if ((ok != k) && (oj != k)) { xph = x + h; xmh = x - h; if (k > 0) { int xmin = Calculate.Min(xmh, xph); int xmax = Calculate.Max(xmh, xph); SDL.SDL_RenderDrawLine(_ctx, xmin, (y + k), xmax, (y + k)); SDL.SDL_RenderDrawLine(_ctx, xmin, (y - k), xmax, (y - k)); } else { int xmin = Calculate.Min(xmh, xph); int xmax = Calculate.Max(xmh, xph); SDL.SDL_RenderDrawLine(_ctx, xmin, y, xmax, y); } ok = k; } if (oj != j && (ok != j) && (k != j)) { xmi = x - i; xpi = x + i; if (j > 0) { int xmin = Calculate.Min(xmi, xpi); int xmax = Calculate.Max(xmi, xpi); SDL.SDL_RenderDrawLine(_ctx, xmin, (y + j), xmax, (y + j)); SDL.SDL_RenderDrawLine(_ctx, xmin, (y - j), xmax, (y - j)); } else { int xmin = Calculate.Min(xmi, xpi); int xmax = Calculate.Max(xmi, xpi); SDL.SDL_RenderDrawLine(_ctx, xmin, y, xmax, (y - j)); } oj = j; } ix += iy / rx; iy -= ix / rx; } } else { ix = 0; iy = ry * 64; h = (ix + 32) >> 6; i = (iy + 32) >> 6; while (i > h) { h = (ix + 32) >> 6; i = (iy + 32) >> 6; j = (h * rx) / ry; k = (i * rx) / ry; if ((oi != i) && (oh != i)) { xmj = x - j; xpj = x + j; if (i > 0) { int xmin = Calculate.Min(xmj, xpj); int xmax = Calculate.Max(xmj, xpj); SDL.SDL_RenderDrawLine(_ctx, xmin, (y + i), xmax, (y + i)); SDL.SDL_RenderDrawLine(_ctx, xmin, (y - i), xmax, (y - i)); } else { int xmin = Calculate.Min(xmj, xpj); int xmax = Calculate.Max(xmj, xpj); SDL.SDL_RenderDrawLine(_ctx, xmin, y, xmax, (y - i)); } oi = i; } if ((oh != h) && (oi != h) && (i != h)) { xmk = x - k; xpk = x + k; if (h > 0) { int xmin = Calculate.Min(xmk, xpk); int xmax = Calculate.Max(xmk, xpk); SDL.SDL_RenderDrawLine(_ctx, xmin, (y + h), xmax, (y + h)); SDL.SDL_RenderDrawLine(_ctx, xmin, (y - h), xmax, (y - h)); } else { int xmin = Calculate.Min(xmk, xpk); int xmax = Calculate.Max(xmk, xpk); SDL.SDL_RenderDrawLine(_ctx, xmin, y, xmax, (y - h)); } oh = h; } ix += iy / ry; iy -= ix / ry; } } }
protected bool SetWindowPtrFromNative(IntPtr nativeWindowPtr) { sdlWindowPtr = SDL.SDL_CreateWindowFrom(nativeWindowPtr); if (sdlWindowPtr == IntPtr.Zero) { Debug.LogError("Failed to convert window handle to SDL window. Error: " + SDL.SDL_GetError()); return(false); } return(true); }
// Explicitly initialize the SDL Joystick/GameController subsystems private static bool Init() { return(SDL.SDL_InitSubSystem(SDL.SDL_INIT_JOYSTICK | SDL.SDL_INIT_GAMECONTROLLER | SDL.SDL_INIT_HAPTIC) == 0); }
public void Begin() { SDL.SDL_SetRenderTarget(_ctx, _baseSurface.Texture); SDL.SDL_SetRenderDrawColor(_ctx, 0, 0, 0, 255); SDL.SDL_RenderClear(_ctx); }
// Prepare the MonoGameJoystick configuration system private static void INTERNAL_AutoConfig() { if (!Init()) { return; } // Get the intended config file path. string osConfigFile = ""; if (SDL2_GamePlatform.OSVersion.Equals("Windows")) { osConfigFile = "MonoGameJoystick.cfg"; // Oh well. } else if (SDL2_GamePlatform.OSVersion.Equals("Mac OS X")) { osConfigFile += Environment.GetEnvironmentVariable("HOME"); if (osConfigFile.Length == 0) { osConfigFile += "MonoGameJoystick.cfg"; // Oh well. } else { osConfigFile += "/Library/Application Support/MonoGame/MonoGameJoystick.cfg"; } } else if (SDL2_GamePlatform.OSVersion.Equals("Linux")) { // Assuming a non-OSX Unix platform will follow the XDG. Which it should. osConfigFile += Environment.GetEnvironmentVariable("XDG_CONFIG_HOME"); if (osConfigFile.Length == 0) { osConfigFile += Environment.GetEnvironmentVariable("HOME"); if (osConfigFile.Length == 0) { osConfigFile += "MonoGameJoystick.cfg"; // Oh well. } else { osConfigFile += "/.config/MonoGame/MonoGameJoystick.cfg"; } } else { osConfigFile += "/MonoGame/MonoGameJoystick.cfg"; } } else { throw new Exception("SDL2_GamePad: SDL2 platform not handled!"); } // Check to see if we've already got a config... if (File.Exists(osConfigFile)) { // Load the file. FileStream fileIn = File.OpenRead(osConfigFile); // Load the data into our config struct. XmlSerializer serializer = new XmlSerializer(typeof(MonoGameJoystickConfig)); INTERNAL_joystickConfig = (MonoGameJoystickConfig)serializer.Deserialize(fileIn); // We out. fileIn.Close(); } else { // First of all, just set our config to default values. // NOTE: These are based on a 360 controller on Linux. // Start INTERNAL_joystickConfig.BUTTON_START.INPUT_TYPE = InputType.Button; INTERNAL_joystickConfig.BUTTON_START.INPUT_ID = 7; INTERNAL_joystickConfig.BUTTON_START.INPUT_INVERT = false; // Back INTERNAL_joystickConfig.BUTTON_BACK.INPUT_TYPE = InputType.Button; INTERNAL_joystickConfig.BUTTON_BACK.INPUT_ID = 6; INTERNAL_joystickConfig.BUTTON_BACK.INPUT_INVERT = false; // A INTERNAL_joystickConfig.BUTTON_A.INPUT_TYPE = InputType.Button; INTERNAL_joystickConfig.BUTTON_A.INPUT_ID = 0; INTERNAL_joystickConfig.BUTTON_A.INPUT_INVERT = false; // B INTERNAL_joystickConfig.BUTTON_B.INPUT_TYPE = InputType.Button; INTERNAL_joystickConfig.BUTTON_B.INPUT_ID = 1; INTERNAL_joystickConfig.BUTTON_B.INPUT_INVERT = false; // X INTERNAL_joystickConfig.BUTTON_X.INPUT_TYPE = InputType.Button; INTERNAL_joystickConfig.BUTTON_X.INPUT_ID = 2; INTERNAL_joystickConfig.BUTTON_X.INPUT_INVERT = false; // Y INTERNAL_joystickConfig.BUTTON_Y.INPUT_TYPE = InputType.Button; INTERNAL_joystickConfig.BUTTON_Y.INPUT_ID = 3; INTERNAL_joystickConfig.BUTTON_Y.INPUT_INVERT = false; // LB INTERNAL_joystickConfig.SHOULDER_LB.INPUT_TYPE = InputType.Button; INTERNAL_joystickConfig.SHOULDER_LB.INPUT_ID = 4; INTERNAL_joystickConfig.SHOULDER_LB.INPUT_INVERT = false; // RB INTERNAL_joystickConfig.SHOULDER_RB.INPUT_TYPE = InputType.Button; INTERNAL_joystickConfig.SHOULDER_RB.INPUT_ID = 5; INTERNAL_joystickConfig.SHOULDER_RB.INPUT_INVERT = false; // LT INTERNAL_joystickConfig.TRIGGER_LT.INPUT_TYPE = InputType.Axis; INTERNAL_joystickConfig.TRIGGER_LT.INPUT_ID = 2; INTERNAL_joystickConfig.TRIGGER_LT.INPUT_INVERT = false; // RT INTERNAL_joystickConfig.TRIGGER_RT.INPUT_TYPE = InputType.Axis; INTERNAL_joystickConfig.TRIGGER_RT.INPUT_ID = 5; INTERNAL_joystickConfig.TRIGGER_RT.INPUT_INVERT = false; // LStick INTERNAL_joystickConfig.BUTTON_LSTICK.INPUT_TYPE = InputType.Button; INTERNAL_joystickConfig.BUTTON_LSTICK.INPUT_ID = 9; INTERNAL_joystickConfig.BUTTON_LSTICK.INPUT_INVERT = false; // RStick INTERNAL_joystickConfig.BUTTON_RSTICK.INPUT_TYPE = InputType.Button; INTERNAL_joystickConfig.BUTTON_RSTICK.INPUT_ID = 10; INTERNAL_joystickConfig.BUTTON_RSTICK.INPUT_INVERT = false; // DPad Up INTERNAL_joystickConfig.DPAD_UP.INPUT_TYPE = InputType.PovUp; INTERNAL_joystickConfig.DPAD_UP.INPUT_ID = 0; INTERNAL_joystickConfig.DPAD_UP.INPUT_INVERT = false; // DPad Down INTERNAL_joystickConfig.DPAD_DOWN.INPUT_TYPE = InputType.PovDown; INTERNAL_joystickConfig.DPAD_DOWN.INPUT_ID = 0; INTERNAL_joystickConfig.DPAD_DOWN.INPUT_INVERT = false; // DPad Left INTERNAL_joystickConfig.DPAD_LEFT.INPUT_TYPE = InputType.PovLeft; INTERNAL_joystickConfig.DPAD_LEFT.INPUT_ID = 0; INTERNAL_joystickConfig.DPAD_LEFT.INPUT_INVERT = false; // DPad Right INTERNAL_joystickConfig.DPAD_RIGHT.INPUT_TYPE = InputType.PovRight; INTERNAL_joystickConfig.DPAD_RIGHT.INPUT_ID = 0; INTERNAL_joystickConfig.DPAD_RIGHT.INPUT_INVERT = false; // LX INTERNAL_joystickConfig.AXIS_LX.INPUT_TYPE = InputType.Axis; INTERNAL_joystickConfig.AXIS_LX.INPUT_ID = 0; INTERNAL_joystickConfig.AXIS_LX.INPUT_INVERT = false; // LY INTERNAL_joystickConfig.AXIS_LY.INPUT_TYPE = InputType.Axis; INTERNAL_joystickConfig.AXIS_LY.INPUT_ID = 1; INTERNAL_joystickConfig.AXIS_LY.INPUT_INVERT = false; // RX INTERNAL_joystickConfig.AXIS_RX.INPUT_TYPE = InputType.Axis; INTERNAL_joystickConfig.AXIS_RX.INPUT_ID = 3; INTERNAL_joystickConfig.AXIS_RX.INPUT_INVERT = false; // RY INTERNAL_joystickConfig.AXIS_RY.INPUT_TYPE = InputType.Axis; INTERNAL_joystickConfig.AXIS_RY.INPUT_ID = 4; INTERNAL_joystickConfig.AXIS_RY.INPUT_INVERT = false; // Since it doesn't exist, we need to generate the default config. // ... but is our directory even there? string osConfigDir = osConfigFile.Substring(0, osConfigFile.IndexOf("MonoGameJoystick.cfg")); if (!String.IsNullOrEmpty(osConfigDir) && !Directory.Exists(osConfigDir)) { // Okay, jeez, we're really starting fresh. Directory.CreateDirectory(osConfigDir); } // So, create the file. FileStream fileOut = File.Open(osConfigFile, FileMode.OpenOrCreate); XmlSerializer serializer = new XmlSerializer(typeof(MonoGameJoystickConfig)); serializer.Serialize(fileOut, INTERNAL_joystickConfig); // We out. fileOut.Close(); } // Limit to the first 4 sticks to avoid crashes. int numSticks = Math.Min(4, SDL.SDL_NumJoysticks()); for (int x = 0; x < numSticks; x++) { INTERNAL_AddInstance(x); } }
public void EndClip() { SDL.SDL_RenderSetClipRect(_ctx, IntPtr.Zero); }
private static IntPtr LoadTexture(string textureName) { var texturePath = $@"Content\{textureName}.png"; //The final optimized image var newTexture = IntPtr.Zero; //Load image at specified path var loadedSurface = SDL_image.IMG_Load(texturePath); if (loadedSurface == IntPtr.Zero) { Console.WriteLine("Unable to load image {0}! SDL Error: {1}", texturePath, SDL.SDL_GetError()); } else { //Create texture from surface pixels newTexture = SDL.SDL_CreateTextureFromSurface(_rendererPtr, loadedSurface); if (newTexture == IntPtr.Zero) { Console.WriteLine("Unable to create texture from {0}! SDL Error: {1}", texturePath, SDL.SDL_GetError()); } //Get rid of old loaded surface SDL.SDL_FreeSurface(loadedSurface); } return(newTexture); }
public void BeginSurface(PicoSurface surface) { SDL.SDL_SetRenderTarget(_ctx, surface.Texture); SDL.SDL_SetRenderDrawColor(_ctx, 0, 0, 0, 255); SDL.SDL_RenderClear(_ctx); }
private static bool Init() { //Init the video card if (SDL.SDL_Init(SDL.SDL_INIT_VIDEO) < 0) { Console.WriteLine("SDL could not initialize! SDL_Error: {0}", SDL.SDL_GetError()); return(false); } else { //Create an SDL window to render graphics upon. _windowPtr = SDL.SDL_CreateWindow("SDL2 Keyboard Sample", SDL.SDL_WINDOWPOS_CENTERED, SDL.SDL_WINDOWPOS_CENTERED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL.SDL_WindowFlags.SDL_WINDOW_SHOWN); _rendererPtr = SDL.SDL_CreateRenderer(_windowPtr, -1, SDL.SDL_RendererFlags.SDL_RENDERER_ACCELERATED); if (_windowPtr == IntPtr.Zero) { Console.WriteLine("The window could not be created!!"); Console.ReadLine(); return(false); } else { //Initialize PNG loading var imgFlags = SDL_image.IMG_InitFlags.IMG_INIT_PNG; if ((SDL_image.IMG_Init(imgFlags) > 0 & imgFlags > 0) == false) { //TODO: Convert to exception Console.WriteLine("SDL_image could not initialize! SDL_image Error: {0}", SDL.SDL_GetError()); return(false); } } } return(true); }
public void EndSurface() { SDL.SDL_SetRenderTarget(_ctx, _baseSurface.Texture); }
public static void SetDisplayBorderless(bool borderless) { SDL.SDL_SetWindowBordered(DisplHandle, (SDL.SDL_bool)(borderless ? 0 : 1)); }
public void SetColor(ref Color color) { SDL.SDL_SetRenderDrawColor(_ctx, color.R, color.G, color.B, 255); }
public static string GetTitle() { return(SDL.SDL_GetWindowTitle(DisplHandle)); }
/// <summary> /// Method responsible of sheep movement /// </summary> /// <param name="curChar">Current sheep to move</param> /// <param name="allChar">Table of all characters of the game</param> /// <returns>Direction in which the sheep will move</returns> public static SDL.MoveDirection Think(SDL.Character curChar, SDL.Character[] allChar) { if (!curChar.Disposed) { // Is sheep safe or not, if safe, run out of the screen SDL.Sheep curSheep = curChar as SDL.Sheep; if (curSheep.Safe) { if (curSheep.X < ScreenSize.Width) { return global::FilsDeBerger.SDL.MoveDirection.Right; } else { return global::FilsDeBerger.SDL.MoveDirection.Stop; } } else { // First check we are in screen if (curChar.X <= 1) { return global::FilsDeBerger.SDL.MoveDirection.Right; } else if (curChar.X >= ScreenSize.Width - curChar.Width) { return global::FilsDeBerger.SDL.MoveDirection.Left; } else if (curChar.Y <= 1) { return global::FilsDeBerger.SDL.MoveDirection.Down; } else if (curChar.Y >= ScreenSize.Height - curChar.Height) { return global::FilsDeBerger.SDL.MoveDirection.Up; } else { // Is sheep near one of the player controlled objects // 1. Find the player controlled characters SDL.Character[] charactersToFlee = Array.FindAll( allChar, delegate(SDL.Character toCheck) { return toCheck.Control == global::FilsDeBerger.SDL.Controller.Player || toCheck.Control == global::FilsDeBerger.SDL.Controller.AltPlayer || toCheck.Eatable == false; }); SDL.MoveDirection result = CommonIABehaviors.FleeCharacters(curChar, 100, charactersToFlee); if (result == global::FilsDeBerger.SDL.MoveDirection.Stop) { // We are not in the danger zone, let's just do something stupid if (t.NextDouble() > .9) { // Choose a new direction result = (SDL.MoveDirection)t.Next(5); } else { if (t.NextDouble() > .7) { // Just stop the sheep result = global::FilsDeBerger.SDL.MoveDirection.Stop; } else { // We just continue in the same direction switch (curChar.CurrentAnimation) { case "WalkUp": result = global::FilsDeBerger.SDL.MoveDirection.Up; break; case "WalkDown": result = global::FilsDeBerger.SDL.MoveDirection.Down; break; case "WalkLeft": result = global::FilsDeBerger.SDL.MoveDirection.Left; break; case "WalkRight": result = global::FilsDeBerger.SDL.MoveDirection.Right; break; default: result = global::FilsDeBerger.SDL.MoveDirection.Stop; break; } } } } return result; } } } else { return global::FilsDeBerger.SDL.MoveDirection.Stop; } }