Jump to content

[Game] Last one to post wins!


Pleeb
 Share

Recommended Posts

  • Replies 110.9k
  • Created
  • Last Reply

Top Posters In This Topic

  • Luminesce

    4662

  • Srn347

    5082

  • Breloomancer

    27336

  • Bear

    7579

Top Posters In This Topic

Posted Images

Posting "I'm breathing" or "I'm digesting" when I have nothing else to say would probably be a new low for LOTPW

 

but maybe not lower than the only other thing I could say right now

Hi! I'm Lumi, host of Reisen, Tewi, Flandre and Lucilyn.

Everyone deserves to love and be loved. It's human nature.

My tulpas and I have a Q&A thread, which was the first (and largest) of its kind. Feel free to ask us stuff.

Link to comment
Share on other sites

I'm breathing through my nostrils and digesting junk that I ate moments ago rn.

I'm the host of my system. I'll sometimes type in this color.

I have two tulpas. The first one is Nepeta, and he types in this color. The second one is Lilith, she types in this color.

 

Progress Report

Link to comment
Share on other sites

same

Hi! I'm Lumi, host of Reisen, Tewi, Flandre and Lucilyn.

Everyone deserves to love and be loved. It's human nature.

My tulpas and I have a Q&A thread, which was the first (and largest) of its kind. Feel free to ask us stuff.

Link to comment
Share on other sites

I have at least a few times

Hi! I'm Lumi, host of Reisen, Tewi, Flandre and Lucilyn.

Everyone deserves to love and be loved. It's human nature.

My tulpas and I have a Q&A thread, which was the first (and largest) of its kind. Feel free to ask us stuff.

Link to comment
Share on other sites

(edited)

Uh... I'm writing some code. I replaced some code for a random snake game I found online. If you use the new colors I coded in, you can sometimes cheat and when crossing the body by passing through. I don't want to fix that yet, there's something else I'm working on.

 

https://codepen.io/rajatkantinandi/pen/LLrorK?editors=1111

 

The program works best if you go to settings and turn off Auto-Updating Preview. That way, you don't have to refresh the page every time you want to play again. If you want, you can take the code I modified in the spoiler tag, paste it into the JS window, and play with what I got working.

 

Spoiler

I really hope this code block doesn't kill the forum. This isn't written by me from scratch, this includes my edits.


var canvas, ctx;
var n = 3,score=0,a=0;
var p=[10,10,10,10];
// Length of each segment of the snake
var segLength = 10;

// Arrays of x,y positions of each coordinate system 
// one for each segment
// Trick to create arrays filled with zero values
var x = Array.apply(null, Array(n)).map(Number.prototype.valueOf,0);
var y = Array.apply(null, Array(n)).map(Number.prototype.valueOf,0);
var mousePos;
var canvas = document.getElementById("myCanvas");
	var fx = 10+Math.random() * (canvas.width-20);  
	var fy = 10+Math.random() * (canvas.height-20);
function init() {
   ctx = canvas.getContext('2d');
  canvas.addEventListener('mousemove', function (evt) {
    mousePos = getMousePos(canvas, evt);
  }, false);
  
  // starts animation
  requestAnimationFrame(animate);
}

function getMousePos(canvas, evt) {
   // necessary to take into account CSS boundaries
   var rect = canvas.getBoundingClientRect();
      p = ctx.getImageData(evt.clientX - rect.left, evt.clientY - rect.top, 1, 1).data;
   return {
      x: evt.clientX - rect.left,
      y: evt.clientY - rect.top
   };
}

function animate() {
 if(a==0)
  {
  ctx.clearRect(0, 0, canvas.width, canvas.height);
  foodRandom(fx,fy);
  // draw the snake, only when the mouse entered at
  if(mousePos !== undefined) {
    //If snake eats food then change length & update food
	  if(mousePos.x>(fx-1)&&mousePos.x<(fx+13)&&mousePos.y>(fy-1)&&mousePos.y<(fy+13)){
	n++;
  score++;
  document.getElementById("score").innerHTML=score;
	changes(n);
	fx = 10+Math.random() * (canvas.width-20);  
	fy = 10+Math.random() * (canvas.height-20);
  foodRandom(fx,fy);
	}
     drawSnake(mousePos.x, mousePos.y);
  }
  requestAnimationFrame(animate);
  }
}

function drawSnake(posX, posY) {
  //game over condition with color & border comparison. Head touching any color with 'b'(b of rgb) value 0f 255 is considered as terminating condition.
      if(p[2]==255||posX>canvas.width-2||posY>canvas.height-2)
      {
      ctx.fillStyle="white";
      ctx.fillRect(0, 0, canvas.width, canvas.height);       
      ctx.fillStyle="red";
      ctx.font="20px Georgia";
      ctx.fillText("Game Over!!",4*canvas.width/11,canvas.height/2-20);
      ctx.fillText("Score: "+score,4*canvas.width/11+10,canvas.height/2);
      ctx.fillText("Reload to play again!!",4*canvas.width/11-40,canvas.height/2+22);
      a=1;
      return 0;
      }  
      dragSegment(0, posX, posY);
      for(var i=0; i < x.length-1; i++) {
         dragSegment(i+1, x[i], y[i]);
      }  
}

