π
<-

Pause pdt l'execution d'un prgm

Pour TI-Nspire OS 3.0 ou ultérieur.

Re: Pause pdt l'execution d'un prgm

Unread postby Creative Basic » 19 Jan 2013, 15:28

oki, je te post la version "allégée", j'inclus pas non plus les images par gain d'espace. Le code ne fonctionne pas à 100 % il me manque la gestion du score et de deux ou trois trucs...
Code: Select all
xmin = 0
ymin = 100
xmax = 275
ymax = 100
rep =  1
score = 0
temps = 0.1
vie = 9
pwr = 9
att1 = 0
att2 = 0
chrono = 1
chrono1 = 1
chrono2 = 1
chrono3 = 1
chrono4 = 0
scorea = ""
scorec = 0
scoreb = 1
menu = 1
joueur = 3
sol = math.random(1,4)
Forme = class()

-- Constructeur
function Forme:init(x, y, image)
    self.xpos = x
    self.ypos = y
    self.pic = image
end

-- Dessiner la forme
function Forme:paint(gc)
    gc:drawImage(self.pic, self.xpos, self.ypos)
end

-- Repositionner l'objet en indiquant les nouvelles coordonnees
function Forme:setxy(newx, newy)
    if newx > xmin and newx < xmax and newy > ymin and newy < ymax then
        self.xpos = newx
        self.ypos = newy
   end
end

-- Repositionner l'objet en indiquant le deplacement a effectuer
function Forme:move(dx, dy)
    local newx,newy
    self:setxy(self.xpos + dx,self.ypos + dy)
end

-- ici defintion de toutes les images du jeu - j'ai sauté exprès

forme1 = Forme (0, 0, fond0)
forme2 = Forme (xmin, ymin, ima1)
forme4 = Forme (xmax, ymax, ima11)
forme7 = Forme (25, 203, ico01)
forme8 = Forme (32, 192, ico10)
forme9 = Forme (0,182, ico20)
forme10 = Forme(280,182, ico32)
forme19 = Forme(60,180, rcd)
forme20 = Forme(0, 0, accueil)
forme21 = Forme(140,100, ico21)
forme22 = Forme(140,100, ico22)
forme23 = Forme(190,100, ico23)
forme24 = Forme(190,100, ico24)
forme25 = Forme(90,100, ico25)
forme26 = Forme(90,100, ico26)
forme27 = Forme(240,100, ico27)
forme28 = Forme(240,100, ico28)
forme29 = Forme(40,100, ico29)
forme30 = Forme(40,100, ico30)
forme31 = Forme(90,185, pts)
forme32 = Forme(12, 120, ico34)
forme33 = Forme(290, 120, ico33)

-- forme1 : fond 2: perso 4: adverse 7: attkperso 8 attak adv 9 10 icone

function perdu()
score = 0
chrono = 1
chrono1 = 1
chrono2 = 1
chrono3 = 1
vie = 9
pwr = 9
platform.window:invalidate()
end

function on.save()
  return record
end
function on.restore(data)
  if type(data) == "number" then
    record = data
  end
end
function on.create()
if not record then
    record = 0
  end
end

function move()

if rep == 1 and xmin == 100 then forme2 = Forme (xmin, ymin, ima2) end
if rep == 1 and xmin == 0 then forme2 = Forme (xmin, ymin, ima1) end

if rep == 2 then forme2 = Forme (xmin, ymin, ima2) end
if rep == 2 and xmin == 0 then forme2 = Forme (xmin, ymin, ima1) end

if rep == 3 then forme2 = Forme (xmin, ymin, ima2) end
if rep == 3 and xmin == 0 then forme2 = Forme (xmin, ymin, ima1) end

if rep == 4 then forme2 = Forme (xmin, ymin, ima2) end
if rep == 4 and xmin == 0 then forme2 = Forme (xmin, ymin, ima1) end

if sol == 1 then
if score < 1500 then forme4 = Forme (xmax, ymax, ima11) end
if score > 1500 and score < 4000 then forme4 = Forme (xmax, ymax, ima16) end
if score > 4000 then forme4 = Forme (xmax, ymax, ima21) end
end

if sol == 2 or sol == 3 or sol == 4 then
if xmax == 175 and ymax == 100 then
a = math.random(1,2)
if a == 1 then xmax = 275 end
if a == 2 then ymax = 0 end
b = math.random(1,4)
if b == 1 then att2 = 1 end
if b == 2 then att2 = 2 end
if b == 3 or b == 4 then att2 = 0 end
end

if xmax == 175 and ymax == 0 then
a = math.random(1,2)
if a == 1 then xmax = 275 end
if a == 2 then ymax = 100 end
b = math.random(1,4)
if b == 1 then att2 = 1 end
if b == 2 then att2 = 2 end
if b == 3 or b == 4 then att2 = 0 end
end

if xmax == 275 and ymax == 100 then
a = math.random(1,2)
if a == 1 then xmax = 175 end
if a == 2 then ymax = 0 end
end

if xmax == 275 and ymax == 0 then
a = math.random(1,2)
if a == 1 then xmax = 175 end
if a == 2 then ymax = 100 end
end

if score < 1500 then forme4 = Forme (xmax, ymax, ima12) end
if score > 1500 and score < 4000 then forme4 = Forme (xmax, ymax, ima17) end
if score > 4000 then forme4 = Forme (xmax, ymax, ima22) end
end
if att2 == 6 then
if score < 1500 then forme4 = Forme (xmax, ymax, ima13b) end
if score > 1500 and score < 4000 then forme4 = Forme (xmax, ymax, ima18b) end
if score > 4000 then forme4 = Forme (xmax, ymax, ima24b) end
forme6 = Forme (xmin + 30, ymin, eff2)
end
if att2 == 7 then
if score < 1500 then forme4 = Forme (xmax, ymax, ima14) end
if score > 1500 and score < 4000 then forme4 = Forme (xmax, ymax, ima19) end
if score > 4000 then forme4 = Forme (xmax, ymax, ima24) end
forme6 = Forme (xmin, ymin - 5, eff3)
if xmax == 275 then forme5 = Forme (-15, ymax, ima10) end
if xmax == 175 then forme5 = Forme (-115, ymax, ima10) end
end
if att2 == 1  then
if score < 1500 then forme4 = Forme (xmax, ymax, ima13) end
if score > 1500 and score < 4000 then forme4 = Forme (xmax, ymax, ima18) end
if score > 4000 then forme4 = Forme (xmax, ymax, ima23) end
att2 = att2 + 5
end
if att2 == 2  then
if score < 1500 then forme4 = Forme (xmax, ymax, ima14b) end
if score > 1500 and score < 4000 then forme4 = Forme (xmax, ymax, ima19b) end
if score > 4000 then forme4 = Forme (xmax, ymax, ima24b) end
att2 = att2 + 5
end
platform.window:invalidate()
end


function on.timer()
sol = math.random(1,4)
move()
life()
end

function life()
if vie == 9 then forme7 = Forme (25, 203, ico01) end
if vie == 8 then forme7 = Forme (25, 203, ico02) end
if vie == 7 then forme7 = Forme (25, 203, ico03) end
if vie == 6 then forme7 = Forme (25, 203, ico04) end
if vie == 5 then forme7 = Forme (25, 203, ico05) end
if vie == 4 then forme7 = Forme (25, 203, ico06) end
if vie == 3 then forme7 = Forme (25, 203, ico07) end
if vie == 2 then forme7 = Forme (25, 203, ico08) end
if vie == 1 then forme7 = Forme (25, 203, ico09) end

if pwr == 9 then forme8 = Forme (32, 192, ico10) end
if pwr == 8 then forme8 = Forme (32, 192, ico11) end
if pwr == 7 then forme8 = Forme (32, 192, ico12) end
if pwr == 6 then forme8 = Forme (32, 192, ico13) end
if pwr == 5 then forme8 = Forme (32, 192, ico14) end
if pwr == 4 then forme8 = Forme (32, 192, ico15) end
if pwr == 3 then forme8 = Forme (32, 192, ico16) end
if pwr == 2 then forme8 = Forme (32, 192, ico17) end
if pwr == 1 then forme8 = Forme (32, 192, ico18) end
platform.window:invalidate()
end

function on.paint(gc)
if menu == 1 then
forme20:paint(gc)
forme22:paint(gc)
forme19:paint(gc)
forme24:paint(gc)
forme26:paint(gc)
forme28:paint(gc)
forme30:paint(gc)
forme32:paint(gc)
forme33:paint(gc)
if joueur == 1 then forme29:paint(gc) end
if joueur == 2 then forme25:paint(gc) end
if joueur == 3 then forme21:paint(gc) end
if joueur == 4 then forme23:paint(gc) end
if joueur == 5 then forme27:paint(gc) end
platform.window:invalidate()
end
if menu == 0 then
if chrono == 0 then
forme1:paint(gc)
forme7:paint(gc)
forme8:paint(gc)
if att1 == 2 then forme2 = Forme (xmin, ymin, ima4) end
if att1 == 1 then forme2 = Forme (xmin, ymin, ima3) end
forme2:paint(gc)
forme4:paint(gc)
forme9:paint(gc)
forme31:paint(gc)
gc:setColorRGB(0, 0, 255)
    gc:setFont("sansserif" , "b", 11)
   gc:drawString("" .. score.."", 105,207)
