<commit_before>CON
  _clkmode = XTAL1|PLL16X
  _xinfreq = 5_000_000

OBJ

    gfx     : "LameGFX"
    lcd     : "LameLCD"
    audio   : "LameAudio"
    ctrl    : "LameControl"
    fn      : "LameFunctions"

    map     : "map1"
    tilemap : "level1"
    lumpy   : "lumpy"

CON
    #0, LEFT, RIGHT

    WALKSPEED = 10
    GRAVITY = 18

VAR
    long    xoffset

    long    playerx
    long    playery
    long    oldx
    long    oldy
    long    speedx
    long    speedy
    byte    count, frame, dir, jumping

PUB Main

    lcd.Start(gfx.Start)
    gfx.ClearScreen(0)
    lcd.DrawScreen
    lcd.SetFrameLimit(40)
    gfx.LoadMap(tilemap.Addr, map.Addr)

    repeat
        ctrl.Update
        gfx.ClearScreen($5555)

        gfx.DrawMap(xoffset,0)

        HandlePlayer
    
        xoffset := playerx + (word[lumpy.Addr][1]>>1) - (lcd#SCREEN_W>>1)
        if xoffset < 0
            xoffset := 0      
        elseif xoffset > gfx.GetMapWidth << 3 - lcd#SCREEN_W
            xoffset := gfx.GetMapWidth << 3 - lcd#SCREEN_W



        lcd.DrawScreen



PUB HandlePlayer | adjust
    oldx := playerx
    oldy := playery    
            
    if ctrl.Left or ctrl.Right
    
            if ctrl.Left
                if ||speedx < WALKSPEED
                    speedx--

                dir := LEFT
            if ctrl.Right
                if speedx =< WALKSPEED
                    speedx++

                dir := RIGHT

            count++
            if count & $1 == 0
                case (count >> 2) & $1
                    0:  frame := 1
                    1:  frame := 2
    else
        if speedx > 0
            speedx--
        elseif speedx < 0
            speedx++
    
        frame := 0
        count := 0            
         
    playerx += (speedx ~> 2)

    adjust := gfx.TestMapMoveX(oldx, playery, word[lumpy.Addr][1], word[lumpy.Addr][2], playerx)
    if adjust
        playerx += adjust
        speedx := 0

    if ctrl.A
        if not jumping               
            speedy := -30
            jumping := 1                 
            
    if speedy < GRAVITY    
        speedy += 3

    playery += (speedy ~> 2)

    adjust := gfx.TestMapMoveY(playerx, oldy, word[lumpy.Addr][1], word[lumpy.Addr][2], playery)
    if adjust
        playery += adjust
        if  speedy > 0
            jumping := 0
        speedy := 0
    
    if speedy > 0
        jumping := 1

<commit_msg>Moved LameGFX maps functionality into LameMap; updated SDK apps to reflect new API.<commit_after>CON
  _clkmode = XTAL1|PLL16X
  _xinfreq = 5_000_000

OBJ

    gfx     : "LameGFX"
    lcd     : "LameLCD"
    map     : "LameMap"
    audio   : "LameAudio"
    ctrl    : "LameControl"
    fn      : "LameFunctions"

    map1    : "map1"
    tilemap : "level1"
    lumpy   : "lumpy"

CON
    #0, LEFT, RIGHT

    WALKSPEED = 10
    GRAVITY = 18

VAR
    long    xoffset

    long    playerx
    long    playery
    long    oldx
    long    oldy
    long    speedx
    long    speedy
    byte    count, frame, dir, jumping

PUB Main

    lcd.Start(gfx.Start)
    gfx.ClearScreen(0)
    lcd.DrawScreen
    lcd.SetFrameLimit(40)
    map.Load(tilemap.Addr, map1.Addr)

    repeat
        ctrl.Update
        gfx.ClearScreen($5555)

        map.Draw(xoffset,0)

        HandlePlayer
    
        xoffset := playerx + (word[lumpy.Addr][1]>>1) - (lcd#SCREEN_W>>1)
        if xoffset < 0
            xoffset := 0      
        elseif xoffset > map.GetWidth << 3 - lcd#SCREEN_W
            xoffset := map.GetWidth << 3 - lcd#SCREEN_W



        lcd.DrawScreen



PUB HandlePlayer | adjust
    oldx := playerx
    oldy := playery    
            
    if ctrl.Left or ctrl.Right
    
            if ctrl.Left
                if ||speedx < WALKSPEED
                    speedx--

                dir := LEFT
            if ctrl.Right
                if speedx =< WALKSPEED
                    speedx++

                dir := RIGHT

            count++
            if count & $1 == 0
                case (count >> 2) & $1
                    0:  frame := 1
                    1:  frame := 2
    else
        if speedx > 0
            speedx--
        elseif speedx < 0
            speedx++
    
        frame := 0
        count := 0            
         
    playerx += (speedx ~> 2)

    adjust := map.TestMoveX(oldx, playery, word[lumpy.Addr][1], word[lumpy.Addr][2], playerx)
    if adjust
        playerx += adjust
        speedx := 0

    if ctrl.A
        if not jumping               
            speedy := -30
            jumping := 1                 
            
    if speedy < GRAVITY    
        speedy += 3

    playery += (speedy ~> 2)

    adjust := map.TestMoveY(playerx, oldy, word[lumpy.Addr][1], word[lumpy.Addr][2], playery)
    if adjust
        playery += adjust
        if  speedy > 0
            jumping := 0
        speedy := 0
    
    if speedy > 0
        jumping := 1


{'fraction_non_alphanumeric': 0.09176374412425914, 'fraction_numerical': 0.024933578581647253, 'mean_word_length': 1.236745886654479, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, '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': '874466', 'n_tokens_mistral': 1731, 'n_tokens_neox': 1594, 'n_words': 396}