Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

It's not an optical illusion, it just looks like one. -- Phil White


devel / comp.lang.javascript / I am presenting you a new game: a game of clicking stars.

SubjectAuthor
o I am presenting you a new game: a game of clicking stars.Kristjan Robam

1
I am presenting you a new game: a game of clicking stars.

<0a924984-7ea3-4627-acdb-176f6f9285cdn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17919&group=comp.lang.javascript#17919

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:622a:1b01:b0:343:582f:3e07 with SMTP id bb1-20020a05622a1b0100b00343582f3e07mr42320545qtb.578.1662462609596;
Tue, 06 Sep 2022 04:10:09 -0700 (PDT)
X-Received: by 2002:a54:4413:0:b0:345:d29f:9dbb with SMTP id
k19-20020a544413000000b00345d29f9dbbmr9452510oiw.48.1662462609175; Tue, 06
Sep 2022 04:10:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Tue, 6 Sep 2022 04:10:08 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=82.131.38.37; posting-account=HfIszAoAAAC8ch6q3uChpTWUALHCfEoF
NNTP-Posting-Host: 82.131.38.37
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0a924984-7ea3-4627-acdb-176f6f9285cdn@googlegroups.com>
Subject: I am presenting you a new game: a game of clicking stars.
From: he12091983@gmail.com (Kristjan Robam)
Injection-Date: Tue, 06 Sep 2022 11:10:09 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 14196
 by: Kristjan Robam - Tue, 6 Sep 2022 11:10 UTC

It contains of folder images, which has transparent star images 1.png up to 11.png. (Which you have to create yourself, because I cannot post it here)

Then file clickgame.html:

<html>
<head>
<meta name="viewport" content="width=345, initial-scale=1.0,
minimum-scale=1.0, maximum-scale=1.0">
<script src="yyyyyyyyyyyyyyyyyyyy.yy"></script>
<style type="text/css">
..a1 {
} ..a15 {
font-size:15px;
} ..currtime {
} ..a2 {
width: 100%;
position:absolute;
top:0;
} ..link1 {
} a:link {
} ..a3 {
position:relative;
top:0vw;
} ..myCanvas {
position:relative;
left:0vw;
display: inline-block;
top:0px;
} ..score {
font-size:15px;
} ..currtime {
font-size:15px;
} ..toplist {
font-size:15px;
}

..aaa1 {
display:inline-block;
height: 70vh;
display:absolute;
top:0px;
} .topplayers {
display:block;
position:absolute;
width:100%;
vertical-align:top;
left: 0;
top: 89vh;
}

body {
background-color: lightblue;
color: white;
}

</style>
</head>
<body>
<h1 class="a1">Clicking game. </h1>
<p class="a3"></p>
<div class="aaa1">
<canvas class="myCanvas" width="1300px" height="580px" style="border:1px solid
#d3d3d3;">
Error</canvas>
<p class="a2"></p>
</div>
<p></p>
<div class="topplayers">
<h1 class="a15">Click as many stars as you can in 15 seconds !</h1>
<button id="startgame1" name="B e g i n ........."
onclick="startgameofclicks()">B e g i n .........</button>
<h1 class="a15">Clicks:</h1>
<div class="score">0</div>
<h1 class="a15">Time:</h1>
<div class="currtime">0</div>
<h1 class="a15">Top players:</h1>
<div class="toplist"></div>
</div>

<script>
var aaa=46;
var aaa12=6;

var circles = new Array();

var circlenr=1;
var x = 70;
var y = 100;
var radius = 43;
var nextX, nextY;
var WIDTH = 1200;
var HEIGHT = 480;
var countt=0;
var circlesnumber=1;
var gamestatus="";
var newcirclecreationcount=0;
var playerscore=0;

function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}

function randomdir(direction) {
newdirection="";
while(true) {
var newd=getRandomInt(1,4);
if(newd==1) newdirection="right";
if(newd==2) newdirection="up";
if(newd==3) newdirection="left";
if(newd==4) newdirection="down";
if(direction!=newdirection) break;
}
return newdirection;
} function randomdir() {
newdirection="";
var newd=getRandomInt(1,4);
if(newd==1) newdirection="right";
if(newd==2) newdirection="up";
if(newd==3) newdirection="left";
if(newd==4) newdirection="down";
return newdirection;
} function getnextdegree(degree) {
var newdeg=degree+10;
if(newdeg>359) newdeg=newdeg-360;
return newdeg;
}

function circlescollidingextended(ca1_x, ca1_y, ca2_x, ca2_y, radiusa1) {

if(Math.sqrt((ca1_x-ca2_x)*(ca1_x-ca2_x)+(ca1_y-ca2_y)*(ca1_y-ca2_y)<radiusa1*2))
return true;
return false;
}

function cancreatecircle(x111, y111) {
var collision=false;
for (var i=0; i<circles.length; i++) {

if(circlescollidingextended(x111,y111,circles[i].x,circles[i].y,circles[i].radius))
{ collision=true;
return false;
break;
}
}
if(collision) return false;
return true;
}

function circlescolliding(circlea1, circlea2) {

if(Math.sqrt((circlea1.x-circlea2.x)*(circlea1.x-circlea2.x)+(circlea1.y-circlea2.y)*(circlea1.y-circlea2.y))<circlea1.radius*2)
return true;
return false;
}

var c = document.getElementsByClassName("MyCanvas")[0];
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.rect(0, 0, 555, 1200);
ctx.closePath();

