2048: Difference between revisions

Content added Content deleted
No edit summary
Line 6,346: Line 6,346:
return
return
ok
ok
pdownnew()
pmovedown()
pmovedown()
newnum()
newnum()

func pdownnew()
if gameover() = 1
return
ok
pmovedown()


func pup()
func pup()
Line 6,360: Line 6,353:
return
return
ok
ok
pupnew()
pmoveup()
pmoveup()
newnum()
newnum()

func pupnew()
if gameover() = 1
return
ok
pmoveup()


func pleft()
func pleft()
Line 6,374: Line 6,360:
return
return
ok
ok
pleftnew()
pmoveleft()
pmoveleft()
newnum()
newnum()

func pleftnew()
if gameover() = 1
return
ok
pmoveleft()


func pright()
func pright()
Line 6,388: Line 6,367:
return
return
ok
ok
prightnew()
pmoveright()
pmoveright()
newnum()
newnum()

func prightnew()
if gameover() = 1
return
ok
pmoveright()


func pmoveleft()
func pmoveleft()
Line 6,408: Line 6,380:
next
next
movetilesleft(n,moveleft)
movetilesleft(n,moveleft)
next
next


func movetilesleft(nr,moveleft)
func movetilesleft(nr,moveleft)
for p = 1 to (len(moveleft) - 1)
for p = 1 to len(moveleft) - 1
button[p][nr] {temp1 = text()}
temp1 = moveleft[p]
button[p+1][nr] {temp2 = text()}
temp2 = moveleft[p+1]
temp = string(number(temp1) + number(temp2))
if (temp1 = temp2) and (temp1 != '0') and (temp2 != '0') and (temp1 != '') and (temp2 != '')
if (temp1 = temp2) and (temp1 != '0') and (temp2 != '0') and (temp1 != '') and (temp2 != '')
temp = string(number(temp1) + number(temp2))
if temp != '0' and temp != ''
moveleft[p] = temp
moveleft[p] = temp
del(moveleft,p+1)
del(moveleft,p+1)
ok
exit
next
ok
for n = 1 to len(moveleft)
c1 = (moveleft[n] = '')
c2 = (moveleft[n] = '0')
if c1 or c2
del(moveleft,n)
ok
ok
next
next
Line 6,452: Line 6,420:


func movetilesright(nr,moveright)
func movetilesright(nr,moveright)
for p = len(moveright) - 1 to 1 step -1
flag = 0
button[p][nr] {temp1 = text()}
for p = len(moveright) to 2 step -1
button[p+1][nr] {temp2 = text()}
temp1 = moveright[p]
temp2 = moveright[p-1]
if (temp1 = temp2) and (temp1 != '0') and (temp2 != '0') and (temp1 != '') and (temp2 != '')
if (temp1 = temp2) and (temp1 != '0') and (temp2 != '0') and (temp1 != '') and (temp2 != '')
temp = string(number(temp1) + number(temp2))
temp = string(number(temp1) + number(temp2))
if temp != '0'
if temp != '0' and temp != ''
flag = 1
moveright[p] = temp
moveright[p] = temp
del(moveright,p+1)
del(moveright,p-1)
exit
exit
ok
ok
Line 6,488: Line 6,458:


func movetilesup(nr,moveup)
func movetilesup(nr,moveup)
flag = 0
for p = 1 to len(moveup) - 1
for p = 1 to len(moveup) - 1
button[nr][p] {temp1 = text()}
temp1 = moveup[p]
button[nr][p+1] {temp2 = text()}
temp2 = moveup[p+1]
if (temp1 = temp2) and (temp1 != '0') and (temp2 != '0') and (temp1 != '') and (temp2 != '')
if (temp1 = temp2) and (temp1 != '0') and (temp2 != '0') and (temp1 != '') and (temp2 != '')
temp = string(number(temp1) + number(temp2))
temp = string(number(temp1) + number(temp2))
if temp != '0'
if temp != '0' and temp != ''
flag = 1
moveup[p] = temp
moveup[p] = temp
del(moveup,p+1)
del(moveup,p+1)
exit
exit
ok
ok
ok
ok
Line 6,524: Line 6,496:


func movetilesdown(nr,movedown)
func movetilesdown(nr,movedown)
flag = 0
for p = 1 to len(movedown) - 1
for p = 1 to len(movedown) - 1
button[nr][size-p+1] {temp1 = text()}
temp1 = movedown[p]
button[nr][size-p] {temp2 = text()}
temp2 = movedown[p+1]
if (temp1 = temp2) and (temp1 != '0') and (temp2 != '0') and (temp1 != '') and (temp2 != '')
if (temp1 = temp2) and (temp1 != '0') and (temp2 != '0') and (temp1 != '') and (temp2 != '')
temp = string(number(temp1) + number(temp2))
temp = string(number(temp1) + number(temp2))
if temp != '0'
if temp != '0' and temp != ''
flag = 1
movedown[p] = temp
movedown[p] = temp
del(movedown,p+1)
del(movedown,p+1)
Line 6,581: Line 6,555:
}
}
}
}

func showarray(vect)
see "["
svect = ""
for n = 1 to len(vect)
svect = svect + vect[n] + " "
next
svect = left(svect, len(svect) - 1)
see svect
see "]" + nl


class MyButton from qPushButton
class MyButton from qPushButton