j"19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAutMÞ <html>
<head>
<meta charset="UTF-8">
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.min.js"></script>
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/addons/p5.dom.min.js"></script>
<script src="https://www.moneybutton.com/moneybutton.js"></script>
<style>
body {
padding: 50px;
font-family: arial;
font-size: 12px;
}
</style>
</head>
<body>
<h1>Flappy Pikachu | Bitcoin SV</h1>
<form>
<input type="text" id="input_id" value="Enter Username Here" onfocus="this.value=''">
<div id="alert" style="color: red"></div>
</form>
<div id='some-div'></div>
<button onclick='myfunction()'>render money button></button>
<br> to share ur hi score
<br><br><br><br>
wait for 1 confirmation for hi score to show up
<br>mouse/ space bar to jump
</body>
<!-- Upload Hi Score thru bitdb -->
<script>
// The query we constructed from step 2.
var query = {
"v": 3,
"q": {
"find": {
"$text": { "$search": "456flappy" }
},
"limit": 1000
},
"r": {
"f": "[ .[] | {msg: .out[0].s3} ]"
}
}
// Turn the query into base64 encoded string.
// This is required for accessing a public bitdb node
var b64 = btoa(JSON.stringify(query));
var url = "https://genesis.bitdb.network/q/1FnauZ9aUH2Bex6JzdcV4eNX7oLSSEbxtN/" + b64;
// Attach API KEY as header
var header = {
headers: { key: ['1K5w2AjkHLi32et2RUbwdbkLQmUvJZP3zy'] }
};
// Make an HTTP request to bitdb.network public endpoint
fetch(url, header).then(function(r) {
return r.json()
}).then(function(r) {
// "r.c" stands for confirmed transactions response array
// Parse the response and render the results on the screen
r.c.forEach(function(output) {
var div = document.createElement("div");
div.innerHTML = output.msg.substr(3);
document.body.appendChild(div)
})
})
</script>
<script>
function myfunction(){
var variable = document.getElementById('input_id').value;
document.getElementById('alert').innerHTML = 'Your user name is: ' + variable + " and your hi score is: " + maxScore.toString()+ " :)";
const div = document.getElementById('some-div')
moneyButton.render(div, {
amount: "0.001",
to: "18awEuWTvvzXksGpWhfGnZVU16GvWm4dkv",
currency: "USD",
label: "swipe",
buttonId: "234325",
buttonData: "{}",
type: "tip",
opReturn: '456flappy '+variable+ '\'s Hiscore: ' + maxScore.toString(),
onPayment: function (arg) { console.log('onPayment', arg) },
onError: function (arg) { console.log('onError', arg) }
})
}
</script>
<script>
class Bird {
constructor() {
this.y = height / 2;
this.x = 64;
this.gravity = 0.6;
this.lift = -10;
this.velocity = 0;
this.icon = birdSprite;
this.width = 41;
this.height = 41;
}
show() {
// draw the icon CENTERED around the X and Y coords of the bird object
image(this.icon, this.x - this.width / 2, this.y - this.height / 2, this.width, this.height);
}
up() {
this.velocity = this.lift;
}
update() {
this.velocity += this.gravity;
this.y += this.velocity;
if (this.y >= height - this.height / 2) {
this.y = height - this.height / 2;
this.velocity = 0;
}
if (this.y <= this.height / 2) {
this.y = this.height / 2;
this.velocity = 0;
}
}
}
//Pipe
class Pipe {
constructor() {
this.spacing = 140;
this.top = random(height / 6, 3 / 4 * height);
this.bottom = this.top + this.spacing;
this.x = width;
this.w = 80;
this.speed = 5.5;
this.passed = false;
this.highlight = false;
}
hits(bird) {
let halfBirdHeight = bird.height / 2;
let halfBirdwidth = bird.width / 2;
if (bird.y - halfBirdHeight < this.top || bird.y + halfBirdHeight > this.bottom) {
//if this.w is huge, then we need different collision model
if (bird.x + halfBirdwidth > this.x && bird.x - halfBirdwidth < this.x + this.w) {
this.highlight = true;
this.passed = true;
return true;
}
}
this.highlight = false;
return false;
}
//this function is used to calculate scores and checks if we've went through the pipes
pass(bird) {
if (bird.x > this.x && !this.passed) {
this.passed = true;
return true;
}
return false;
}
drawHalf() {
let howManyNedeed = 0;
let peakRatio = pipePeakSprite.height / pipePeakSprite.width;
let bodyRatio = pipeBodySprite.height / pipeBodySprite.width;
//this way we calculate, how many tubes we can fit without stretching
howManyNedeed = Math.round(height / (this.w * bodyRatio));
//this <= and start from 1 is just my HACK xD But it's working
for (let i = 0; i < howManyNedeed; ++i) {
let offset = this.w * (i * bodyRatio + peakRatio);
image(pipeBodySprite, -this.w / 2, offset, this.w, this.w * bodyRatio);
}
image(pipePeakSprite, -this.w / 2, 0, this.w, this.w * peakRatio);
}
show() {
push();
translate(this.x + this.w / 2, this.bottom);
this.drawHalf();
translate(0, -this.spacing);
rotate(PI);
this.drawHalf();
pop();
}
update() {
this.x -= this.speed;
}
offscreen() {
return (this.x < -this.w);
}
}
//Sketch
var bird;
var pipes;
var parallax = 0.8;
var score = 0;
var maxScore = 0;
var birdSprite;
var pipeBodySprite;
var pipePeakSprite;
var bgImg;
var bgX;
var gameoverFrame = 0;
var isOver = false;
var touched = false;
var prevTouched = touched;
function preload() {
pipeBodySprite = loadImage('https://raw.githubusercontent.com/CodingTrain/Flappy-Bird-Clone/master/graphics/pipe_marshmallow_fix.png');
pipePeakSprite = loadImage('https://raw.githubusercontent.com/CodingTrain/Flappy-Bird-Clone/master/graphics/pipe_marshmallow_fix.png');
birdSprite = loadImage('https://i.imgur.com/1L4gIOw.png');
bgImg = loadImage('https://i.imgur.com/bhh35fT.png');
}
function setup() {
createCanvas(800, 600);
reset();
}
function draw() {
if(mouseIsPressed){
bird.up();
}
background(0);
// Draw our background image, then move it at the same speed as the pipes
image(bgImg, bgX, 0, bgImg.width, height);
bgX -= pipes[0].speed * parallax;
// this handles the "infinite loop" by checking if the right
// edge of the image would be on the screen, if it is draw a
// second copy of the image right next to it
// once the second image gets to the 0 point, we can reset bgX to
// 0 and go back to drawing just one image.
if (bgX <= -bgImg.width + width) {
image(bgImg, bgX + bgImg.width, 0, bgImg.width, height);
if (bgX <= -bgImg.width) {
bgX = 0;
}
}
for (var i = pipes.length - 1; i >= 0; i--) {
pipes[i].update();
pipes[i].show();
if (pipes[i].pass(bird)) {
score++;
}
if (pipes[i].hits(bird)) {
gameover();
}
if (pipes[i].offscreen()) {
pipes.splice(i, 1);
}
}
bird.update();
bird.show();
if ((frameCount - gameoverFrame) % 150 == 0) {
pipes.push(new Pipe());
}
showScores();
// touches is an list that contains the positions of all
// current touch points positions and IDs
// here we check if touches' length is bigger than one
// and set it to the touched var
touched = (touches.length > 0);
// if user has touched then make bird jump
// also checks if not touched before
if (touched && !prevTouched) {
bird.up();
}
// updates prevTouched
prevTouched = touched;
}
function showScores() {
textSize(32);
text('score: ' + score, 1, 32);
text('record: ' + maxScore, 1, 64);
}
function gameover() {
textSize(64);
textAlign(CENTER, CENTER);
text('GAMEOVER', width / 2, height / 2);
textAlign(LEFT, BASELINE);
maxScore = max(score, maxScore);
isOver = true;
noLoop();
}
function reset() {
isOver = false;
score = 0;
bgX = 0;
pipes = [];
bird = new Bird();
pipes.push(new Pipe());
gameoverFrame = frameCount - 1;
loop();
}
function keyPressed() {
if (key === ' ') {
bird.up();
if (isOver) reset(); //you can just call reset() in Machinelearning if you die, because you cant simulate keyPress with code.
}
}
function touchStarted() {
if (isOver) reset();
}
</script>
</html>
text/htmlutf8Flappy Pikachu.html
https://whatsonchain.com/tx/d7bac8a0e3adb2d3c2e55cb1c84a177d0269457aa7172a80297daaf5e9488cc5