Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

I need Help

edited November 29 in Questions Posts: 13

Hello.
I am new here and i have created al little test game for my own, but it doesn’t works.
I would like to save the variable „p“ (total points), but it doesn’t works..
I know that it is this command „saveLocalData=("save_p"), p“... but i can’t put it on the right place...
Can you help me please?

-----------------------------------------
-- Coin Kollektor
-- Written by Biberjumper
-----------------------------------------
-- Description
-- You can touch and you get points
-- you can save this points, by standing on the chest, and clicking "x" or "X"
-- The points at the top will be saved, but the points at the Button, will be deletet, wen you dont click x by the Box
--
-- You can move with "w, a, s, d"
-- I hope you have Fun ;)
-- P.s. Sorry for my Englisch... I am a german boy... xD
-----------------------------------------

-- Coin Kollektor
displayMode(FULLSCREEN)

function setup()
    print("Gehe auf die Kiste und Sammle die Klick punkte mit x")
    showKeyboard()
    --Spieler und Kiste werden erstellt
    player=sprite("Planet Cute:Character Boy")
    chest=sprite("Planet Cute:Chest Closed")
    --x und p werden erstellt und gespeichert
    fontSize(200)
    fill(0, 200, 255, 255)
    x=readLocalData("save_x") or 0
    p=readLocalData("save_p") or 0
    t=readLocalData("save_t") or 0
    --Bewegungen
    px=100
    py=HEIGHT-100
    --Kiste
    chestClosed=true
    --Schalter
    parameter.boolean("HACKING")
    --Uhr
    t = 0
    --Spielzeit wird beim Drücken angezeigt
    parameter.action("Wie lange spiele ich schon?", function() print("Time: "..math.ceil(t)) end)
    --ClearOutput
    parameter.action("Clear Output", function() output.clear() print("Sucsess!") end )
end


function draw()

    --Hintergrund wird gezeichnet
    sprite("SpaceCute:Background",512,384,1024,768)

    --Punkte werden hir angezeigt
    text(math.tointeger(x),500, 150)
    text(math.tointeger(p),500, 600)

    --Kiste und spieler werden Gemalt
    if chestClosed then chest=sprite("Planet Cute:Chest Closed", WIDTH/2, HEIGHT/2) end
    player=sprite("Planet Cute:Character Boy", px, py)
    showKeyboard()

    --Schalter einstellungen
     if HACKING == false then    
    else
        x=x+1
    end

    --Clock
    t = t + DeltaTime

    --Zeit wird gespeichert (funktioniert noch nicht...)
    saveLocalData=("save_t"), t
end

function touched(touch)
    --Berührungen werden wahrgenommen
    if touch.state==BEGAN then
        x=x+1
        end
    end


function keyboard(key)
    --Tastatur reagiert auf Tasten
    if (key == "w" or key == "W") then
        py = py + 40 
    end
    if (key == "a" or key == "A") then
        px = px - 40 
    end
    if (key == "s" or key == "S") then
        py = py - 40 
    end
    if (key == "d" or key == "D") then
        px = px + 40 
    end
    if (key == "x" or key == "X") then
        if touchingChest() then
            chestClosed=true
            sound(SOUND_PICKUP, 24870)
            p=p+x
            x=x-x
            end
        end
    end
--Position der Kiste wird angegeben
function touchingChest()
    if (px < WIDTH/2+50 and
        px > WIDTH/2-50 and
        py < HEIGHT/2+85 and
        py > HEIGHT/2-85) then return true
    else
        return false
    end
end

Comments

Sign In or Register to comment.