platform.window:invalidate()
end
if chrono4 == 1 and chrono == 1 then forme11:paint(gc)end
if score < 1500 then forme10 = Forme (280, 182, ico32) end
if score >= 1500 and score < 4000 and chrono == 0 and chrono2 == 1 then
chrono = 1
forme10 = Forme (280, 182, ico31) end
if score >= 4000  and chrono == 0 and chrono3 == 1 then
chrono = 1
forme10 = Forme (280, 182, ico41)
end
if chrono == 0 then forme10:paint(gc) end
if score >= 4000 and chrono3 == 1 and chrono == 1 then
forme6 = Forme (0,0, intro3)
forme6:paint(gc)
end
if score >= 1500 and score < 4000 and chrono2 ==1 and chrono == 1 then
forme6 = Forme (0,0, intro2)
forme6:paint(gc)
end
if score >= 0 and score < 1500 and chrono1 == 1 and chrono == 1 then
forme6 = Forme (0,0, intro1)
forme6:paint(gc)
end
if chrono == 0 and att1 == 1 then
forme4 = Forme (xmax, ymax, ima15)
if xmin == 100 and xmax == 175 and ymin == ymax then
pwr = pwr + 1
if pwr > 10 then
pwr = 10 end
forme6 = Forme (xmax - 30, ymax, eff1)
score = score + 100
forme4:paint(gc)
forme6:paint(gc)
xmin = 0
xmax = 275
end
att1 = 0
att2 = 0
end
if chrono == 0 and att1 == 2 then
forme6 = Forme (xmax, ymax - 5, eff3)
forme3 = Forme (xmin + 30, ymin, ima0)
if xmin == 100 and xmax == 175 and ymin == ymax then score = score + 250
forme6:paint(gc)
xmin = 0
xmax = 275
end
forme3:paint(gc)
att1 = 0
att2 = 0
end
if chrono == 0 and att2 == 7 and xmin == 100 and xmax == 175 and ymin == ymax then
vie = vie - 1
if vie == 0 then perdu() end
if score < 1500 then forme4 = Forme (xmax, ymax, ima13b) end
if score > 1500 and score < 4000 then forme4 = Forme (xmax, ymax, ima18b) end
if score > 4000 then forme4 = Forme (xmax, ymax, ima24b) end
forme6 = Forme (xmin + 30, ymin, eff2)
forme6:paint(gc)
forme4:paint(gc)
att2 = 0
end
if chrono == 0 and att2 == 6 and xmin == 100 and xmax == 175 and ymin == ymax then
vie = vie - 1
if vie == 0 then perdu() end
forme6:paint(gc)
forme4:paint(gc)
att2 = 0
end
if chrono== 0 and att2 == 7 and xmin == 100 and xmax == 175 and ymin == ymax then
vie = vie - 1
if vie == 0 then perdu() end
forme6:paint(gc)
forme5:paint(gc)
forme4:paint(gc)
att2 = 0
end
if chrono == 0 and att2 == 6 or att2 == 7 then att2 = 0 end
if menu == 1 then
gc:setColorRGB(200, 50, 50)
    gc:setFont("sansserif" , "b", 11)
gc:drawString("" .. record.."", 160,203)   
end
end
timer.start(temps)
platform.window:invalidate()
end

function on.arrowRight()
if chrono == 0 and menu == 0 then
rep = 1
if xmin == 100 then att1 = 1 end
xmin = xmin + 100
if xmin > 100 then xmin = 100 end
sol = math.random(1,4)
move()
end
if menu == 1 then
joueur = joueur + 1
if joueur >= 6 then joueur = 1 end
end
platform.window:invalidate()
end


function on.arrowLeft()
if chrono == 0 and menu == 0 then
rep = 2
xmin = xmin - 100
if xmin <= 0 then xmin = 0 end
sol = math.random(1,4)
move()
end
if menu == 1 then
joueur = joueur - 1
if joueur <= 0 then joueur = 5 end
end
platform.window:invalidate()
end

function on.arrowUp()
if chrono == 0 and menu ==0 then
rep = 3
ymin = ymin - 100
if ymin <= 0 then ymin = 0 end
sol = math.random(1,4)
move()
end
platform.window:invalidate()
end

function on.arrowDown()
if chrono == 0 and menu ==0 then
rep = 4
ymin = ymin + 100
if ymin > 100 then ymin = 100 end
sol = math.random(1,4)
move()
end
platform.window:invalidate()
end

function on.enterKey()
if menu == 1 then
menu = 0
end
if chrono == 0 and menu == 0 then
pwr = pwr - 1
if pwr > 0 then att1 = 2 end
   sol = math.random(1,4)
   move()
end

if chrono4 == 1 and chrono == 1 then
chrono4 = 0
chrono = 0
att1 = 0
att2 = 0
xmin = 0
xmax = 275
end

if chrono1 == 1 and chrono == 1 then
chrono = 0
chrono1 = 0
end

if chrono2 == 1 and chrono == 1 then
chrono2 =0
chrono = 0
forme4 = Forme (xmax, ymax, ima16)
end
if chrono3 == 1 and chrono == 1 then
chrono = 0
chrono3 = 0
forme4 = Forme (xmax, ymax, ima21)
end
platform.window:invalidate()
end

function on.tabKey()
if pwr > 5 then
pwr = pwr - 5
vie = vie + 1
end
platform.window:invalidate()
end


et voilà
User avatar
Creative Basic
Niveau 8: ER (Espèce Rare: nerd)
Niveau 8: ER (Espèce Rare: nerd)
Level up: 57%
 
Posts: 93
Joined: 24 Jul 2011, 12:51
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Pause pdt l'execution d'un prgm

Unread postby Levak » 19 Jan 2013, 19:02

Indentation ... C'est illisible là ._.
Responsable design/graphique de TI-Planet
I do not get mad at people, I just want them to learn the way I learnt.
ImageTNOC [topic][DL]
nClock [topic][DL]
HideManager [topic][DL]
ZLock [topic][DL]
Theme Editor [topic][DL]
Mes programmes
User avatar
LevakAdmin
Niveau 14: CI (Calculateur de l'Infini)
Niveau 14: CI (Calculateur de l'Infini)
Level up: 98.9%
 
Posts: 6414
Images: 22
Joined: 27 Nov 2008, 00:00
Location: 0x1AACC355
Gender: Male
Calculator(s):
MyCalcs profile
Class: BAC+5: Epita (ING3)

Re: Pause pdt l'execution d'un prgm

Unread postby Adriweb » 19 Jan 2013, 19:04

Voici une version améliorée (uniquement au niveau de l'indentation) :

Code: Select all
xmin = 0
ymin = 100
xmax = 275
ymax = 100
rep = 1
score = 0
temps = 0.1
vie = 9
pwr = 9
att1 = 0
att2 = 0
chrono = 1
chrono1 = 1
chrono2 = 1
chrono3 = 1
chrono4 = 0
scorea = ""
scorec = 0
scoreb = 1
menu = 1
joueur = 3
sol = math.random(1, 4)
Forme = class()

-- Constructeur
function Forme:init(x, y, image)
    self.xpos = x
    self.ypos = y
    self.pic = image
end

-- Dessiner la forme
function Forme:paint(gc)
    gc:drawImage(self.pic, self.xpos, self.ypos)
end

-- Repositionner l'objet en indiquant les nouvelles coordonnees
function Forme:setxy(newx, newy)
    if newx > xmin and newx < xmax and newy > ymin and newy < ymax then
        self.xpos = newx
        self.ypos = newy
    end
end

-- Repositionner l'objet en indiquant le deplacement a effectuer
function Forme:move(dx, dy)
    local newx, newy
    self:setxy(self.xpos + dx, self.ypos + dy)
end

-- ici defintion de toutes les images du jeu - j'ai sauté exprès

forme1 = Forme(0, 0, fond0)
forme2 = Forme(xmin, ymin, ima1)
forme4 = Forme(xmax, ymax, ima11)
forme7 = Forme(25, 203, ico01)
forme8 = Forme(32, 192, ico10)
forme9 = Forme(0, 182, ico20)
forme10 = Forme(280, 182, ico32)
forme19 = Forme(60, 180, rcd)
forme20 = Forme(0, 0, accueil)
forme21 = Forme(140, 100, ico21)
forme22 = Forme(140, 100, ico22)
forme23 = Forme(190, 100, ico23)
forme24 = Forme(190, 100, ico24)
forme25 = Forme(90, 100, ico25)
forme26 = Forme(90, 100, ico26)
forme27 = Forme(240, 100, ico27)
forme28 = Forme(240, 100, ico28)
forme29 = Forme(40, 100, ico29)
forme30 = Forme(40, 100, ico30)
forme31 = Forme(90, 185, pts)
forme32 = Forme(12, 120, ico34)
forme33 = Forme(290, 120, ico33)

-- forme1 : fond 2: perso 4: adverse 7: attkperso 8 attak adv 9 10 icone

function perdu()
    score = 0
    chrono = 1
    chrono1 = 1
    chrono2 = 1
    chrono3 = 1
    vie = 9
    pwr = 9
    platform.window:invalidate()
end

function on.save()
    return record
end

function on.restore(data)
    if type(data) == "number" then
        record = data
    end
end

function on.create()
    if not record then
        record = 0
    end
end

function move()

    if rep == 1 and xmin == 100 then forme2 = Forme(xmin, ymin, ima2) end
    if rep == 1 and xmin == 0 then forme2 = Forme(xmin, ymin, ima1) end

    if rep == 2 then forme2 = Forme(xmin, ymin, ima2) end
    if rep == 2 and xmin == 0 then forme2 = Forme(xmin, ymin, ima1) end

    if rep == 3 then forme2 = Forme(xmin, ymin, ima2) end
    if rep == 3 and xmin == 0 then forme2 = Forme(xmin, ymin, ima1) end

    if rep == 4 then forme2 = Forme(xmin, ymin, ima2) end
    if rep == 4 and xmin == 0 then forme2 = Forme(xmin, ymin, ima1) end

    if sol == 1 then
        if score < 1500 then forme4 = Forme(xmax, ymax, ima11) end
        if score > 1500 and score < 4000 then forme4 = Forme(xmax, ymax, ima16) end
        if score > 4000 then forme4 = Forme(xmax, ymax, ima21) end
    end

    if sol == 2 or sol == 3 or sol == 4 then
        if xmax == 175 and ymax == 100 then
            a = math.random(1, 2)
            if a == 1 then xmax = 275 end
            if a == 2 then ymax = 0 end
            b = math.random(1, 4)
            if b == 1 then att2 = 1 end
            if b == 2 then att2 = 2 end
            if b == 3 or b == 4 then att2 = 0 end
        end

        if xmax == 175 and ymax == 0 then
            a = math.random(1, 2)
            if a == 1 then xmax = 275 end
            if a == 2 then ymax = 100 end
            b = math.random(1, 4)
            if b == 1 then att2 = 1 end
            if b == 2 then att2 = 2 end
            if b == 3 or b == 4 then att2 = 0 end
        end

        if xmax == 275 and ymax == 100 then
            a = math.random(1, 2)
            if a == 1 then xmax = 175 end
            if a == 2 then ymax = 0 end
        end

        if xmax == 275 and ymax == 0 then
            a = math.random(1, 2)
            if a == 1 then xmax = 175 end
            if a == 2 then ymax = 100 end
        end

        if score < 1500 then forme4 = Forme(xmax, ymax, ima12) end
        if score > 1500 and score < 4000 then forme4 = Forme(xmax, ymax, ima17) end
        if score > 4000 then forme4 = Forme(xmax, ymax, ima22) end
    end
    if att2 == 6 then
        if score < 1500 then forme4 = Forme(xmax, ymax, ima13b) end
        if score > 1500 and score < 4000 then forme4 = Forme(xmax, ymax, ima18b) end
        if score > 4000 then forme4 = Forme(xmax, ymax, ima24b) end
        forme6 = Forme(xmin + 30, ymin, eff2)
    end
    if att2 == 7 then
        if score < 1500 then forme4 = Forme(xmax, ymax, ima14) end
        if score > 1500 and score < 4000 then forme4 = Forme(xmax, ymax, ima19) end
        if score > 4000 then forme4 = Forme(xmax, ymax, ima24) end
        forme6 = Forme(xmin, ymin - 5, eff3)
        if xmax == 275 then forme5 = Forme(-15, ymax, ima10) end
        if xmax == 175 then forme5 = Forme(-115, ymax, ima10) end
    end
    if att2 == 1 then
        if score < 1500 then forme4 = Forme(xmax, ymax, ima13) end
        if score > 1500 and score < 4000 then forme4 = Forme(xmax, ymax, ima18) end
        if score > 4000 then forme4 = Forme(xmax, ymax, ima23) end
        att2 = att2 + 5
    end
    if att2 == 2 then
        if score < 1500 then forme4 = Forme(xmax, ymax, ima14b) end
        if score > 1500 and score < 4000 then forme4 = Forme(xmax, ymax, ima19b) end
        if score > 4000 then forme4 = Forme(xmax, ymax, ima24b) end
        att2 = att2 + 5
    end
    platform.window:invalidate()
end


function on.timer()
    sol = math.random(1, 4)
    move()
    life()
end

function life()
    if vie == 9 then forme7 = Forme(25, 203, ico01) end
    if vie == 8 then forme7 = Forme(25, 203, ico02) end
    if vie == 7 then forme7 = Forme(25, 203, ico03) end
    if vie == 6 then forme7 = Forme(25, 203, ico04) end
    if vie == 5 then forme7 = Forme(25, 203, ico05) end
    if vie == 4 then forme7 = Forme(25, 203, ico06) end
    if vie == 3 then forme7 = Forme(25, 203, ico07) end
    if vie == 2 then forme7 = Forme(25, 203, ico08) end
    if vie == 1 then forme7 = Forme(25, 203, ico09) end

    if pwr == 9 then forme8 = Forme(32, 192, ico10) end
    if pwr == 8 then forme8 = Forme(32, 192, ico11) end
    if pwr == 7 then forme8 = Forme(32, 192, ico12) end
    if pwr == 6 then forme8 = Forme(32, 192, ico13) end
    if pwr == 5 then forme8 = Forme(32, 192, ico14) end
    if pwr == 4 then forme8 = Forme(32, 192, ico15) end
    if pwr == 3 then forme8 = Forme(32, 192, ico16) end
    if pwr == 2 then forme8 = Forme(32, 192, ico17) end
    if pwr == 1 then forme8 = Forme(32, 192, ico18) end
    platform.window:invalidate()
end

function on.paint(gc)
    if menu == 1 then
        forme20:paint(gc)
        forme22:paint(gc)
        forme19:paint(gc)
        forme24:paint(gc)
        forme26:paint(gc)
        forme28:paint(gc)
        forme30:paint(gc)
        forme32:paint(gc)
        forme33:paint(gc)
        if joueur == 1 then forme29:paint(gc) end
        if joueur == 2 then forme25:paint(gc) end
        if joueur == 3 then forme21:paint(gc) end
        if joueur == 4 then forme23:paint(gc) end
        if joueur == 5 then forme27:paint(gc) end
        platform.window:invalidate()
    end
    if menu == 0 then
        if chrono == 0 then
            forme1:paint(gc)
            forme7:paint(gc)
            forme8:paint(gc)
            if att1 == 2 then forme2 = Forme(xmin, ymin, ima4) end
            if att1 == 1 then forme2 = Forme(xmin, ymin, ima3) end
            forme2:paint(gc)
            forme4:paint(gc)
            forme9:paint(gc)
            forme31:paint(gc)
            gc:setColorRGB(0, 0, 255)
            gc:setFont("sansserif", "b", 11)
            gc:drawString("" .. score .. "", 105, 207)
            platform.window:invalidate()
        end
        if chrono4 == 1 and chrono == 1 then forme11:paint(gc) end
        if score < 1500 then forme10 = Forme(280, 182, ico32) end
        if score >= 1500 and score < 4000 and chrono == 0 and chrono2 == 1 then
            chrono = 1
            forme10 = Forme(280, 182, ico31)
        end
        if score >= 4000 and chrono == 0 and chrono3 == 1 then
            chrono = 1
            forme10 = Forme(280, 182, ico41)
        end
        if chrono == 0 then forme10:paint(gc) end
        if score >= 4000 and chrono3 == 1 and chrono == 1 then
            forme6 = Forme(0, 0, intro3)
            forme6:paint(gc)
        end
        if score >= 1500 and score < 4000 and chrono2 == 1 and chrono == 1 then
            forme6 = Forme(0, 0, intro2)
            forme6:paint(gc)
        end
        if score >= 0 and score < 1500 and chrono1 == 1 and chrono == 1 then
            forme6 = Forme(0, 0, intro1)
            forme6:paint(gc)
        end
        if chrono == 0 and att1 == 1 then
            forme4 = Forme(xmax, ymax, ima15)
            if xmin == 100 and xmax == 175 and ymin == ymax then
                pwr = pwr + 1
                if pwr > 10 then
                    pwr = 10
                end
                forme6 = Forme(xmax - 30, ymax, eff1)
                score = score + 100
                forme4:paint(gc)
                forme6:paint(gc)
                xmin = 0
                xmax = 275
            end
            att1 = 0
            att2 = 0
        end
        if chrono == 0 and att1 == 2 then
            forme6 = Forme(xmax, ymax - 5, eff3)
            forme3 = Forme(xmin + 30, ymin, ima0)
            if xmin == 100 and xmax == 175 and ymin == ymax then score = score + 250
            forme6:paint(gc)
            xmin = 0
            xmax = 275
            end
            forme3:paint(gc)
            att1 = 0
            att2 = 0
        end
        if chrono == 0 and att2 == 7 and xmin == 100 and xmax == 175 and ymin == ymax then
            vie = vie - 1
            if vie == 0 then perdu() end
            if score < 1500 then forme4 = Forme(xmax, ymax, ima13b) end
            if score > 1500 and score < 4000 then forme4 = Forme(xmax, ymax, ima18b) end
            if score > 4000 then forme4 = Forme(xmax, ymax, ima24b) end
            forme6 = Forme(xmin + 30, ymin, eff2)
            forme6:paint(gc)
            forme4:paint(gc)
            att2 = 0
        end
        if chrono == 0 and att2 == 6 and xmin == 100 and xmax == 175 and ymin == ymax then
            vie = vie - 1
            if vie == 0 then perdu() end
            forme6:paint(gc)
            forme4:paint(gc)
            att2 = 0
        end
        if chrono == 0 and att2 == 7 and xmin == 100 and xmax == 175 and ymin == ymax then
            vie = vie - 1
            if vie == 0 then perdu() end
            forme6:paint(gc)
            forme5:paint(gc)
            forme4:paint(gc)
            att2 = 0
        end
        if chrono == 0 and att2 == 6 or att2 == 7 then att2 = 0 end
        if menu == 1 then
            gc:setColorRGB(200, 50, 50)
            gc:setFont("sansserif", "b", 11)
            gc:drawString("" .. record .. "", 160, 203)
        end
    end
    timer.start(temps)
    platform.window:invalidate()
end

function on.arrowRight()
    if chrono == 0 and menu == 0 then
        rep = 1
        if xmin == 100 then att1 = 1 end
        xmin = xmin + 100
        if xmin > 100 then xmin = 100 end
        sol = math.random(1, 4)
        move()
    end
    if menu == 1 then
        joueur = joueur + 1
        if joueur >= 6 then joueur = 1 end
    end
    platform.window:invalidate()
end


function on.arrowLeft()
    if chrono == 0 and menu == 0 then
        rep = 2
        xmin = xmin - 100
        if xmin <= 0 then xmin = 0 end
        sol = math.random(1, 4)
        move()
    end
    if menu == 1 then
        joueur = joueur - 1
        if joueur <= 0 then joueur = 5 end
    end
    platform.window:invalidate()
end

function on.arrowUp()
    if chrono == 0 and menu == 0 then
        rep = 3
        ymin = ymin - 100
        if ymin <= 0 then ymin = 0 end
        sol = math.random(1, 4)
        move()
    end
    platform.window:invalidate()
end

function on.arrowDown()
    if chrono == 0 and menu == 0 then
        rep = 4
        ymin = ymin + 100
        if ymin > 100 then ymin = 100 end
        sol = math.random(1, 4)
        move()
    end
    platform.window:invalidate()
end

function on.enterKey()
    if menu == 1 then
        menu = 0
    end
    if chrono == 0 and menu == 0 then
        pwr = pwr - 1
        if pwr > 0 then att1 = 2 end
        sol = math.random(1, 4)
        move()
    end

    if chrono4 == 1 and chrono == 1 then
        chrono4 = 0
        chrono = 0
        att1 = 0
        att2 = 0
        xmin = 0
        xmax = 275
    end

    if chrono1 == 1 and chrono == 1 then
        chrono = 0
        chrono1 = 0
    end

    if chrono2 == 1 and chrono == 1 then
        chrono2 = 0
        chrono = 0
        forme4 = Forme(xmax, ymax, ima16)
    end
    if chrono3 == 1 and chrono == 1 then
        chrono = 0
        chrono3 = 0
        forme4 = Forme(xmax, ymax, ima21)
    end
    platform.window:invalidate()
end

function on.tabKey()
    if pwr > 5 then
        pwr = pwr - 5
        vie = vie + 1
    end
    platform.window:invalidate()
end


Remarque générale, de loin :
- Tu n'utilises pas de Screen Manager, donc tu es réduis à utiliser plein de if xxx dans le on.paint et autres, c'est dommage.
- Heureusement encore que tu utilise un petit peu les classes, c'est déja ca :)

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
My calculator programs
Mes programmes pour calculatrices
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 82%
 
Posts: 14856
Images: 1211
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: adriweb
GitHub: adriweb

Re: Pause pdt l'execution d'un prgm

Unread postby Creative Basic » 19 Jan 2013, 19:20

Code: Select all
Tu n'utilises pas de Screen Manager, donc tu es réduis à utiliser plein de if xxx dans le on.paint et autres, c'est dommage.

ok, je vais potasser ça alors :
http://www.inspired-lua.org/2012/02/how-to-create-a-screen-manager/

et essayer de réecrire le code, parce que là ca donne rien de bien sympa
User avatar
Creative Basic
Niveau 8: ER (Espèce Rare: nerd)
Niveau 8: ER (Espèce Rare: nerd)
Level up: 57%
 
Posts: 93
Joined: 24 Jul 2011, 12:51
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Pause pdt l'execution d'un prgm

Unread postby Lionel Debroux » 20 Jan 2013, 10:41

Malheureusement, TINCS n'est pas un émulateur et l'implémentation de certains aspects dans TINCS est différente de l'implémentation dans l'OS calculatrice, donc on a parfois de mauvaises surprises, comme tu le vois actuellement :(
Membre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
User avatar
Lionel DebrouxSuper Modo
Niveau 14: CI (Calculateur de l'Infini)
Niveau 14: CI (Calculateur de l'Infini)
Level up: 11.4%
 
Posts: 6873
Joined: 23 Dec 2009, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Class: -
GitHub: debrouxl

Re: Pause pdt l'execution d'un prgm

Unread postby Adriweb » 20 Jan 2013, 11:47

Lionel Debroux wrote:Malheureusement, TINCS n'est pas un émulateur et l'implémentation de certains aspects dans TINCS est différente de l'implémentation dans l'OS calculatrice, donc on a parfois de mauvaises surprises, comme tu le vois actuellement :(

Voilà, je dirais que c'est de loin le plus gros point négatif. Autant ca peut être "bien" si l'on souhaite faire des choses sur grand écran pour pouvoir montrer des activités interactives à des élèves, par exemple, et dans ce cas il est utile de ne pas se restreindre, mais ils auraient peut-être du prévoir un switch permettant de tester à vitesse/performances "réduites"...

Sinon, pour le screen manager, regarde aussi des exemples du genre, je ne sais pas si tu as forcément besoin de gestion de "screen" à proprement parler (quoique..) mais c'est dans l'idée d'utiliser à fond les classes et leur possibilités :
https://github.com/adriweb/Doodle-Jump- ... umpLua.lua
https://github.com/adriweb/LuaTowerDefe ... efense.lua (plus complexe)

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
My calculator programs
Mes programmes pour calculatrices
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 82%
 
Posts: 14856
Images: 1211
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: adriweb
GitHub: adriweb

Re: Pause pdt l'execution d'un prgm

Unread postby Creative Basic » 15 Feb 2013, 22:02

Un petit passage pour vous soumettre un truc. J'ai repris plusieurs fois le prgm et j'en ai même commencé un autre et j'ai pu remarquer que on-calc pour gérer l'utilisation des touches et des déplacements dans en jeu lorsque j'utilisais les functions on.arrow... ca ne répondait pas du tout (ou de manière foireuse - ou c'est peut être moi qui code comme un boeuf). Par contre pour un même contenu, ça fonctionne nickel sur la nspire en utilisant :
Code: Select all
function on.charIn(ch)
   if ch=="8" then
      ...
   elseif ch=="4" then
      ...
   elseif ch=="6" then
      ...
   elseif ch=="2" then
      ...
   
   end
end

et ce, même après plusieurs appels de différentes functions.( Alors qu'avec les on.arrow, au bout de 30 secondes, ça ne répondait déjà plus).
voilà, je ne sais pas si ce genre de choses avaient été déjà soulevé auparavant...
User avatar
Creative Basic
Niveau 8: ER (Espèce Rare: nerd)
Niveau 8: ER (Espèce Rare: nerd)
Level up: 57%
 
Posts: 93
Joined: 24 Jul 2011, 12:51
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Pause pdt l'execution d'un prgm

Unread postby Adriweb » 15 Feb 2013, 22:08

N'oublies pas de faire un platform.windows:invalidate() apres chaque event où un rafraichissement graphique est attendu.
Meme si ca marche sur TINCS, il en faut un on-calc.

Et sinon, c'est bizarre, le on.arrowKey(key) devrait marcher, par contre il faut pas l'avoir en même temps que on.arrowRight() (etc.) par exemple , parce qu'il y en a un qui prend le dessus (je sais plus lequel :P)

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
My calculator programs
Mes programmes pour calculatrices
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 82%
 
Posts: 14856
Images: 1211
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: adriweb
GitHub: adriweb

Re: Pause pdt l'execution d'un prgm

Unread postby Creative Basic » 15 Feb 2013, 23:08

oui, j'ai bien tapé les platform a la fin de chaque function arrow. En fait, le prgm tourne nickel sur TINCS, c'est vraiment le passage a la calc qui pose problème. Déjà que la vitesse affichée n'est pas la même on calc que sur le logiciel...
Code: Select all
function on.arrowRight()
...
platform.window:invalidate()
end


function on.arrowLeft()
...
platform.window:invalidate()
end


function on.arrowUp()
...
platform.window:invalidate()
end


function on.arrowDown()
...
platform.window:invalidate()
end


Ca déconne peut être entre l'utilisation de ses functions et l'affichage des (grosses) images... on a vraiment l'impression que la calc rame
User avatar
Creative Basic
Niveau 8: ER (Espèce Rare: nerd)
Niveau 8: ER (Espèce Rare: nerd)
Level up: 57%
 
Posts: 93
Joined: 24 Jul 2011, 12:51
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Pause pdt l'execution d'un prgm

Unread postby Creative Basic » 19 Feb 2013, 20:16

bon, effectivement pour ce qui est de la vitesse de l’exécution d'un prgm en LUA, le fait d’appeler une "grande" image (318 x 212) ralentit considérablement la vitesse du gameplay. Sans image "de fond", le jeu s’exécute pratiquement à la même vitesse que sur le logiciel PC.
Je vais essayer de tester avec des images en basse def. ou d'une couleur unie...
User avatar
Creative Basic
Niveau 8: ER (Espèce Rare: nerd)
Niveau 8: ER (Espèce Rare: nerd)
Level up: 57%
 
Posts: 93
Joined: 24 Jul 2011, 12:51
Gender: Not specified
Calculator(s):
MyCalcs profile

PreviousNext

Return to Nspire-Lua

Who is online

Users browsing this forum: ClaudeBot [spider] and 94 guests

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
1234
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
2640 utilisateurs:
>2630 invités
>2 membres
>8 robots
Record simultané (sur 6 mois):
29271 utilisateurs (le 11/07/2025)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)