platform.apilevel = '2.0' ----------------------------------------------------------- --------------- BRICK BREAKER, BY ANTOX98 ----------------- ----------------------------------------------------------- -- Contact : TI-Planet / Omnimaga Username : AnToX98 Mail : antoineaappia@hotmail.fr -- Please don't use parts of this code without contacting me -- Special thanks to the TI planet and Omnimaga communauty -- Project started : 30 / 08 / 2013 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------------------------- --------- GLOBALS --------- --------------------------- --------- IMAGES ---------- -- Ball image -- imgball = image.new("\006\000\000\000\006\000\000\000\000\000\000\000\012\000\000\000\016\000\001\000\247^k\173c\140c\140\008\161\247Zk\173\198\152\008\161\000\128\000\128k\173c\140\008\161\255\255\000\128\000\128c\140c\140\000\128\000\128\000\128\000\128c\140k\173\000\128\000\128\000\128\000\128k\173\247Zk\173c\140c\140k\173\215Z") -- Normal paddle image -- palet = image.new("'\000\000\000\010\000\000\000\000\000\000\000N\000\000\000\016\000\001\000tNV\198\218\210\219\210\187\206=\223\190\239\157\235\189\239\189\239\189\235\189\235\189\235\190\235\158\235\158\235\189\235\221\239\221\239\190\235\190\239\189\235\157\235\189\239\189\239\190\239\157\235\189\235\157\235\189\235\189\235\156\235\157\235\029\219\188\206\221\206\152\202UFsJTB\185\206\158\231^\223^\194\190\177\157\173\157\173\155\173\157\173~\173}\173{\169{\169|\173{\169\157\169\158\173\158\173\159\173\158\173\156\173\156\169}\173}\173}\169|\173\156\173~\173}\173\156\173}\169\158\173\190\177=\194\031\215\029\219y\198UF\185\202^\227\253\214\250\185X\165\217\148W\132\020\128\020\128\020\128\020\1282\128o\136\141\140\142\140\143\140T\136\025\128\028\128\028\128\027\128\024\128t\136\143\140\143\140\143\140n\1361\128\022\128\021\128\017\128\019\128x\136\217\148X\165\248\185\188\206\223\210Y\198\186\177=\194\217\1817\161t\140:\132]\140Y\136;\132>\132\092\132z\140\184\152\184\148\185\148\184\148\153\148z\136\156\136z\136z\136\154\136\185\144\183\148\184\148\185\152\185\152y\140<\132]\136[\136Z\132Z\136X\132\149\140\021\161\186\181\220\181z\169\028\153\153\140\215\144v\136Z\132\188\144\218\148\147\140q\140r\140r\140r\140r\140v\140\187\148\185\144\146\144\238\152\014\161\013\157\014\157\207\152\146\144\154\144\186\148\179\140q\136\146\144r\140r\136r\140\149\144\186\144\157\140Z\136w\136\151\140\153\144\028\157\221\177\029\153y\1368\132\157\144\217\148p\136G\132c\136\132\144c\140d\140\131\140D\136\142\148l\144\166\148\196\144\166\144\167\148\166\144\165\148\167\144\140\144m\144E\136\130\140D\140e\140\132\140b\136G\132s\144\217\148\154\144X\132\153\136<\153\221\173\157\169\254\152Z\136Y\136\147\144j\140&\132g\140\167\144\176\177\209\177\178\185\142\181\230\156\007\153\176\1854\198T\178\150\154\250\150\184\1584\1822\198\141\177\200\152\235\160\175\181\208\181\178\181\143\173\134\144e\136G\132\141\140\146\140Y\136\127\136\029\149\188\173\154\169\188\1485\132j\132c\136@\136c\140\132\144\132\140\168\144N\165\176\177\176\177\018\194(\161\240\185\182\206\025\211\092\199\092\187}\199\248\210\150\210\174\177)\161\019\190\144\173\175\177L\165\136\144\134\140\165\148e\144B\136c\136M\1329\132\220\144\186\173\2449/\161\199\140\164\140\166\148\167\152\231\156\006\157\007\157\009\157\010\157\197\148\133\140\013\161\137\136-\157T\190\027\219<\219<\223;\223\025\211U\194\011\153\136\140\013\157\134\140\199\148\008\157\009\157\232\156\007\161\232\152\166\148\163\148\164\144\199\144M\161\019:1F\172\181i\165l\169\175\181\206\185\208\189\207\185\016\190\016\190\016\190\205\181J\169\200\148f\140g\136\169\144\203\148\235\148\011\149\011\149\234\148\169\140\135\140\133\140\200\152i\169\206\181\015\190\239\189\016\194\238\189\239\185\208\189\142\181L\169i\169\204\1813B") -- Large paddle image -- palet2 = image.new(";\000\000\000\010\000\000\000\000\000\000\000v\000\000\000\016\000\001\0006\194\247\185\249\185\249\185\250\185\251\185\251\185\251\185\250\185\216\181\247\185\153\206\215\214\182\210\182\210\183\206\183\206\183\206\183\206\183\206\182\206\182\206\183\206\183\206\182\206\150\206\182\210\182\210\182\210\182\210\150\210\150\210u\206u\206\150\206\149\206\149\206\150\206\150\206\150\206\150\210\182\210\183\210\183\210\183\210\216\214\154\206\247\185\216\185\249\185\249\185\249\185\249\185\249\185\250\185\251\189\217\185\024\194W\202X\198\023\190\246\181\246\185\246\189\247\185\247\185\247\185\248\185Y\198z\202x\173<\194_\231\127\235_\231\127\231\127\231\127\231\127\231\127\231\127\231\127\231\127\231\127\231\127\235\127\235\127\235\127\235\127\235\127\235\127\235\127\235\127\235\127\235\127\235\127\235\127\235_\235\127\235\127\235\127\231_\231\127\235?\231=\198y\173Y\198X\194\246\185\022\186\021\186\245\185\245\185\246\185\216\185\216\185:\198z\206\015\157\169\144P\198\239\218\204\218\204\218\171\218\204\218\175\214\024\227\159\243\127\206\028\157V\1325\1326\1327\1326\1326\1325\128U\132U\1325\1327\1327\1328\1327\1326\1326\1325\1326\1328\1329\1329\1328\1325\1323\132T\1325\1285\132V\1327\132V\132W\1328\132\252\156^\198\127\2358\227\207\214\203\214\200\214\202\218\234\218\015\223Q\198\139\144\240\152\214\185\236\152\004\128J\169/\231\172\251\166\251A\243\002\235\235\2309\235[\202\187\177\027\161\155\140\022\128\024\128\025\128\024\1289\132x\136\151\136x\136Y\128\025\128\026\128\026\128:\132y\136w\132x\136Y\132\027\128\028\128\028\128\027\128Y\136\150\136v\136x\1369\128\025\128\025\128\024\128\024\128|\140\027\161\153\177Z\202\025\231\015\231$\235A\239\133\247\171\251o\239\171\181\004\128\173\148\146\1814F\146\177l\140\006\128\168\181g\210@\206\003\198\239\197\025\198{\173\186\148:\132\027\132:\136:\132[\132Y\132\153\140\218\148\217\144\186\144\186\144\154\140\154\140y\140\185\148\249\156\247\152\248\156\216\152x\140y\140y\144\153\144\185\148\184\148\184\144\218\152\154\144Z\136[\136Z\136:\132<\132\025\128\152\144y\169\249\189\241\193\227\197 \210H\214\170\185%\132I\136P\1695F4FTJUJ\022FQ\169H\136D\136\227\156\006\161S\173\216\152z\144;\136\157\144\188\148w\140s\136r\136q\136q\136q\136\180\144\180\144\146\144\241\152\240\152\207\152\205\152\205\152\206\152\174\152\206\152\205\152\206\152\206\152\207\152\144\148\147\152\180\152p\140o\140p\140p\140p\140u\140\187\144}\140X\132v\136\182\144S\169\006\161\194\160E\144(\136\015\161\021>UF3B2FSJ3FSJUN\243A\012\161\003\128H\132\188\181\253\156\026\132[\140\218\152\146\140L\136j\136\138\140\204\152\203\148\171\148\170\144\171\148\237\160\170\140\235\128\012\129\235\128\236\128\013\129\238\128\238\128\237\128\237\128\236\132\138\136\237\156\171\152\138\148\202\152\170\148\236\152\169\144h\136J\132p\136\184\148z\1409\132\252\156\221\185j\140\002\128\234\156\242\1894F3B2B2B2BSJSJSJSJSJSJ\2085\016\157\190\181\189\152X\136\147\144l\140h\136\169\148\233\152\200\148M\169\242\189T\202\208\185\241\189\218\218w\186\250\166]\167]\163]\163]\163]\163^\167^\167^\171\028\175\152\182\251\214\241\189\174\1812\198\017\190l\169\232\148\200\148\167\140g\136\140\140\146\144W\140\187\156\158\181\241\156\143\1773F2F2B2B2B2B2B2J3J3J3J3F3JSJ5F\1825\209\152m\140\136\140E\136d\136\133\140\134\140\168\148\201\152\010\161\202\156\201\152\144\177V\202\251\206=\195\027\179\027\179\028\175\028\175\028\175\028\175\028\179\028\179\028\187\251\202V\198\176\177\200\152\200\152\009\161\167\148\167\148\166\144\133\140e\140f\140i\140l\140\177\152\149\177\245\1933F2F2F2F2B2B2B2B3J3J3J3J3J3J2J2J\240AK\169\233\156\232\156\232\156\233\156\234\156\234\156*\161L\169\201\152\003\128\004\128\203\152\212\189\219\218\028\219\028\211\028\215\028\211\028\211\028\215\028\215\028\215<\215<\219\251\214\211\189\235\156\004\128\002\128\167\148+\165\009\161\009\157\009\157\232\156\199\152\199\152\232\152L\169\208\185\018B2F2F2F3F3F3F3FSF") -- Blocks Image -- block1 = image.new("\024\000\000\000\011\000\000\000\000\000\000\0000\000\000\000\016\000\001\000t\230J\205\255\127\255\127\255\127\181\230\016\226\239\221\239\217\239\221\239\217\239\221\140\217\255\127\255\127\255\127\016\222\239\221\239\221\239\221\239\221\016\222\016\226\132\188\173\217b\188J\185\255\127\255\127s\226\198\200B\188c\192\132\196d\196c\192c\188\132\196\255\127R\226\166\200\131\192B\188c\192c\196\165\196\131\196B\160\239\217c\192\198\188\255\127\247\230\206\221\132\196c\192\164\196\165\200)\229\231\204\034\176\132\196\198\204(\205\198\200\132\196c\196\133\196\131\192\131\192\132\196B\164\206\217\165\200\198\200\141\209\182\234\008\205B\192\164\196\165\196\231\208J\221\132\188\199\192\132\196B\192\132\196\165\200\198\200\198\200\165\200\008\205\132\196c\196B\164\239\221\198\200\132\196B\176\198\188\198\200c\188\131\188\198\200\231\204\132\188B\172\198\196\198\200c\188\131\188\166\196\231\200\132\192\132\192\198\200\197\200c\192B\164\206\217\198\200\166\196B\172\000\160A\176\132\192d\192\132\196\198\200\198\196\132\192b\192\132\196\132\192B\184B\176\165\192\165\188c\184B\188\132\196\132\196B\164\206\217\165\196c\192\165\196c\180B\176\132\192c\192\131\196\198\196b\192\198\200\166\200\132\196\132\192B\188 \168B\172!\172\165\192\165\196\132\196\132\196B\164\173\217\132\192c\192\165\200\198\196\131\188\131\192c\196\131\196\132\196c\192\165\196\198\200\165\200\132\192c\192B\172\000\152\000\172\132\196\198\200\165\200\132\192B\168\173\217c\192\132\196\132\196\132\196\165\196\132\192\034\176!\184\131\192c\188!\176c\188\165\200\165\200B\176c\168\255\127)\193\165\192\132\192\165\196\165\200B\168\206\217\132\196c\196\132\200\131\196c\184\132\172\255\127\255\127\008\193!\176B\180c\196\165\200c\180c\160\255\127\255\127\255\127\206\205b\192\165\200\132\196B\164\231\192B\164B\164B\164!\164\165\160\255\127\255\127\255\127J\197!\168B\164B\164!\160c\160\255\127\255\127\255\127\255\127\255\127I\193\000\164B\164!\156") block2 = image.new("\024\000\000\000\011\000\000\000\000\000\000\0000\000\000\000\016\000\001\000\181\2461\238k\221\255\127\255\127\255\1271\234\016\238\239\2331\238\239\237\140\225\255\127\255\127\255\1271\238\015\2341\238\016\234\239\2331\242\016\234\239\233\231\208\239\233\197\220\131\208J\197\255\127\148\234\008\221b\212\165\216\198\220\132\216B\212\231\208\255\1271\230\132\216\165\216\198\220\132\216c\212\132\216\165\212c\212B\172\206\229\198\220\165\212\008\209\016\222\239\229\231\220\132\216\132\216\198\220\165\216\165\216c\216J\225\140\229\165\220\131\212\198\216\165\216\165\216b\208\132\216\165\220B\172\206\229\132\216c\208\009\217k\221)\217\132\212c\212\132\216\132\216B\208\198\216\231\220\165\216\132\212c\212\132\216\132\216B\208\198\216\198\216\165\216\132\216!\172\206\229\132\216\132\216\165\212\197\196c\176\132\204c\212c\212\132\216\132\212\165\212\165\216\132\216\132\216c\212c\212\132\216\132\212\132\212\165\216\132\216\132\216B\176\173\229\132\216\132\216c\204B\184c\180c\192c\208\132\216\132\216c\212\131\212\132\216\198\220\133\212c\208d\208\132\216c\212c\212\132\216\198\220\132\216B\176\206\229\132\216c\212\165\220c\204c\196c\212c\212\132\212\132\216c\212\165\216c\212\132\216\132\204\000\176B\180\132\208c\212\132\216c\212\132\212\132\216B\176\239\233\165\216\198\216\165\216\008\221\132\216c\216\132\216\197\220\198\220\197\216\165\216\008\221\132\212c\216c\188c\180\132\196\165\216\198\216\231\220\131\212\132\216B\176\239\233\198\220\165\216\132\212\008\221\165\204A\196\132\212\165\220\165\200c\188\132\208\231\224\198\220c\212\132\196\000\168\198\188\197\208c\216\008\225\165\216c\212B\176\239\233\198\220\165\220\132\220B\196B\168B\180c\208\165\216\132\192c\184\131\212c\216\165\220\132\204!\172\255\127\255\127\207\217\132\216c\212\165\216\132\220B\176\165\200B\176B\176B\172!\160\000\152!\156B\172!\168B\168!\164B\176B\172B\176!\164\255\127\255\127\255\127\255\127\198\196\000\172B\176B\176!\164") block3 = image.new("\024\000\000\000\011\000\000\000\000\000\000\0000\000\000\000\016\000\001\000\016\250\008\241\008\241\008\233\008\233\008\241\008\241\231\240\231\240(\241\008\241)\241)\241\166\228\133\224\173q1\246\239\245\231\240)\241)\241\008\241\231\240B\204\140\245B\236\034\232B\208B\204B\232B\236!\236\034\236c\236\034\236B\236c\240\132\236D\220\008q\016\246K\245\001\232B\236B\236c\240#\224A\176\173\245c\236B\236C\224C\208\164\232c\240B\236C\236c\236B\236c\236c\236\133\240c\236)\241\016\246\231\240\034\236c\236c\236\133\240D\224k\205\239\245\132\240c\236\165\240\199\240\165\236d\236c\236\198\240c\236c\236\165\240\165\240C\236\132\240d\236\008\241\132\240c\236\165\240\132\236c\236\132\240B\188\173\245\165\240\133\240\132\236)\241\165\240B\236c\236\132\240\198\240\133\240d\236\008\241\132\236B\236c\236\132\240\198\240\132\236\132\236\231\240\132\236B\236B\188\206\245\165\240\132\240C\236C\236\165\240c\236C\236\165\240\165\240\132\240C\236C\236\165\240c\236c\236\165\240\165\240\132\236c\236c\236\165\240c\236!\188\239\245\165\240\165\240\132\240B\236\132\240\132\240c\236\132\240\165\240\165\240\132\240B\236\132\236\132\240c\236\132\240\165\240\165\240\132\236B\236\132\240\132\236!\188\173\245c\236\034\236\165\236\165\240\132\240c\236B\236c\236\132\236\034\236\165\240\165\240\132\240c\236B\236c\240\132\240\034\236\165\240\165\240\132\240C\236!\188\173\245c\236c\236\165\240\165\240c\236C\236B\236c\236c\236c\236\132\240\132\240\132\236c\236C\236d\228B\220B\228\132\240\132\240\132\236C\236!\188\173\245c\240c\236C\240c\240\133\240c\240C\236C\236\132\240C\236c\240d\240\165\240c\240B\232B\192\173\209\140\233c\244c\240\165\240c\236!\188d\220!\180!\184!\188!\184B\188!\184!\184!\184!\184!\184A\188!\184B\184!\184!\180\230\176\206\209J\225!\196!\180B\184!\184!\172") block4 = image.new("\024\000\000\000\011\000\000\000\000\000\000\0000\000\000\000\016\000\001\000\239\253\008\253\231\252\198\252\231\252)\253\230\252\198\252\231\252)\253\231\252\198\252\231\252)\253\199\252\198\252\231\252)\253\231\252\198\252\231\252)\253\198\252!\220J\253\000\252\000\248\000\252\000\252\000\252\000\252\000\252\000\252\000\252\000\248\000\252\000\252\000\252\001\252\000\252\000\252\000\252\000\252\000\252\000\252\000\252\001\248\000\196k\253\000\252\000\248\000\252b\252\000\248B\252C\252\000\252\000\252\000\248\000\252c\252\000\248B\252c\252\000\252\000\252\000\248!\252c\252\000\252B\248!\196\173\253!\252\000\248!\252B\252\034\252B\252\132\252c\252!\252\000\248!\252B\252B\252b\252\198\252\132\252\000\252\000\248!\252B\252B\252B\248c\200\140\253!\252\000\248\000\244\132\252\166\252!\252\000\252A\252!\252\000\248\000\248\132\252\165\252\000\252\000\252A\252!\252\000\244\000\248\132\252\132\252\000\244\000\200k\253\000\252!\252\000\252!\252 \252B\252\000\252\000\252\000\252!\252\000\252!\252 \252b\252\000\252\000\248\000\252\000\252\000\252!\252 \252B\248\000\200\141\253\000\244\000\248\000\248!\252\000\252!\252b\252B\252!\248\000\248\000\248!\252\000\252B\252c\252A\252!\248\000\248\000\248\034\252\000\252\034\248!\200k\253\000\252!\244\000\252\000\248 \248\000\252B\252 \252!\252!\244\000\252\000\248\000\248\000\252c\252 \252!\252\001\244\000\252\000\248\000\252\000\248\034\200k\253B\252!\252\000\252!\248c\252\001\252\000\252!\252c\252!\252\000\252 \252c\252\000\252\000\252!\252c\252 \252\000\252!\248c\252\000\248\000\200k\253\000\252\000\252\000\252!\252!\252B\252\000\252\000\252 \252\000\252\000\252 \252!\252B\252\000\252\000\252\000\252\000\252\000\252!\252!\252B\248\000\200!\232\000\192\000\192\000\192!\196\000\196!\196!\196\000\192\000\192\000\192\000\192!\196\000\196!\196 \196\000\192\000\192\000\192\000\192!\196\000\196!\192!\180") block5 = image.new("\024\000\000\000\011\000\000\000\000\000\000\0000\000\000\000\016\000\001\000|\243{\239{\239[\239[\239{\239{\239{\239[\239{\239[\239[\239{\239[\239{\239{\239{\239{\239|\243{\239\189\247\156\243[\239\024\227Z\235\247\222\182\218s\206\181\214\247\222\247\222\246\218\148\210s\206\148\210\148\210s\206\148\210\148\210\181\214\024\227:\235\024\227\182\218\024\227{\239\247\222\016\194Z\235\181\214s\206\247\222R\202s\206\214\218\214\2181\198k\173\017\198\016\194k\173s\206\173\181\239\1899\2319\231\181\214\024\227\148\210\247\222\215\222\239\189Z\235\180\210R\202R\202\206\1851\198\214\218\247\222s\206\140\177t\210s\206\173\181\247\222\240\189\017\194{\239\024\227\181\214R\202\239\189\148\210\181\214\207\189Z\235\214\218s\206\140\177\206\185R\202\214\218\024\227\148\210\173\181\181\214\148\210\174\185\024\227\016\1941\198|\243Z\235\214\218\239\189\016\194\148\210\148\210\206\181Z\235\247\222\215\222s\206s\206\213\214\024\227\024\227\148\210\173\181\181\214\149\214\174\185\025\231\016\1941\198{\239[\2399\231\181\214\148\210\215\222s\206\140\177Z\235\215\222\181\214\182\218\148\210\247\2229\2319\231\149\214\173\181\214\218\181\214\206\1859\231\016\1941\198{\2399\231\181\214\214\218\148\210\181\214S\202\140\173{\239\214\218\148\210\247\2221\198\149\2149\231Z\235\214\218\206\185\247\222\214\218\206\185Y\2311\1981\198{\239\181\214\148\210\215\222\239\1890\194\016\194k\173{\239\024\227t\210\140\177\206\185\148\2109\231[\2398\227R\202Z\2359\231R\202\156\243\148\210\148\210Z\235\181\2141\198k\173l\177\206\185\239\189J\169\155\239Z\235\024\227\181\214\148\210\247\222Z\235{\239\156\243\189\247\189\247\156\243\156\243{\239{\239Z\235\247\222\181\214S\206\239\189\206\1851\198\016\194k\173Z\235\213\214\214\218\182\218\181\214\182\218\214\218\214\218\214\218\181\214\181\214\148\214s\206R\2021\1981\198\016\194\016\194\016\194\239\189\239\189\016\194\206\185)\165") -- Fall bonus image-- bonus = image.new("\020\000\000\000\008\000\000\000\000\000\000\000(\000\000\000\016\000\001\000;g;c\092\227}\231\158\239\158\239\157\231\157\223\157\223\157\227\157\227\157\227\157\231\157\231\157\231\158\231\158\231<\223\250R\249V;\227<\223\190\227\255\243\255\251\255\251\255\247\255\247\255\247\255\247\255\247\255\251\255\251\255\251\255\251\255\247\255\243\223\231<\211\249R;\227\026\211\191\215\255\231\255\239\255\239\255\239\255\243\255\243\255\243\255\243\255\243\255\243\255\243\255\243\255\239\255\231\223\223<\203\217\206 0 and math.random(1,4) == 1 and verif_blocks[k]==0 then patternBonus[#patternBonus][k] = 1 end end end cursor.set("crosshair") menu, game, highsc, help, about = 1, 2, 3, 4, 5 screen = menu blockW = 24 blockH = 11 tBonus = patternBonus mY = 72 timerB = true option = 1 hiscore = var.recall("hiscore") if not hiscore then hiscore = {} end end initGame() --------- OTHERS ---------- function newGame() life = 3 score = 0 ammo = 0 tBonus = patternBonus ciwall = {} tAmmo = {} resetBonus() dilvl = true stickball = false ingame = false gameover = false hiscore = var.recall("hiscore") nlvl = 1 tBalls = { Balls(92+pW/2,h-pH-5,0,-5,imgball) } objPad = Paddle(94,h-pH+1,1,palet) on.initLvl() end function resetBonus() eBonus = {} mainBonus = "nobonus" actBonus = nil namebonus = "nobonus" tAmmo = {} end function saveHighsc() if #hiscore == 0 then hiscore[1] = score elseif #hiscore>0 and #hiscore<10 then hiscore[#hiscore+1] = score elseif #hiscore == 10 then for i=1, 10 do if score>hiscore[11-i] then table.insert(hiscore,11-i,score) table.remove(hiscore,1) break end end end table.sort(hiscore) var.store("hiscore",hiscore) end function on.initLvl() ciwall = {} blockX = {} blockY = {} bst = {} for i=1,#levels[nlvl] do for k=1,#levels[nlvl][i] do if levels[nlvl][i][k]>0 then blockX[#blockX+1]=k*blockW+6 blockY[#blockY+1]=i*blockH+11 bst[#bst+1] = levels[nlvl][i][k] end end end end function reset() tBalls = { Balls(92+pW/2,h-pH-5,0,-5,imgball) } objPad = Paddle(94,h-pH+1,1,palet) ingame = false stickball = true life = life - 1 resetBonus() end function on.newLevel() nlvl = nlvl + 1 if nlvl == 35 then nlvl = 1 patternBonus = {} for i = 1, #levels do patternBonus[#patternBonus+1] = {} local nb = math.random(1,4) for k = 1, getnblocks(levels[i]) do patternBonus[#patternBonus][k] = 0 if nb > 0 and math.random(1,4) == 1 and verif_blocks[k]==0 then patternBonus[#patternBonus][k] = 1 end end end end score = score + 50 dilvl = true ingame = false tBalls = { Balls(92+pW/2,h-pH-5,0,-5,imgball) } objPad = Paddle(94,h-pH+1,1,palet) resetBonus() on.initLvl() end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------------------------- --------- EVENTS ---------- --------------------------- --------- TIMER LAUNCH ---------- timer.start(platform.hw and (platform.hw() == 7 and 0.04 or 0.01) or 0.01) --------- TIMER FUNCTIONS --------- -- Main Event -- function on.timer() if screen == game then timers[game]() else timers[menu]() end end -- Timer stuff -- timers[menu] = function() platform.window:invalidate() end timers[game] = function() if ingame == true then Balls:move() Balls:wallColli() Balls:paddleColli() local rem3 = {} if #tAmmo>0 then for i = 1, #tAmmo do tAmmo[i][2] = tAmmo[i][2] - 8 if tAmmo[i][2]<20 then rem3[#rem3+1] = i end end if #rem3>0 then for i = 1, #rem3 do table.remove(tAmmo,rem3[i]) end end end Balls:blockColli() Balls:verif() moveBlocks() if #eBonus>0 then fBonus() end if actBonus then factBonus() end end circlewall() if gameover == true then if tDoors[1]= h-10-boH and eBonus[i][2] <= h-boH-4 and eBonus[i][1]+boW >= p.x and eBonus[i][1] <= p.x+p.width then actBonus = 0 mainbonus = eBonus[i][5] remB[#remB+1] = i namebonus = eBonus[i][5] end if eBonus[i][2] >= h then remB[#remB+1] = i end end for i = 1, #remB do table.remove(eBonus,remB[i]) end if mainbonus~="nobonus" then if mainbonus == "Life X1" or mainbonus == "Life X2" or mainbonus == "Life X3" then life = life + numBL mainbonus = "nobonus" objPad.img = palet objPad.width = pW elseif mainbonus == "Score +10" or mainbonus == "Score +50" or mainbonus == "Score +200" then score = score + numBS mainbonus = "nobonus" objPad.img = palet objPad.width = pW elseif mainbonus == "Large Pad" then objPad.img = palet2 objPad.width = pW2 mainbonus = "nobonus" elseif mainbonus == "Ammo X1" or mainbonus == "Ammo X2" or mainbonus == "Ammo X3" then ammo = ammo + numBA mainbonus = "nobonus" objPad.img = palet objPad.width = pW elseif mainbonus == "Multiball X1" or mainbonus == "Multiball X2" or mainbonus == "Multiball X3" then mainbonus = "nobonus" for i = 1, numBM do local rb = math.random(1,#tBalls) local rb2 = math.random(1,2) if rb2 == 1 then rb2 = -5 else rb2 = 5 end local rb3 = math.random(-10,10) tBalls[#tBalls+1] = Balls(tBalls[rb].x, tBalls[rb].y, rb3, rb2, imgball) end objPad.img = palet objPad.width = pW end end end local ct3 = 0 function moveBlocks() for i = 1, #tBalls do local b = tBalls[i] if b.y >= h-50 then ct3 = ct3 + 1 else ct3 = 0 end end if ct3>=10 then local rb = math.random(1,10) if rb == 9 then local ver = 0 for i = 1, #blockX do if blockY[i]>=h-40 then ver = 1 end end if ver==0 then for i = 1, #blockX do blockY[i]=blockY[i]+4 end end end end end local ct = 0 function circlewall() local sup = {} ct = ct +1 if ct==2 then for i = 1,#ciwall do ciwall[i][3]=ciwall[i][3]+1 if ciwall[i][3]==4 then sup[#sup+1] = i end end for k=1,#sup do table.remove(ciwall,sup[k]) end ct= 0 end end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------- MOUSE FUNCTIONS ---------- function on.mouseMove(x,y) if timerB == true then if screen == game then cursor.show() if ingame == true then local p=objPad p.x = x - p.width/2 if p.x+p.width>201 then p.x = 200-p.width elseif p.x<27 then p.x = 28 end elseif ingame == false and stickball == true then if xtBalls[1].x+40 then tBalls[1].ax = 10 else tBalls[1].ax = (x-tBalls[1].x)/4 print(((x-tBalls[1].x)/4)) end end elseif screen == menu then if y<72+25 then mY = 72 option = 1 elseif y>=72+25 and y<72+2*25 then mY = 72+25 option = 2 elseif y>=72+2*25 and y<72+3*25 then mY = 72+2*25 option = 3 elseif y>=72+3*25 then mY = 72+3*25 option = 4 end end end end function on.mouseDown(x,y) if timerB == true then local pass = 0 if screen==game and stickball == true then stickball = false pass = 1 ingame = true pass = 1 end if screen == game and dilvl == true and x>=w/2-20 and x<=w/2+20 and y>=h/2 and y<=h/2+20 then dilvl = false stickball = true pass = 1 end if screen==menu then screen = option + 1 if option + 1 == game then dilvl = true newGame() end end if screen==game and ingame == true and ammo>0 and pass == 0 then ammo = ammo - 1 tAmmo[#tAmmo+1] = {objPad.x+(objPad.width/2)-2,h-10} end end end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------- KEY FUNCTIONS ---------- function on.enterKey() if timerB == true then if gameover == false then local pass = 0 if screen==game and stickball == true then stickball = false pass = 1 ingame = true end if screen==game and dilvl == true then dilvl = false pass = 1 stickball = true end if screen==game and ingame == true and ammo>0 and pass == 0 then ammo = ammo - 1 tAmmo[#tAmmo+1] = {objPad.x+objPad.width/2,h-10} end end if screen==menu then screen = option + 1 if option + 1 == game then dilvl = true newGame() end end if gameover == true and tDoors[2]==w/2 then initGame() gameover = false end end end function on.escapeKey() if timerB == true then initGame() end end function on.charIn(char) if char == "8" then on.arrowKey("up") elseif char == "2" then on.arrowKey("down") elseif char == "4" then on.arrowKey("left") elseif char == "6" then on.arrowKey("right") elseif char == "5" then on.enterKey() elseif char == "p" then if timerB == true then timer.stop() platform.window:invalidate() else timer.start(0.05) end timerB = not timerB end end function on.arrowKey(key) if timerB == true then if screen == menu or screen == game then arrowKeys[screen](key) end end end -- Arrow stuff -- arrowKeys[menu] = function(key) cursor.hide() if key == "down" and option~=4 then mY = mY + 25 option = option + 1 elseif key == "up" and option~=1 then mY = mY - 25 option = option - 1 end end arrowKeys[game] = function(key) cursor.hide() if gameover==false then if dilvl == false then if stickball == true then local b = tBalls[1] if key=="right" and b.ax<10 then b.ax = b.ax + 1 elseif key=="left" and b.ax>-10 then b.ax = b.ax - 1 end else local p = objPad if key=="right" then p.x = p.x + 19 elseif key=="left" then p.x = p.x - 19 end if p.x+p.width>201 then p.x = 200-p.width elseif p.x<27 then p.x = 28 end end end end end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------- GRAPHICAL CONTEXT FUNCTIONS ---------- ---------- BETTER LUA API, BY ADRIWEB ---------- function drawRoundRect(gc, x, y, wd, ht, rd) -- wd = width, ht = height, rd = radius of the rounded corner local x = x - wd / 2 -- let the center of the square be the origin (x coord) local y = y - ht / 2 -- same for y coord if rd > ht / 2 then rd = ht / 2 end -- avoid drawing cool but unexpected shapes. This will draw a circle (max rd) gc:drawLine(x + rd, y, x + wd - (rd), y) gc:drawArc(x + wd - (rd * 2), y + ht - (rd * 2), rd * 2, rd * 2, 270, 90) gc:drawLine(x + wd, y + rd, x + wd, y + ht - (rd)) gc:drawArc(x + wd - (rd * 2), y, rd * 2, rd * 2, 0, 90) gc:drawLine(x + wd - (rd), y + ht, x + rd, y + ht) gc:drawArc(x, y, rd * 2, rd * 2, 90, 90) gc:drawLine(x, y + ht - (rd), x, y + rd) gc:drawArc(x, y + ht - (rd * 2), rd * 2, rd * 2, 180, 90) end function fillRoundRect(gc, x, y, wd, ht, radius) -- wd = width and ht = height -- renders badly when transparency (alpha) is not at maximum >< will re-code later if radius > ht / 2 then radius = ht / 2 end -- avoid drawing cool but unexpected shapes. This will draw a circle (max radius) gc:fillPolygon({ (x - wd / 2), (y - ht / 2 + radius), (x + wd / 2), (y - ht / 2 + radius), (x + wd / 2), (y + ht / 2 - radius), (x - wd / 2), (y + ht / 2 - radius), (x - wd / 2), (y - ht / 2 + radius) }) gc:fillPolygon({ (x - wd / 2 - radius + 1), (y - ht / 2), (x + wd / 2 - radius + 1), (y - ht / 2), (x + wd / 2 - radius + 1), (y + ht / 2), (x - wd / 2 + radius), (y + ht / 2), (x - wd / 2 + radius), (y - ht / 2) }) local x = x - wd / 2 -- let the center of the square be the origin (x coord) local y = y - ht / 2 -- same gc:fillArc(x + wd - (radius * 2), y + ht - (radius * 2), radius * 2, radius * 2, 1, -91) gc:fillArc(x + wd - (radius * 2), y, radius * 2, radius * 2, -2, 91) gc:fillArc(x, y, radius * 2, radius * 2, 85, 95) gc:fillArc(x, y + ht - (radius * 2), radius * 2, radius * 2, 180, 95) end ------------------------------------------------ function on.paint(gc) paints[screen](gc) if timerB == false then gc:setColorRGB(0,0,0) gc:setFont("serif","b",12) gc:drawString("Game paused : press p to resume",5,210) end end -- GC Stuff -- paints[menu] = function(gc) gc:setFont("serif","r",20) gc:drawString("BRICK",w/2-135,40) gc:setFont("serif","b",20) gc:setColorRGB(110,110,110) gc:drawString("BREAKER",w/2-26,40) for k = 2,10 do gc:drawImage(block1,k*blockW+3,50) gc:drawImage(block5,k*blockW+3,182) end for i = 5,15 do gc:drawImage(block3,51,blockH*i+6) gc:drawImage(block3,243,blockH*i+6) end gc:setColorRGB(0,0,0) gc:setFont("serif","r",12) gc:drawString("PLAY",w/2-22,89) gc:drawString("HIGHSCORES",w/2-52,114) gc:drawString("HELP",w/2-22,139) gc:drawString("ABOUT",w/2-30,164) gc:drawRect(w/2-55,mY,110,20) end paints[game] = function(gc) drawBack(gc) drawBlocks(gc) drawScore(gc) drawCiwall(gc) Paddle:paint(gc) Balls:paint(gc) if #eBonus> 0 then drawBonus(gc) end if actBonus then gc:setFont("serif","b",16) local mw = gc:getStringWidth(namebonus) if actBonus == 1 then gc:setColorRGB(255,255,0) gc:drawString(namebonus,w/2-30-mw/2,h/2) else gc:setColorRGB(0,0,150) gc:drawString(namebonus,w/2-30-mw/2,h/2) end end if #tAmmo > 0 then gc:setColorRGB(0,170,0) for i = 1, #tAmmo do gc:fillRect(tAmmo[i][1]-2,tAmmo[i][2],4,6) end end if dilvl == true then drawInitLvl(gc) end if gameover == true then drawGameover(gc) end end --gc game stuff-- function drawBonus(gc) for i = 1, #eBonus do gc:drawImage(bonus,eBonus[i][1],eBonus[i][2]) if eBonus[i][4]<20 then gc:setFont("serif","r",6) gc:drawString(eBonus[i][5],eBonus[i][1]+23,eBonus[i][2]+10) end end end function drawCiwall(gc) gc:setColorRGB(150,0,0) gc:setPen("thin") for i=1,#ciwall do if ciwall[i][3]==1 then gc:drawArc(ciwall[i][1]-5,ciwall[i][2],10,10,0,360) elseif ciwall[i][3]==2 then gc:drawArc(ciwall[i][1]-7.5,ciwall[i][2]-7.5,15,15,0,360) elseif ciwall[i][3]==3 then gc:drawArc(ciwall[i][1]-10,ciwall[i][2]-10,20,20,0,360) end end end function drawBack(gc) gc:setPen("thick") gc:setColorRGB(170,170,170) if actBonus then if actBonus == 1 then gc:setColorRGB(0,0,150) else gc:setColorRGB(255,255,0) end end gc:fillRect(0,0,w,h) gc:setColorRGB(230,230,0) gc:drawRect(26,17,191-15,200) gc:drawRect(28,19,187-15,196) gc:setColorRGB(255,255,255) if actBonus then if actBonus == 1 then gc:setColorRGB(0,0,150) else gc:setColorRGB(255,255,0) end end gc:fillRect(30,22,183-15,200) gc:setColorRGB(100,100,100) gc:fillRect(225,15,77,210) end function drawScore(gc) gc:setFont("sansserif","b",12) gc:setColorRGB(255,255,0) gc:drawString("SCORE",w-83,40) gc:drawString("AMMO",w-78,85) gc:drawString("LIVES",w-77,130) gc:setFont("sansserif","b",10) gc:drawString("HISCORE",w-83,175) gc:setColorRGB(0,0,0) gc:setFont("sansserif","b",12) local ssc = gc:getStringWidth(score) local sam = gc:getStringWidth(ammo) local sli = gc:getStringWidth(life) if #hiscore>0 then local shi = gc:getStringWidth(hiscore[#hiscore]) gc:drawString(hiscore[#hiscore],w-54-shi/2,195) elseif #hiscore==0 then gc:drawString(0,w-58,195) end gc:drawString(life,w-54-sli/2,150) gc:drawString(ammo,w-54-sam/2,105) gc:drawString(score,w-54-ssc/2,60) end function drawBlocks(gc) for i=1,#blockX do if bst[i]==1 then gc:drawImage(block1,blockX[i],blockY[i]) elseif bst[i]==2 then gc:drawImage(block2,blockX[i],blockY[i]) elseif bst[i]==3 then gc:drawImage(block3,blockX[i],blockY[i]) elseif bst[i]==4 then gc:drawImage(block4,blockX[i],blockY[i]) elseif bst[i]==5 then gc:drawImage(block5,blockX[i],blockY[i]) end end end function drawInitLvl(gc) gc:setFont("sansserif","b",12) gc:setColorRGB(0,0,0) fillRoundRect(gc,w/2,h/2,100,70,20) gc:setColorRGB(0,0,200) gc:setPen("medium") drawRoundRect(gc,w/2,h/2,100,70,20) gc:fillRect(w/2-20,h/2,40,20) gc:setColorRGB(255,255,255) gc:setPen("thin") gc:drawRect(w/2-20,h/2,40,20) gc:drawString("Level "..nlvl.."/34",w/2-38,94) gc:drawString("OK",w/2-13,124) end function drawGameover(gc) drawDoors(gc,tDoors[1],0) drawDoors(gc,tDoors[2],0) gc:setColorRGB(100,100,100) if tDoors[1]>=0 then gc:fillRect(0,0,tDoors[1],h) gc:fillRect(tDoors[2]+doorW,0,w-tDoors[2],h) end if tDoors[2]==w/2 then gc:setColorRGB(255,255,255) gc:drawString("GAMEOVER",23,40) gc:drawString("SCORE :",23,70) gc:drawString("HISCORE :",23,100) gc:setColorRGB(255,255,0) gc:drawString("Press enter",23,150) gc:drawString(tostring(score),230,70) gc:drawString(hiscore[#hiscore],230,100) end end function drawDoors(gc,x,y) gc:setColorRGB(0,0,0) gc:fillRect(x,y,doorW,h) gc:setColorRGB(250,250,0) for i = 0, h, 40 do gc:fillPolygon({x,i,x+doorW,i+20,x+doorW,i+40,x,i+20,x,i}) end end --------------------------- paints[highsc] = function(gc) gc:setFont("serif","b",14) gc:setColorRGB(255,0,0) local mYtext = "HIGHSCORES" gc:drawString(mYtext,90,25) gc:setFont("serif","b",10) gc:setColorRGB(0,0,0) if #hiscore == 0 then gc:drawString("No highscores",w/2-46,60) else for i= 1, #hiscore do local hiLen = gc:getStringWidth(hiscore[#hiscore+1-i]) gc:drawString(hiscore[#hiscore+1-i],w/2-hiLen/2,25+i*18) gc:drawLine(w/2-50,27+i*18,w/2+50,27+i*18) end gc:drawRect(w/2-50,27,100,18+(#hiscore-1)*18) end end paints[help] = function(gc) gc:setFont("serif","b",14) gc:setColorRGB(255,0,0) local mYtext = "BRICK BREAKER HELP" gc:drawString(mYtext,40,25) local mYtext = {"The objective of this brickbreaker is to reach the highest score", "possible.", "You have to control the paddle to break the blocks with the ball.", "Use arrows/8-6-2-4 or mouse to control it. You can go back to menu ", "at any time with esc and pause the game with p", "Try to win the 34 levels, but don't worry if you do so, you go to lvl 1", "again ! Use the secret bonus to reach the highest scores possible !" } gc:setFont("serif","b",8) gc:setColorRGB(0,0,0) local y = 45 for k=1,#mYtext do gc:drawString(mYtext[k],15,y) y = y + 22 end end paints[about] = function(gc) gc:setFont("serif","b",14) gc:setColorRGB(255,0,0) local mYtext2 = "ABOUT" gc:drawString(mYtext2,120,25) gc:setFont("serif","b",11) local mYtext2 = {"Lua Brick Breaker, by AnToX98 Project Started : 30 / 08 / 2013", "This brick beaker was written in Lua by Antoine Appia", "using the TI-nspire Student Software and IntelliJ IDEA with lua plugin.", "Big thanks to TI-planet and Omnimaga community for their help ", "and support, big thanks to Adriweb's Nspire lua api on Intellij !", "This brickbreaker is an reproduction of the BlackBerry's one.", "All levels and textures are similar.", "However, to promove a fluent game, the background is simplified." } gc:setFont("serif","b",8) gc:setColorRGB(0,0,0) local y = 45 for k=1,#mYtext2 do gc:drawString(mYtext2[k],15,y) y = y + 22 end end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------- --------- GAME CLASSES --------- -------------------------------- Balls = class() function Balls:init(x,y,ax,ay,img) self.x = x self.y = y self.ax = ax self.ay = ay self.img = img end function Balls:move() for k=1,#tBalls do local b = tBalls[k] b.x = b.x + b.ax b.y = b.y + b.ay end end function Balls:wallColli() for k=1,#tBalls do local b = tBalls[k] local rw = math.random(1,3) if b.x+6>=200 and b.ax>0 and b.x+6<210 then ciwall[#ciwall+1]={b.x,b.y,1} if b.ax>=5 then b.ax=-b.ax+rw elseif b.ax<5 then b.ax=-b.ax-rw end end if b.x<=28 and b.ax<0 and b.x>18 then ciwall[#ciwall+1]={b.x,b.y,1} if b.ax<=-5 then b.ax=-b.ax-rw elseif b.ax>-5 then b.ax=-b.ax+rw end end if b.y<=23 and b.ay<0 then ciwall[#ciwall+1]={b.x,b.y,1} b.ay = -b.ay if b.ax == 0 then local rb = 0 while rb == 0 do rb = math.random(-1,1) end b.ax = b.ax + rb end end end end function Balls:verif() for i=1, #tBalls do local b = tBalls[i] rem2 = {} if b.y+6>h then rem2[#rem2+1] = i end end for k=1, #rem2 do table.remove(tBalls,rem2[i]) end if #tBalls == 0 then reset() end if life == 0 then gameover = true saveHighsc() ingame = false tDoors = {0-doorW,w} end end function Balls:paddleColli() local p = objPad for k=1,#tBalls do local b = tBalls[k] if b.y+6>=h-pH and b.y+6<=h-pH+5 and b.x+3>=p.x and b.x+3<=p.x+p.width and b.ay > 0 then b.ay = -b.ay if b.x+3>=p.x+2*(p.width/5) and b.x+3<=p.x+3*(p.width/5) then elseif b.x+3=p.x+p.width/10 then if b.ax>=0 then b.ax=b.ax-2 elseif b.ax<0 and b.ax>-10 then b.ax=b.ax-1 end elseif b.x+3>p.x+3*(p.width/5) and b.x+3<=p.x+9*(p.width/10) then if b.ax<=0 then b.ax=b.ax+2 elseif b.ax>0 and b.ax<10 then b.ax=b.ax+1 end elseif b.x+3>=p.x and b.x+3=0 then b.ax=b.ax-5 elseif b.ax<0 and b.ax>-9 then b.ax=b.ax-2 end elseif b.x+3<=p.x+p.width and b.x+3>p.x+9*(p.width/10) then if b.ax<=0 then b.ax=b.ax+5 elseif b.ax>0 and b.ax<9 then b.ax=b.ax+2 end end end end end function Balls:blockColli() rem = {} for i=1,#tBalls do local b = tBalls[i] rem[#rem+1] = 0 for k=1,#blockX do if b.y<=blockY[k]+blockH+5 and b.y>blockY[k]+blockH and b.x+3>=blockX[k] and b.x+3<=blockX[k]+blockW and b.ay<0 then b.ay = -b.ay if b.ax == 0 then local rb = 0 while rb == 0 do rb = math.random(-1,1) end b.ax = b.ax + rb end rem[#rem] = k elseif b.y+6>=blockY[k]-5 and b.y+6=blockX[k] and b.x+3<=blockX[k]+blockW and b.ay>0 then b.ay = -b.ay if b.ax == 0 then local rb = 0 while rb == 0 do rb = math.random(-1,1) end b.ax = b.ax + rb end rem[#rem] = k elseif b.x+6>=blockX[k] and b.x+6=blockY[k] and b.y+3<=blockY[k]+blockH and b.ax>0 then local rb = math.random(0,2) b.ax = -b.ax+rb rem[#rem] = k elseif b.x<=blockX[k]+blockW and b.x>blockX[k]+blockW-10 and b.y+3>=blockY[k] and b.y+3<=blockY[k]+blockH and b.ax<0 then local rb = math.random(0,2) b.ax = -b.ax-rb rem[#rem] = k end end end rem2 = {} for i = 1, #tAmmo do for k = 1, #blockX do if tAmmo[i][1]+2>=blockX[k] and tAmmo[i][1]-2<=blockX[k]+blockW and tAmmo[i][2]>=blockY[k] and tAmmo[i][2]<=blockY[k]+blockH then local verif = 0 for j = 1, #rem do if rem[j] == k then verif = 1 end end if verif == 0 then rem[#rem] = k rem2[#rem2+1] = i end end end end if #rem2>0 then for i = 1, #rem2 do table.remove(tAmmo,rem2[i]) end end for i=1,#rem do if rem[i]~=0 then if tBonus[nlvl][rem[i]]>0 then eBonus[#eBonus+1] = {blockX[rem[i]],blockY[rem[i]],tBonus[nlvl][rem[i]],0} tBonus[nlvl][rem[i]] = 0 end end end for i=1,#rem do if rem[i]~=0 then if bst[rem[i]]<5 then score = score + 10 bst[rem[i]] = bst[rem[i]]-1 if bst[rem[i]]==0 then table.remove(blockX,rem[i]) table.remove(blockY,rem[i]) table.remove(bst,rem[i]) table.remove(tBonus[nlvl],rem[i]) end end end end for k = 1,#bst do if bst[k]<5 then break end if k == #bst then on.newLevel() end end if #bst == 0 then on.newLevel() end end function Balls:paint(gc) for k=1,#tBalls do local b = tBalls[k] gc:drawImage(b.img,b.x,b.y) end if dilvl == false and stickball == true then local b = tBalls[1] gc:setPen("thin") gc:setColorRGB(0,0,200) gc:drawLine(b.x+3,b.y+3,b.x+3+3*b.ax,b.y+3+3*b.ay) end end --------------------------- Paddle = class() function Paddle:init(x,y,ty,img) self.x = x self.y = y self.ty = ty self.img = img self.width = image.width(img) self.height = h-pH+1 end function Paddle:paint(gc) local p = objPad gc:drawImage(p.img,p.x,p.y) end -- Our objects : tBalls = { Balls(92+pW/2,h-pH-5,0,-5,imgball) } objPad = Paddle(94,h-pH+1,1,palet)