mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-20 12:15:06 -04:00
Added a palette for bricks color
This commit is contained in:
parent
0622e63eb5
commit
8c4735f3f2
4 changed files with 27 additions and 24 deletions
|
@ -160,9 +160,11 @@ The "engine" could be better
|
||||||
- option : don't pause on mobile when lifting finger
|
- option : don't pause on mobile when lifting finger
|
||||||
- option : accelerated relative movements on mobile
|
- option : accelerated relative movements on mobile
|
||||||
- maybe just have 10 background, and always use the same one for the nth level of each run ?
|
- maybe just have 10 background, and always use the same one for the nth level of each run ?
|
||||||
|
- would be nice to have a leaderboard for not using each perk too. Like "best runs without hot start"
|
||||||
|
|
||||||
There are many possible perks left to implement :
|
There are many possible perks left to implement :
|
||||||
- offer next level choice after upgrade pick
|
- offer next level choice after upgrade pick
|
||||||
|
- ban 3 random perks from pool, doesn't tell you which ones, gain 2 upgrades
|
||||||
- 3 random perks immediately, or maybe "all level get twice as many upgrades, but they are applied randomly, and you aren't told which ones you have."
|
- 3 random perks immediately, or maybe "all level get twice as many upgrades, but they are applied randomly, and you aren't told which ones you have."
|
||||||
- wrap left / right
|
- wrap left / right
|
||||||
- pause and cheat again
|
- pause and cheat again
|
||||||
|
|
|
@ -23,6 +23,7 @@ const randomPatterns=[
|
||||||
]
|
]
|
||||||
let attributed=0
|
let attributed=0
|
||||||
allLevels.forEach(l => {
|
allLevels.forEach(l => {
|
||||||
|
l.bricks=l.bricks.split('').map(c=>palette[c])
|
||||||
if (!l.color && !l.svg) {
|
if (!l.color && !l.svg) {
|
||||||
l.svg = randomPatterns[attributed%randomPatterns.length]
|
l.svg = randomPatterns[attributed%randomPatterns.length]
|
||||||
attributed++
|
attributed++
|
||||||
|
@ -87,7 +88,7 @@ function resetCombo(x, y) {
|
||||||
type: "text",
|
type: "text",
|
||||||
text: "-" + lost,
|
text: "-" + lost,
|
||||||
time: levelTime,
|
time: levelTime,
|
||||||
color: "red",
|
color: "r",
|
||||||
x: x,
|
x: x,
|
||||||
y: y,
|
y: y,
|
||||||
duration: 150,
|
duration: 150,
|
||||||
|
@ -110,7 +111,7 @@ function decreaseCombo(by, x, y) {
|
||||||
type: "text",
|
type: "text",
|
||||||
text: "-" + lost,
|
text: "-" + lost,
|
||||||
time: levelTime,
|
time: levelTime,
|
||||||
color: "red",
|
color: "r",
|
||||||
x: x,
|
x: x,
|
||||||
y: y,
|
y: y,
|
||||||
duration: 300,
|
duration: 300,
|
||||||
|
|
|
@ -260,9 +260,9 @@ let allLevels=[
|
||||||
"focus": false
|
"focus": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Greed",
|
"name": "Dollar",
|
||||||
"size": 17,
|
"size": 17,
|
||||||
"bricks": "________________________k_k______________k_k____________kkkkkkk_________kkkkkkkkk_______kk__k_k__kk______kk__k_k__kk______kk__k_k___________kkkkkkkk__________kkkkkkkk___________k_k__kk______kk__k_k__kk______kk__k_k__kk_______kkkkkkkkk_________kkkkkkk____________k_k______________k_k________________________",
|
"bricks": "________________________G_G______________G_G____________GGGGGGG_________GGGGGGGGG_______GG__G_G__GG______GG__G_G__GG______GG__G_G___________GGGGGGGG__________GGGGGGGG___________G_G__GG______GG__G_G__GG______GG__G_G__GG_______GGGGGGGGG_________GGGGGGG____________G_G______________G_G________________________",
|
||||||
"svg": "",
|
"svg": "",
|
||||||
"color": "",
|
"color": "",
|
||||||
"focus": false
|
"focus": false
|
||||||
|
@ -414,7 +414,7 @@ let allLevels=[
|
||||||
{
|
{
|
||||||
"name": "B71",
|
"name": "B71",
|
||||||
"size": 10,
|
"size": 10,
|
||||||
"bricks": "__________rrryyyy_r_r__r__yrr_r__r__y_r_rrr__y__r_r__r_y__r_r__ry___r_rrr_y__rrr__________",
|
"bricks": "__________bbbtttt_b_b__b__tbb_b__b__t_b_bbb__t__b_b__b_t__b_b__bt___b_bbb_t__bbb__________",
|
||||||
"svg": "",
|
"svg": "",
|
||||||
"focus": false
|
"focus": false
|
||||||
},
|
},
|
||||||
|
|
|
@ -129,32 +129,29 @@ document.getElementById('levels').addEventListener('click', e => {
|
||||||
if (!levelIndexStr) return
|
if (!levelIndexStr) return
|
||||||
if (e.target.tagName!=='BUTTON') return
|
if (e.target.tagName!=='BUTTON') return
|
||||||
|
|
||||||
|
|
||||||
const levelIndex = parseInt(levelIndexStr)
|
const levelIndex = parseInt(levelIndexStr)
|
||||||
const level = allLevels[levelIndex]
|
const level = allLevels[levelIndex]
|
||||||
const {bricks, size} = level;
|
const {bricks, size} = level;
|
||||||
|
|
||||||
if (resize) {
|
if (resize) {
|
||||||
const newSize = size + parseInt(resize)
|
const newSize = size + parseInt(resize)
|
||||||
const newBricks = []
|
const newBricks = new Array(newSize*newSize).fill('_')
|
||||||
for (let x = 0; x < Math.min(size, newSize); x++) {
|
for (let x = 0; x < Math.min(size, newSize); x++) {
|
||||||
for (let y = 0; y < Math.min(size, newSize); y++) {
|
for (let y = 0; y < Math.min(size, newSize); y++) {
|
||||||
newBricks[y * newSize + x] = bricks[y * size + x] || ''
|
newBricks[y * newSize + x] = bricks.split('')[y * size + x] || '_'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
level.size = newSize;
|
level.size = newSize;
|
||||||
level.bricks = newBricks;
|
level.bricks = newBricks.map(b=>b||'_').join('');
|
||||||
} else if (moveX && moveY) {
|
} else if (moveX && moveY) {
|
||||||
const dx = parseInt(moveX), dy = parseInt(moveY)
|
const dx = parseInt(moveX), dy = parseInt(moveY)
|
||||||
const moved = []
|
const newBricks = new Array(size*size).fill('_')
|
||||||
for (let x = 0; x < size; x++) {
|
for (let x = 0; x < size; x++) {
|
||||||
for (let y = 0; y < size; y++) {
|
for (let y = 0; y < size; y++) {
|
||||||
moved[(y + dy) * size + (x + dx)] = bricks[y * size + x] || ''
|
newBricks[(y + dy) * size + (x + dx)] = bricks.split('')[y * size + x]|| '_'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
level.bricks = newBricks.map(b=>b||'_').join('');
|
||||||
level.bricks = moved;
|
|
||||||
} else if (e.target.getAttribute('data-rename')) {
|
} else if (e.target.getAttribute('data-rename')) {
|
||||||
const newName = prompt('Name ? ', level.name)
|
const newName = prompt('Name ? ', level.name)
|
||||||
if (newName) {
|
if (newName) {
|
||||||
|
@ -182,38 +179,41 @@ document.getElementById('levels').addEventListener('click', e => {
|
||||||
|
|
||||||
}, true)
|
}, true)
|
||||||
|
|
||||||
let applying = undefined
|
let applying = ''
|
||||||
|
|
||||||
function colorPixel(e) {
|
function colorPixel(e) {
|
||||||
if (typeof applying === 'undefined') return
|
if ( applying == '') return
|
||||||
const index = e.target.getAttribute('data-set-color-of')
|
const index = e.target.getAttribute('data-set-color-of')
|
||||||
const level = e.target.getAttribute('data-level')
|
const level = e.target.getAttribute('data-level')
|
||||||
if (index && level) {
|
if (index && level) {
|
||||||
const levelIndex = parseInt(level)
|
const levelIndex = parseInt(level)
|
||||||
e.target.style.background = applying || 'transparent'
|
e.target.style.background = palette[applying]
|
||||||
allLevels[levelIndex].bricks[index] = applying
|
setBrick(levelIndex,parseInt(index),applying)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function setBrick(levelIndex,index,chr) {
|
||||||
|
const bricks=allLevels[levelIndex].bricks
|
||||||
|
allLevels[levelIndex].bricks = bricks.substring(0,index) + chr + bricks.substring(index+1);
|
||||||
|
}
|
||||||
document.getElementById('levels').addEventListener('mousedown', e => {
|
document.getElementById('levels').addEventListener('mousedown', e => {
|
||||||
const index = e.target.getAttribute('data-set-color-of')
|
const index = parseInt(e.target.getAttribute('data-set-color-of'))
|
||||||
const level = e.target.getAttribute('data-level')
|
const level = e.target.getAttribute('data-level')
|
||||||
if (index && level) {
|
if (index && level) {
|
||||||
const before = allLevels[parseInt(level)].bricks[parseInt(index)] || ''
|
const before = allLevels[parseInt(level)].bricks[parseInt(index)] || '_'
|
||||||
applying = before === currentCode ? '_' : currentCode
|
applying = before === currentCode ? '_' : currentCode
|
||||||
colorPixel(e)
|
colorPixel(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
document.getElementById('levels').addEventListener('mouseenter', e => {
|
document.getElementById('levels').addEventListener('mouseenter', e => {
|
||||||
if (typeof applying !== undefined) {
|
if (applying !== '') {
|
||||||
|
|
||||||
colorPixel(e)
|
colorPixel(e)
|
||||||
}
|
}
|
||||||
}, true)
|
}, true)
|
||||||
|
|
||||||
document.addEventListener('mouseup', e => {
|
document.addEventListener('mouseup', e => {
|
||||||
applying = undefined
|
applying = ''
|
||||||
save()
|
save()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue