J'ai depuis peu un problème assez bizarre : sur JSE, quand je vais sur l'"execution page", le programme me dit "Switch to this page when your script is ready", problème que je n'avais pas avant sur le même fichier. Encore plus étrange est le fait que quand je supprime une centaine de ligne de code aléatoirement, il se remet à fonctionner
Pour essayer, j'ai mis mon code sur TIDE, et là, même problème excepté qu'il ne m'affiche tout simplement rien.
J'ai essayer aussi sur Student Software, et là, en revanche, cela fonctionne bien, mais ça m'embête, sachant que j'ai acheté la TI-Nspire principalement pour avoir une plateforme où je peux coder portative.
Pour informations : J'ai environ 80 Mo de libre sur ma Nspire, JSE fonctionne avec tout autres programmes, dont certains ont plus de lignes de codes que ce dernier, ma version d'O.S. est 4.2.0.532, et j'ai Ndless d'installé (je ne pense pas que ce soit une cause, mais on sait jamais . . .)
Aussi, voilà mon code :
- Code: Tout sélectionner
-- les temps sont separe de pww/3 pixel, soit pww/12 entre les quarts de temps
pww = platform.window:width()
pwh = platform.window:height()
function gsw(gc,s) return gc:getStringWidth(s) end
function gsh(gc,s) return gc:getStringHeight(s) end
function arr(nb, mod)
if mod == 0 then
return math.floor(nb+0.125)
elseif mod == 1 then
return math.floor((nb+0.125)*4%4)+1
end
end
selecC = {0, 0, 0, 200}
screen = 0
selec = 0
spe = 0
dif = 4
lon = 4
bpm = 60
input = ""
affhs = false
lon_score = 1
print(var.recall("biffle"))
var.store("highScore","s")
if var.recall("highScore") == "s" then
highScore = {}
hsName = {}
print(true)
for i=1, 10 do
local col = {}
local col2 = {}
for j=1, 5 do
table.insert(col, 0)
table.insert(col2, "-----")
end
table.insert(highScore, col)
table.insert(hsName, col2)
end
var.store("highScore",highScore)
var.store("hsName",hsName)
end
--print(var.recall("highScore")[1][1])
text = {
{"Raté", {255,0,0}},
{"Pas mal", {255,125,0}},
{"Bien", {125,255,0}},
{"Excellent!", {0,255,0}}
}
song_preset = {"tetris", "lune", "berczelda", "joie"}
title_preset = {"\"Tetris\"", "\"Au clair de la lune\"", "\"Berceuse de Zelda\"", "\"Ode à la joie\""}
carac_preset = {}
part_preset = {
{{"e","","",""},{"b","","c",""},{"d","","",""},{"c","","b",""},{"a","","",""},{"a","","c",""},{"e","","",""},{"d","","c",""},{"b","","",""},{"","","c",""},{"d","","",""},{"e","","",""},{"c","","",""},{"a","","",""},{"a","","",""},}
}
function Partition(ind, chance)
if math.random() < chance then
table.insert(partition[ind], string.char(97+math.floor(math.random()*7)))
return Partition(ind, chance-0.30)
end
end
function Initialisation()
score = 0
life = 5
if spe > 0 then
partition = preset[spe]
bpm = carac_preset[spe][1]
dif = carac_preset[spe][2]
for k, v in ipairs(partition) do
for ka, va in ipairs(v) do
if va == "" then
partition[k][ka] = false
end
end
end
else
partition = {}
for i=1, 60*lon do
table.insert(partition, {})
Partition(i, 0.75+0.025*dif)
if #partition[i] == 0 or #partition[i] == 1 or #partition[i] == 3 then
for j=1, 4-#partition[i] do
table.insert(partition[i], false)
end
elseif #partition[i] == 2 then
table.insert(partition[i], 2, false)
table.insert(partition[i], false)
end
end
end
for i=1, 4 do
table.insert(partition, 1, {false,false,false,false})
table.insert(partition, {false,false,false,false})
end
screen = 1
state = 1
refresh = 0.05
timer.start(refresh)
end
function on.timer()
state = state+refresh*bpm/60
if state > 3 and state < 60*lon+11 then
score = score+refresh*(bpm/60)^1.2
end
if state >= 5 and state < 60*lon+12 then
if partition[arr(state-4,0)][arr(state-4,1)] then
life = life - 1
partition[arr(state-4,0)][arr(state-4,1)] = false
end
end
if state > 60*lon+12 or life == 0 then
screen = 2
timer.stop()
score = math.floor(score)
for i=1, 5 do
print(var.recall("highScore"))
print(var.recall("highScore")[lon])
print(var.recall("highScore")[lon][i])
if score > var.recall("highScore")[lon][i] then
local hsnew = var.recall("highScore")
local namenew = var.recall("hsName")
table.insert(hsnew[lon], i, score)
table.remove(hsnew[lon])
table.insert(namenew[lon], i, "")
table.remove(namenew[lon])
var.store("highScore", hsnew)
var.store("hsName", namenew)
affhs = {true, i}
break
end
end
end
platform.window:invalidate()
end
function on.paint(gc)
if screen == 0 then
gc:setFont("serif", "b", 24)
gc:setColorRGB(150,0,0)
gc:drawString("Temp-it!", (pww-gsw(gc,"Temp-it!"))/2, 5, "top")
gc:setFont("serif", "b", 12)
gc:setColorRGB(0,0,selecC[(selec+3)%4+1])
gc:drawString("Difficulté :", pww/2-gsw(gc,"Difficulté :"), pwh/2-gsh(gc,"Difficulté"), "baseline")
gc:drawString(" < "..tostring(dif).." >", pww/2, pwh/2-gsh(gc," < "..tostring(dif).." >"), "baseline")
gc:setColorRGB(0,0,selecC[(selec+2)%4+1])
gc:drawString("Durée :", pww/2-gsw(gc,"Durée :"), pwh/2, "baseline")
gc:drawString(" < "..tostring(lon).." >", pww/2, pwh/2, "baseline")
gc:setColorRGB(0,0,selecC[(selec+1)%4+1])
gc:drawString("Tempo :", pww/2-gsw(gc,"Tempo :"), pwh/2+gsh(gc,"Difficulté"), "baseline")
gc:drawString(" < "..tostring(bpm).." >", pww/2, pwh/2+gsh(gc," < "..tostring(bpm).." >"), "baseline")
gc:setColorRGB(0,0,selecC[(selec)%4+1])
gc:drawString("Jouer", (pww-gsw(gc,"Jouer"))/2, pwh/2+gsh(gc,"Jouer")*2, "baseline")
gc:setFont("serif", "r", 8)
gc:setColorRGB(0,0,0)
gc:drawString(">"..input, 1, pwh-1, "bottom")
elseif screen == 1 then
gc:setFont("serif", "i", 12)
gc:setColorRGB(0,0,0)
gc:drawString("Score : "..math.floor(score), 5, 5, "top")
gc:setPen()
gc:setFont("serif", "r", 10)
-- gc:setColorRGB(200,200,200)
-- gc:fillRect(0, pwh/2-gsh(gc,"A"), pww, gsh(gc,"A")*2)
gc:setColorRGB(235,235,235)
gc:fillRect(0, pwh/2-gsh(gc,"A")-2, pww, gsh(gc,"A")*2-2)
for i=math.floor(-4+state), math.floor(0+state) do
if i >= 1 and i <= 60*lon+8 then
for k, v in ipairs(partition[i]) do
if k == 1 then
gc:setColorRGB(150,150,150)
else
gc:setColorRGB(215,215,215)
end
gc:drawLine(pww*7/6-pww/3*(state-i)+pww/12*(k-1), pwh/2-gsh(gc,"A")-2, pww*7/6-pww/3*(state-i)+pww/12*(k-1), pwh/2+gsh(gc,"A")-4)
gc:setColorRGB(0,0,0)
if v then
gc:drawString(string.upper(v), pww*7/6-pww/3*(state-i)+pww/12*(k-1)-gsw(gc,"A")/2, pwh/2, "baseline")
end
end
end
end
gc:setPen("medium")
-- gc:setColorRGB(150,150,150)
-- gc:drawLine(0, pwh/2-gsh(gc,"A")-2 , pww, pwh/2-gsh(gc,"A")-2)
-- gc:drawLine(0, pwh/2+gsh(gc,"A")-2 , pww, pwh/2+gsh(gc,"A")-2)
gc:setColorRGB(200,200,200)
gc:drawLine(0, pwh/2-gsh(gc,"A")-4 , pww, pwh/2-gsh(gc,"A")-4)
gc:drawLine(0, pwh/2+gsh(gc,"A")-4 , pww, pwh/2+gsh(gc,"A")-4)
-- gc:setColorRGB(125,125,125)
-- gc:drawArc(pww/2-gsh(gc,"A")-1, pwh/2-gsh(gc,"A")-4, gsh(gc,"A")*2+1, gsh(gc,"A")*2, 0, 360)
-- gc:fillPolygon({pww/2, pwh/2-gsh(gc,"A")-6, pww/2-gsh(gc,"A")/4, pwh/2-gsh(gc,"A")*1.5-6, pww/2+gsh(gc,"A")/4, pwh/2-gsh(gc,"A")*1.5-6})
-- gc:fillPolygon({pww/2, pwh/2+gsh(gc,"A")-4, pww/2-gsh(gc,"A")/4, pwh/2+gsh(gc,"A")*1.5-4, pww/2+gsh(gc,"A")/4, pwh/2+gsh(gc,"A")*1.5-4})
gc:setColorRGB(175,175,175)
gc:drawArc(pww/2-gsh(gc,"A")-1, pwh/2-gsh(gc,"A")-6, gsh(gc,"A")*2+1, gsh(gc,"A")*2, 0, 360)
gc:fillPolygon({pww/2, pwh/2-gsh(gc,"A")-8, pww/2-gsh(gc,"A")/4, pwh/2-gsh(gc,"A")*1.5-8, pww/2+gsh(gc,"A")/4, pwh/2-gsh(gc,"A")*1.5-8})
gc:fillPolygon({pww/2, pwh/2+gsh(gc,"A")-6, pww/2-gsh(gc,"A")/4, pwh/2+gsh(gc,"A")*1.5-6, pww/2+gsh(gc,"A")/4, pwh/2+gsh(gc,"A")*1.5-6})
local affLife = ": Vie"
for i=1, life do
affLife = " • "..affLife
end
gc:drawString(affLife, pww-gsw(gc,affLife), 1, "top")
elseif screen == 2 then
gc:setFont("serif", "b", 23)
gc:setColorRGB(0,0,0)
gc:drawString("Partie terminée", pww/2-gsw(gc,"Partie terminée")/2, pwh/2-gsh(gc,"Partie terminée")*1.5, "middle")
gc:drawString("Score : "..score, pww/2-gsw(gc,"Score : "..score)/2, pwh/2-gsh(gc,"Score : "..score)/2, "middle")
if affhs[1] then
gc:drawString("Nouveau High Score", pww/2-gsw(gc,"Nouveau High Score")/2, pwh/2+gsh(gc,"Nouveau High Score")/2, "middle")
end
elseif screen == 3 then
gc:setFont("serif", "i", 13)
gc:setColorRGB(150,150,150)
gc:drawString("Score pour durée : "..lon_score,(pww-gsw(gc, "Score pour durée : "..lon_score))/2, 1, "top")
gc:setColorRGB(200,200,200)
for i=1, 5 do
gc:drawString(var.recall("hsName")[lon_score][i], pww/2-gsw(gc,var.recall("hsName")[lon_score][i])-1, pwh*(i+2)/8, "top")
gc:drawString(var.recall("highScore")[lon_score][i], pww/2+1, pwh*(i+2)/8, "top")
end
end
end
function readCode()
for k, v in ipairs(song_preset) do
if input == v then
screen = -1
return
end
end
Initialisation()
end
function on.charIn(char)
if screen == 1 and state > 3 and state < 60*lon + 10 then
if partition[arr(state-2, 0)][arr(state-2, 1)] == char then
score = score+(dif/4+1)*10
else
life = life - 1
end
partition[arr(state-2, 0)][arr(state-2, 1)] = false
elseif screen == 0 then
if char == "8" then
selec = (selec-1)%4
elseif char == "2" then
selec = (selec+1)%4
elseif char == "6" then
if selec == 0 then
dif = (dif+1)%11
elseif selec == 1 then
lon = (lon+1)%11
elseif selec == 2 then
bpm = math.min(bpm+10, 90)
end
elseif char == "4" then
if selec == 0 then
dif = (dif-1)%11
elseif selec == 1 then
lon = (lon-2)%10+1
elseif selec == 2 then
bpm = math.max(bpm-10, 30)
end
elseif char == "5" and selec == 3 then
readCode()
elseif not(type(char)=="number") then
input = input..char
end
elseif screen == -1 and char == "5" then
Initialisation()
elseif screen == 2 and char == "5" then
if affhs[1] then
screen = 3
else
screen = 0
end
elseif screen == 3 and #name < 6 and affhs[1] then
name = name..char
end
platform.window:invalidate()
end
function on.enterKey()
if screen == 0 and selec == 3 then
readCode()
elseif screen == -1 then
Initialisation()
elseif screen == 2 then
screen = 3
elseif screen == 3 then
--
if affhs[1] then
affhs[1] = false
local nameReg = var.recall("hsName")
nameReg[lon][affhs[2]] = name
var.store("hsName", nameReg)
else
screen = 0
end
--
end
platform.window:invalidate()
end
function on.backspaceKey()
if screen == 0 then
input = string.sub(input, 1, -2)
elseif screen == 3 and affhs then
name = string.sub(name, 1, -2)
end
platform.window:invalidate()
end
Merci d'avance à toutes les personnes qui m'aide .