function dragSegment(i,  xin,  yin) {
   dx = xin - x[i];
   dy = yin - y[i];
  //calculate inclination of co-ordinate system based on the gradient
   angle = Math.atan2(dy, dx);
  //set new origins
   x[i] = xin - Math.cos(angle) * segLength;
   y[i] = yin - Math.sin(angle) * segLength;
  
  ctx.save();
  ctx.translate(x[i], y[i]);
  ctx.rotate(angle);
  
  var segColor;
  
  // Generate funny colors
  
  segColor = segmentColorFunc(segColor, i, randColorPalette);
  
  drawLine(0, 0, segLength, 0, segColor, 10);
  
  ctx.restore();
}//draw segment




//Field for bellow function
var randColorPalette = Math.random()*10;
// var randColorPalette = 1.5;

//This number determines how many random colors are on the snek
//The +1 is to prevent 0 random colors
var xNumOfRandSegColors = Math.floor((Math.random()*15)+1);

//This is referenced for the 10 random colors mode
var XRandSegColorsArr = [];
    XRandSegColorsArr = generateXRandSegColors();

function generateRandSegCol() {
  
    //Generate a random red, blue, and green color.
    //I don't want a pure red, so 250 it is.
    var randRed = Math.random() * 250;
    var randGreen = Math.random() * 255;
    var randBlue = Math.random() * 255;
    
    //create the segment color
    var sColor = `rgba(${randRed}, ${randGreen}, ${randBlue}, 255)`;
    
    return sColor;
  
}//generateRandSegColor

function generateXRandSegColors(){
  
  var arr = [];
  
  for(var c = 0; c < xNumOfRandSegColors; c++){
    //generate the random color
    var sColor = generateRandSegCol();
    //push the color to the array
    arr.push(sColor);
  }//for c
  
  return arr;
  
}//generateXRandSegColors

//segment color function
function segmentColorFunc(segColor, i){
  
  //Rainbow!
  
  if(randColorPalette > 9){
    
    if(i==0)
  segColor="red";
  //orange
  else if (i % 7 == 1)
    segColor = "rgba(255, 150, 0, 255)";
  //yellow
  else if (i % 7 == 2)
    segColor = "rgba(255, 255, 0, 255)";
  //green
  else if (i % 7 == 3)
    segColor = "rgba(30, 255, 30, 255)";
  //cyan
  else if (i % 7 == 4)
    segColor = "rgba(0, 255, 255, 255)";
  //blue
  else if (i % 7 == 5)
    segColor = "rgba(50, 150, 255, 255)";
  //purple
  else if (i % 7 == 6)
    segColor = "rgba(170, 50, 255, 255)";
  //pink
  else
    segColor = "rgba(255, 100, 255, 255)";
    
  }else if(randColorPalette > 1 && randColorPalette < 9){
    
    if(i==0){
  segColor="red";
  //random snek colors!
    }else{
    //This line gets a color from the random array
    segColor = XRandSegColorsArr[(i % xNumOfRandSegColors)];
    }//if red or rand
    
  }else{
    
    if(i==0)
      //bluegray head
  // segColor="rgba(120, 120, 230, 255)";
  //Nope, a bluegray head can break the game
  //red
  segColor="red";
   //white
  else if (i % 6 == 1 || i % 5 == 3)
    segColor = "rgba(255, 255, 255, 255)";
  //blue
  else if (i % 6 == 2)
    segColor = "rgba(50, 100, 255, 255)";
  //gray
  else
    segColor = "rgba(100, 100, 100, 255)";
    
  }//if randColorPalette
  
  return segColor;
  
}//segmentColFunc



//increase array length when eats food
function changes(n){
	x[n-1] = x[n-2]+100;
	y[n-1] = y[n-2]+100;
}
//generate food at random location
function foodRandom(fx,fy){
      ctx.fillStyle="rgb(0,255,0)";
      ctx.fillRect(fx,fy,12,12);
}

function drawLine(x1, y1, x2, y2, color, width) {
  ctx.save();
  
  ctx.strokeStyle = color;
  ctx.lineWidth = width;
  
  ctx.beginPath();
  ctx.moveTo(x1, y1);
  ctx.lineTo(x2, y2);
  ctx.stroke();
  
  ctx.restore();
}

 

 

The code I added was something that would change the color palette of the snake. In this version, most of the time the code will generate x number of random colors between 1 and 15 (While rare I think you can get a solid colored snake)

 

image.png.3ca369dcb259a0381f2d5c52aab79d90.png

 

11 random colors

 

image.png.6baf241b0100206017040d1cc9534966.png

 

12 random colors

 

image.png.e24edf81db6ba0fa4c23d65158025635.png

 

6 random colors

 

Bonus sneks:

 

Spoiler

image.png.78cd159a496993a8a14f433c9378ba4a.png

 

Another 12

 

image.png.9690388df3235c7073d7b10e86c499fb.png

 

7 random colors

 

image.png.4590f0297d066113a488299635f037c5.png

 

15 random colors! It's the first time I got that!

 

Edited by Ranger

I'm Ranger, Gray's/Cat_ShadowGriffin's tulpa, and I love hippos! I also like cake and chatting about stuff. I'm not sure if I like Rosalind or Rosalin better, but you can call me Roz.

My other headmates have their own account now.

Temporary Log | Switching LogcBox | Yay! | Bre Translator

Link to comment
Share on other sites

Nice coding, I'm thinking about the idea of what it would be like to do something productive too

Hi! I'm Lumi, host of Reisen, Tewi, Flandre and Lucilyn.

Everyone deserves to love and be loved. It's human nature.

My tulpas and I have a Q&A thread, which was the first (and largest) of its kind. Feel free to ask us stuff.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...