Skip to content

Commit

Permalink
Merge pull request #86 from okwme/okwme/80-target
Browse files Browse the repository at this point in the history
Okwme/80 target
  • Loading branch information
okwme authored Apr 3, 2024
2 parents edf4db0 + 5ccb993 commit 022c615
Show file tree
Hide file tree
Showing 25 changed files with 267 additions and 83 deletions.
2 changes: 1 addition & 1 deletion contractData/11155111-Bodies.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x8d70C4cCDb0859755046BDe1126BF4f457A62788",
"address": "0x12c309E83D00b9A553EdE271212B183cFEC92EF8",
"chain": { "name": "sepolia", "chainId": 11155111, "ensAddress": null }
}
2 changes: 1 addition & 1 deletion contractData/11155111-Game_10_50Verifier.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x81EB1850eaA4740fa8Cf5bEA70300b4Ccac953D6",
"address": "0x9521f5587d57a3A1391523741Ac19725Ec4F5754",
"chain": { "name": "sepolia", "chainId": 11155111, "ensAddress": null }
}
2 changes: 1 addition & 1 deletion contractData/11155111-Game_3_500Verifier.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x7CD605e935d70730DEB3fC035A8BDBe9BE8eA8fF",
"address": "0xC96A8C6470232211d178ff5a5563054FaFCBBc0f",
"chain": { "name": "sepolia", "chainId": 11155111, "ensAddress": null }
}
2 changes: 1 addition & 1 deletion contractData/11155111-Game_4_300Verifier.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x3e00a26Ccb5C6568bED4cc9d9a242FA7E6F7D43D",
"address": "0x38c749641143c471a774BcA8b1e4eBD3E0BDe175",
"chain": { "name": "sepolia", "chainId": 11155111, "ensAddress": null }
}
2 changes: 1 addition & 1 deletion contractData/11155111-Game_5_100Verifier.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x974E01f9bE379b285895170f6A2c0c518b94b2Ad",
"address": "0x4e061213Dfd5F5398C8B456Be5CAB406e3b5dacD",
"chain": { "name": "sepolia", "chainId": 11155111, "ensAddress": null }
}
2 changes: 1 addition & 1 deletion contractData/11155111-Game_6_100Verifier.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x17e00A790240075b053bc1BE32F8ffe715e31915",
"address": "0x3C3849D6502c6BF9df89AaF094a16Db73E79ad80",
"chain": { "name": "sepolia", "chainId": 11155111, "ensAddress": null }
}
2 changes: 1 addition & 1 deletion contractData/11155111-Game_7_100Verifier.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x251020fF3b6e2ac4208f53B92B4b82747596B068",
"address": "0x6cb41940Dc367D96ae38B86b898047361820f6d3",
"chain": { "name": "sepolia", "chainId": 11155111, "ensAddress": null }
}
2 changes: 1 addition & 1 deletion contractData/11155111-Game_8_50Verifier.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x566e5537A0E41ae76Dc9229A962EDD56acA5dF1d",
"address": "0x0525Fb332FD50bC923b77CFED8E0E6f0e19b506D",
"chain": { "name": "sepolia", "chainId": 11155111, "ensAddress": null }
}
2 changes: 1 addition & 1 deletion contractData/11155111-Game_9_50Verifier.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x0374ee6b87b8DE81BD4d6E506A735b6Ce68647d8",
"address": "0x111F6C2E1172541aff16887351d77cA6c1169ea0",
"chain": { "name": "sepolia", "chainId": 11155111, "ensAddress": null }
}
2 changes: 1 addition & 1 deletion contractData/11155111-Metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x913e2fD7e1BeD3bC0Ea51854c2aB50154Dab0d8e",
"address": "0xdE202c051af40c7D9fB20aAcDC4A4E2F3E1C275c",
"chain": { "name": "sepolia", "chainId": 11155111, "ensAddress": null }
}
2 changes: 1 addition & 1 deletion contractData/11155111-Problems.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x7F3dc4A515160785049FC74011F71905205dB357",
"address": "0x2399ee0C9866Ddbb57F8971a89f0292EB7E259DA",
"chain": { "name": "sepolia", "chainId": 11155111, "ensAddress": null }
}
2 changes: 1 addition & 1 deletion contractData/11155111-Solver.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x0466974dE8815C357CBa69D06b388Af315458952",
"address": "0x8A0117eC0B3a56c48ec6EB3222162C1ed3995427",
"chain": { "name": "sepolia", "chainId": 11155111, "ensAddress": null }
}
2 changes: 1 addition & 1 deletion contractData/11155111-Tocks.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0xE64026794367d55A4A667b19Da9479aBA5C8C79F",
"address": "0x7fc962f1fE02c667dED7596B4Bb7Bb42704E7ea8",
"chain": { "name": "sepolia", "chainId": 11155111, "ensAddress": null }
}
4 changes: 2 additions & 2 deletions contractData/ABI-11155111-Bodies.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contractData/ABI-11155111-Metadata.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contractData/ABI-11155111-Problems.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contractData/ABI-11155111-Solver.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions contracts/Problems.sol
Original file line number Diff line number Diff line change
Expand Up @@ -510,12 +510,15 @@ contract Problems is ERC721, Ownable {
}

function levelUp(uint256 problemId) public onlySolver {
for (uint256 i = 0; i < problems[problemId].bodyCount; i++) {
uint256 bodyId = problems[problemId].bodyIds[i];
uint256 deletionCount = 0;
uint256 bodyCount = problems[problemId].bodyCount;
for (uint256 i = 0; i < bodyCount; i++) {
uint256 bodyId = problems[problemId].bodyIds[i - deletionCount];
problems[problemId].bodyData[bodyId].starLvl++;
if (problems[problemId].bodyData[bodyId].starLvl == problems[problemId].bodyData[bodyId].maxStarLvl) {
Body memory bodyData = problems[problemId].bodyData[bodyId];
internalRemoveBody(problemId, bodyId);
deletionCount++;
problems[problemId].starData.push(bodyData);
}
}
Expand Down
1 change: 1 addition & 0 deletions contracts/Solver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ contract Solver is Ownable {

function deleteMatch(uint256 problemId) public {
require(msg.sender == Problems(problems).ownerOf(problemId), "Not the owner");
Problems(problems).restoreRadius(problemId);
delete matches[problemId];
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"circom:nft-prod": "yarn circom nft_3_500 && yarn circom nft_4_100 && yarn circom nft_5_100 && yarn circom nft_6_100 && yarn circom nft_7_100 && yarn circom nft_8_100 && yarn circom nft_9_50 && yarn circom nft_10_50",
"circom:game-test": "yarn circom game_3_20 && yarn circom game_4_20 && yarn circom game_5_20 && yarn circom game_6_20 && yarn circom game_7_20 && yarn circom game_8_20 && yarn circom game_9_20 && yarn circom game_10_20",
"circom:game-prod": "yarn circom game_3_500 && yarn circom game_4_100 && yarn circom game_5_100 && yarn circom game_6_100 && yarn circom game_7_100 && yarn circom game_8_50 && yarn circom game_9_50 && yarn circom game_10_50",
"deploy": "hardhat run scripts/deploy.cjs",
"test:circom": "ls test/*.js | grep -v -e 'bodies' -e 'problems' -e 'solver' -e 'metadata' | xargs npx hardhat test",
"test:solidity": "hardhat test test/problems.test.js test/metadata.test.js test/bodies.test.js test/solver.test.js",
"test": "hardhat test",
Expand Down
26 changes: 21 additions & 5 deletions src/anybody.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export class Anybody extends EventEmitter {
util: false,
optimistic: false,
paused: true,
aimHelper: false,
target: 'outside', // 'outside' or 'inside'
showLives: true, // true or false
timer: 60 * 50 // 60 seconds * 50 frames per second
}

Expand Down Expand Up @@ -70,6 +73,9 @@ export class Anybody extends EventEmitter {
this.optimistic = mergedOptions.optimistic
this.paused = mergedOptions.paused
this.timer = mergedOptions.timer + this.alreadyRun
this.target = mergedOptions.target
this.showLives = mergedOptions.showLives
this.aimHelper = mergedOptions.aimHelper

// Add other constructor logic here
this.p = p
Expand Down Expand Up @@ -132,14 +138,14 @@ export class Anybody extends EventEmitter {
}

storeInits() {
// console.log('storeInits')
// console.dir(
// {
// frames: this.frames,
// bodies: this.bodies.map((b) => (b.position.x, b.position.y))
// },
// { depth: null }
// )
this.bodyCopies = JSON.parse(JSON.stringify(this.bodies))
this.bodyInits = this.processInits(this.bodies)
// console.dir({ bodyInits: this.bodyInits }, { depth: null })
}
Expand Down Expand Up @@ -345,7 +351,6 @@ export class Anybody extends EventEmitter {
this.mode == 'game' &&
this.bodies.reduce((a, c) => a + c.radius, 0) == 0
) {
this.setPause(true)
alert('You won!')
}
return results
Expand Down Expand Up @@ -374,6 +379,8 @@ export class Anybody extends EventEmitter {
this.bgColor = this.colorArrayToTxt(this.randomColor(0, 200))
this.radiusMultiplyer = 100 //this.random(10, 200)
this.bodies = this.bodyData.map((b) => {
const bodyId = b.bodyId.toNumber()
const bodyIndex = b.bodyIndex.toNumber()
const seed = b.seed
const bodyRNG = new Prando(seed.toString(16))
const px = b.px.toNumber() / parseInt(this.scalingFactor)
Expand All @@ -386,7 +393,8 @@ export class Anybody extends EventEmitter {
parseInt(this.scalingFactor)
const radius = b.radius.toNumber() / parseInt(this.scalingFactor)
return {
index: b.bodyIndex,
bodyId: bodyId,
bodyIndex: bodyIndex,
position: this.createVector(px, py),
velocity: this.createVector(vx, vy),
radius: radius,
Expand Down Expand Up @@ -438,13 +446,15 @@ export class Anybody extends EventEmitter {
// const j = this.random(0, 2)
const j = Math.floor(this.random(1, 3))
const radius = j * 5 + startingRadius
const maxStarLvl = this.random(3, 10, new Prando())
const starLvl = this.random(0, maxStarLvl - 1, new Prando())
const body = {
bodyIndex: i,
position: this.createVector(ss[i][0], ss[i][1]),
velocity: this.createVector(0, 0),
radius,
starLvl: 0,
maxStarLvl: 3,
starLvl,
maxStarLvl,
c: cs[i]
}
bodies.push(body)
Expand Down Expand Up @@ -490,6 +500,12 @@ export class Anybody extends EventEmitter {
this.setPause(false)
return
}
if (
this.bodies.reduce((a, c) => a + c.radius, 0) == 0 ||
this.frames >= this.timer
) {
return
}
if (this.missiles.length > 0 && !this.admin) {
// this is a hack to prevent multiple missiles from being fired
this.missiles = []
Expand Down
4 changes: 2 additions & 2 deletions src/nft.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ window.anybody
q5.setup = () => {
window.anybody = new Anybody(q5, {
mode: 'game',
seed: 0n
// startingBodies: 1
// seed: 0n,
startingBodies: Math.floor(Math.random() * 7) + 3
})
}
q5.draw = () => {
Expand Down
4 changes: 0 additions & 4 deletions src/sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const whistle_8_T7 = new URL(
'/public/sound/whistle/whistle_8_T7.mp3',
import.meta.url
).href
console.log({ whistle_8_T7 })
const whistle_4_T3 = new URL(
'/public/sound/whistle/whistle_4_T3.mp3',
import.meta.url
Expand Down Expand Up @@ -221,7 +220,6 @@ export default class Sound {
}

async playOneShot(url, volume) {
console.log('playOneShot')
this.oneShots = this.oneShots || {}
if (!this.oneShots[url]) {
this.oneShots[url] = new Player({
Expand All @@ -239,7 +237,6 @@ export default class Sound {
}

voiceFromFile(file) {
console.log({ file })
const voice = {
file: file,
player: new Player({
Expand Down Expand Up @@ -279,7 +276,6 @@ export default class Sound {

if (!this.voices) {
const parts = song.parts[0]
console.log({ parts })
this.voices = parts.map((part) => this.voiceFromFile(part[0]))

// master output
Expand Down
Loading

0 comments on commit 022c615

Please sign in to comment.