abhivadan aur parichay kya hai iske prakar kaun kaun se Hain
Answers
Answer:
var goal1 = createSprite(200, 28,100,20);
goal1.shapeColor='yellow';
var goal2 = createSprite(200, 372,100,20);
goal2.shapeColor='yellow';
var player1= createSprite(200, 50,50,10);
player1.shapeColor='black';
var computer = createSprite(200, 350,50,10);
computer.shapeColor='black';
var stricker = createSprite(200, 200,10,10);
stricker.shapeColor=('red');
var line1 = createSprite(373, 390,1000,10);
line1.shapeColor=('white');
var line2 = createSprite(376, 7,10,1000);
line2.shapeColor=('white');
var line3 = createSprite(90, 10,1000,10);
line3.shapeColor=('white');
var line4 = createSprite(23, 5,10,1000);
line4.shapeColor=('white');
var gameState = "serve";
var computerscore = 0;
var player1score = 0;
function draw() {
background('green');
text(computerscore, 52, 217);
text( player1score, 53, 168);
createEdgeSprites();
stricker.bounceOff(line1);
stricker.bounceOff(line4);
stricker.bounceOff(line3);
stricker.bounceOff(line2);
stricker .bounceOff( computer );
stricker.bounceOff( player1);
//serve the ball when space is pressed
if (keyDown("space") && gameState === "serve") {
serve();
gameState = "play";
}
player1.x=World.mouseX;
computer.x=stricker.x;
if ( stricker.isTouching(goal1)||stricker.isTouching(goal2)) {
stricker .velocityX=0;
stricker.velocityY=0;
}
if ( stricker.isTouching(goal1)) {
computerscore=computerscore+1;
stricker .x=200;
stricker.y=200;
}
if ( stricker.isTouching(goal2)) {
player1score=player1score+1 ;
stricker .x=200;
stricker.y=200;
}
gameState='serve';
for (var i = 0; i < 400;i= i+20) {
line(i,200,i+10,200);
}
if (player1score===5||computerscore===5) {
gameState="over";
fill( "red")
text("gameover", 150, 160);
text("press R to restart",150, 180);
}
if (keyDown("r") && gameState === "over") { gameState = "serve";
computerscore = 0;
player1score = 0; }
drawSprites()}
function serve() {
stricker .velocityX = 3;
stricker.velocityY = 4;
please help me to put everything in class gamestate =PLAY
ang gamestate end
if the scor of computer paddle is5. then game state end and every thing should stop then is should restart plz help I have to submit my game to unity hub
the code are give to you can add and in your game state remember
if space is pressed the game should start only in gamestate play else in game state end it should restart from score 0