function isinCircle(evx, evy, circlex, circley, r) {
return Math.sqrt((evx-circlex)*(evx-circlex) +
(evy-circley)*(evy-circley)) < r;
} c.addEventListener('click', function(event) {
var rect = c.getBoundingClientRect();

var mouse_x=(event.clientX - rect.left) / (rect.right - rect.left) *
c.width;
var mouse_y=(event.clientY - rect.top) / (rect.bottom - rect.top) *
c.height;

var canvasOffset=$(".myCanvas").offset();

var offsetX=canvasOffset.left;
var offsetY=canvasOffset.top;
var ev_x=event.pageX-offsetX;
var ev_y=event.pageY-offsetY;
for (var i = circles.length - 1; i >= 0; --i) {
if(isinCircle(ev_x, ev_y, circles[i].x+7.5, circles[i].y+7.5, radius)) {
if(gamestatus=="stop") break;
playerscore++;
document.getElementsByClassName("score")[0].innerHTML = playerscore;
circles[i].dontdraw=true;
circlefadeout(circles[i], aaa*2, i);
} else {
} }
});

function circlefadeout(circleabc, circlewidthabc,circleidx) {
circleabc.x=circleabc.x-61;
circleabc.y=circleabc.y-61;
circlewidthabc=circlewidthabc+122;
if(circlewidthabc>7292) {
circles.splice(circleidx,1);
return;
} ctx.beginPath();
ctx.clearRect(circleabc.x, circleabc.y, circlewidthabc, circlewidthabc);
imgObj=new Image();
imgObj.src=circleabc.imagesrc;
ctx.drawImage(imgObj, circleabc.x, circleabc.y,
circlewidthabc,circlewidthabc);
ctx.closePath();
setTimeout(function() { circlefadeout(circleabc, circlewidthabc,circleidx);
}, 2);
}

var imgObj;

function clear() {
ctx.clearRect(0, 0, c.width, c.height);
}

function drawcircle(circlea) {

ctx.save();
ctx.beginPath();
ctx.translate(circlea.x+aaa,circlea.y+aaa);
circlea.degree=getnextdegree(circlea.degree);
ctx.rotate(circlea.degree*Math.PI/180);
ctx.translate(-circlea.x-aaa,-circlea.y-aaa);
imgObj=new Image();
imgObj.src=circlea.imagesrc;
ctx.drawImage(imgObj, circlea.x, circlea.y, aaa*2,aaa*2);
ctx.closePath();
ctx.restore();

}

function createnewcircle() {

var image000=Array("1.png", "2.png", "3.png", "4.png", "5.png", "6.png", "7.png", "8.png", "9.png", "10.png", "11.png");

var imagesrc000 = image000[Math.floor(Math.random()*image000.length)];

var x_rand=getRandomInt(0,WIDTH);
var y_rand=getRandomInt(0,HEIGHT);
if(!cancreatecircle(x_rand,y_rand)) {
newcirclecreationcount++;
if(newcirclecreationcount>987654321) {
gamestatus='stop';
return;
} createnewcircle();
return;
} var newid=circlenr++;
var newcirc = {
x: x_rand,
y: y_rand,
radius: aaa,
direction: randomdir(),
id: 're'+newid,
degree: 0,
dontdraw: false,
imagesrc: "/images/"+imagesrc000
} circles.push(newcirc);
drawcircle(newcirc);
}

c.onclick = function (event)
{ if(gamestatus=="stop") return;
} var nameentered=false;

function displaytoppl() {

$.ajax({
url: 'process.php',
dataType: 'json',
type: 'POST',
async: true,
data: { action: 'get'},
success: function( data, textStatus, jQxhr ){
var data1=data;
var listofpl="Player &nbsp;&nbsp;&nbsp; Clicks<br>";
for(var i=0; i<data1.length; i++) {
listofpl=listofpl+data1[i]['playername']+" &nbsp;&nbsp;&nbsp;"+data1[i]['playerscore']+"<br>";
} document.getElementsByClassName("toplist")[0].innerHTML = listofpl;
},
error: function( jqXhr, textStatus, errorThrown ){
alert(errorThrown);
} });
}

function entername() {

if(nameentered) return;
var name = prompt("Your name:", "");
var psc=playerscore;
nameentered=true;
$.ajax({
url: 'process.php',
dataType: 'text',
type: 'POST',
async: true,
data: { playername: name, playerscore: psc, action: 'add'},
success: function( data, textStatus, jQxhr ){
displaytoppl();
},
error: function( jqXhr, textStatus, errorThrown ){
displaytoppl();
} });
}

function makeamove(circle) {

var x_rand=getRandomInt(0,WIDTH);
var y_rand=getRandomInt(0,HEIGHT);

switch(circle.direction) {
case "right":
{
var collision=false;
for (var i=0; i<circles.length; i++) {
if(circle.id!=circles[i].id) {
if(circlescolliding(circle,circles[i])) {
collision=true;
circle.direction="left";
circle.x=x_rand;
circle.y=y_rand;
return;
break;
}
}
}
if(collision) break;
if(circle.x<WIDTH) {
circle.x=circle.x+aaa12;
break;
} else {
circle.direction=randomdir("right");
makeamove(circle);
break;
}
} break;
case "left":
{
var collision=false;
for (var i=0; i<circles.length; i++) {
if(circle.id!=circles[i].id) {
if(circlescolliding(circle,circles[i])) {
collision=true;

circle.direction="right";
circle.x=x_rand;
circle.y=y_rand;


Click here to read the complete article
1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor