<commit_before>﻿namespace Elmario
open Prime
open SDL2
open Nu
open Nu.Declarative
module Elmario =

    // here we create references for the entities that we are going to define for our game
    let Elmario = Default.Layer / "Elmario"
    let Ground = Default.Layer / "Ground"

    // this is our Elm-style command type
    type Command =
        | Jump
        | MoveLeft
        | MoveRight

    // this is our Elm-style game dispatcher
    type ElmarioDispatcher () =
        inherit GameDispatcher<unit, unit, Command> (())

        // here we define the Bindings used to connect events to their desired commands
        override this.Bindings (_, game, _) =
            [game.KeyboardKeyDownEvent =|>! fun evt ->
                if evt.Data.ScanCode = int SDL.SDL_Scancode.SDL_SCANCODE_UP && not evt.Data.Repeated
                then Some Jump
                else None
             game.UpdateEvent =|>! fun _ ->
                if KeyboardState.isKeyDown (int SDL.SDL_Scancode.SDL_SCANCODE_LEFT) then Some MoveLeft
                elif KeyboardState.isKeyDown (int SDL.SDL_Scancode.SDL_SCANCODE_RIGHT) then Some MoveRight
                else None]

        // here we handle the above commands
        override this.Command (command, _, _, world) =
            match command with
            | Jump ->
                let physicsId = Elmario.GetPhysicsId world
                if World.isBodyOnGround physicsId world
                then World.applyBodyForce (v2 0.0f 100000.0f) physicsId world
                else world
            | MoveLeft ->
                let physicsId = Elmario.GetPhysicsId world
                World.applyBodyForce (v2 -1000.0f 0.0f) physicsId world
            | MoveRight ->
                let physicsId = Elmario.GetPhysicsId world
                World.applyBodyForce (v2 1000.0f 0.0f) physicsId world

        // here we describe the content of the game including elmario and the ground he walks on.
        override this.Content (_, _, _) =
            [Content.screen Default.Screen Vanilla []
                [Content.layer Default.Layer []
                    [Content.sideViewCharacter Elmario
                        [Entity.Position == v2 0.0f 0.0f]
                     Content.block Ground
                        [Entity.Position == v2 -256.0f -64.0f
                         Entity.Size == v2 512.0f 64.0f]]]]<commit_msg>Minor clean-up.<commit_after>﻿namespace Elmario
open Prime
open SDL2
open Nu
open Nu.Declarative
module Elmario =

    // here we create references for the entities that we are going to define for our game
    let Elmario = Default.Layer / "Elmario"
    let Ground = Default.Layer / "Ground"

    // this is our Elm-style command type
    type Command =
        | MoveLeft
        | MoveRight
        | Jump

    // this is our Elm-style game dispatcher
    type ElmarioDispatcher () =
        inherit GameDispatcher<unit, unit, Command> (())

        // here we define the Bindings used to connect events to their desired commands
        override this.Bindings (_, game, _) =
            [game.UpdateEvent =|>! fun _ ->
                if KeyboardState.isKeyDown (int SDL.SDL_Scancode.SDL_SCANCODE_LEFT) then Some MoveLeft
                elif KeyboardState.isKeyDown (int SDL.SDL_Scancode.SDL_SCANCODE_RIGHT) then Some MoveRight
                else None
             game.KeyboardKeyDownEvent =|>! fun evt ->
                if evt.Data.ScanCode = int SDL.SDL_Scancode.SDL_SCANCODE_UP && not evt.Data.Repeated
                then Some Jump
                else None]

        // here we handle the above commands
        override this.Command (command, _, _, world) =
            match command with
            | MoveLeft ->
                let physicsId = Elmario.GetPhysicsId world
                World.applyBodyForce (v2 -1000.0f 0.0f) physicsId world
            | MoveRight ->
                let physicsId = Elmario.GetPhysicsId world
                World.applyBodyForce (v2 1000.0f 0.0f) physicsId world
            | Jump ->
                let physicsId = Elmario.GetPhysicsId world
                if World.isBodyOnGround physicsId world
                then World.applyBodyForce (v2 0.0f 100000.0f) physicsId world
                else world

        // here we describe the content of the game including elmario and the ground he walks on.
        override this.Content (_, _, _) =
            [Content.screen Default.Screen Vanilla []
                [Content.layer Default.Layer []
                    [Content.sideViewCharacter Elmario
                        [Entity.Position == v2 0.0f 0.0f]
                     Content.block Ground
                        [Entity.Position == v2 -256.0f -64.0f
                         Entity.Size == v2 512.0f 64.0f]]]]
{'fraction_non_alphanumeric': 0.07148864592094197, 'fraction_numerical': 0.020185029436501262, 'mean_word_length': 1.7182857142857142, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4009528', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1262, 'n_words': 398}