Nexclap

Rock Paper Scissors

This is a game of rock paper scissors with the CPU. The user is prompted to choose rock, paper, or scissor and then the CPU randomly selects one of the three. Afterwards the winner is outputted to the console. The main part of the code was the nested "if" statements to check for all the possible outcomes that could result between the user and the CPU.

var player1 = prompt("Choose Rock, Paper, or Scissors "); var x = Math.random(); if (x < 1/3){ x = "rock"; } else if(x <= 2/3) { x = "paper"; } else { x = "scissors"; } var result = function(a, b) { if(a === b) { return "It's a draw"; } if(a === "rock") { if(b === "scissors") { return "rock wins"; } else { return "paper wins"; } } if(a === "paper") { if(b === "rock") { return "paper wins"; } else { if(b === "scissors") { return "scissors wins"; } } if(a === "scissors") { if(b === "rock") { return "rock wins"; } else { if(b === "paper") { return "scissors wins"; } } } } }; console.log("Player1: " + player1); console.log("x: " + x); result(player1, x);

flappy bird

flappy bird re-created into pygame(python)WIP.

import pygame, sys from pygame.locals import * import random pygame.init() WHITE = (255,255,255) height_floor = 200 height_ceiling = 200 #backround backround = pygame.image.load('bg.jpg') backround = pygame.transform.scale(backround,(1000,600)) #player player = pygame.image.load('fat_bird.png') player = pygame.transform.scale(player,(75,75)) # bottom floor pipes_floor = pygame.image.load('Mario_pipe_bottom.png') pipes_floor = pygame.transform.scale(pipes_floor,(200,200)) # top floor pipes_top = pygame.image.load('Mario_pipe_top.png') pipes_top = pygame.transform.scale(pipes_top,(200,200)) myfont= pygame.font.SysFont("monospace",16) screen = pygame.display.set_mode((1000,600)) #player positions playerX = 200 playerY = 250 #pipe positions ceilingX = 600 ceilingY = 0 #floor floorX = 500 floorY = 500 #backround bgrX = 0 bgrY = 10 score = 0 # score/passing flag while True: pastpipe = False if floorX >= playerX: score += 15 #speed/keys keys = pygame.key.get_pressed() if keys[K_UP]: playerY -= 4 if playerY < 0: playerY += 4 if keys[K_DOWN]: playerY += 4 if playerY > 550: playerY -= 4 for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() #loops pipes if floorX < -50: floorX = 500 height = random.randint(200,4550) pipes_floor = pygame.transform.scale(pipes_floor,(200,height)) if ceilingX < -50: ceilingX = 500 height = random.randint(200,400) pipes_top = pygame.transform.scale(pipes_top,(200,height)) #collisions if (ceilingX <= playerX) and (ceilingX + height_ceiling >= playerX): if ((ceilingY + height_ceiling) > playerY): break #collisions if (floorX <= playerX + 75) and (floorX + height_floor >= playerX): if ((floorY + height_floor) > playerY) and (floorY < playerY + 75): break # how fast the player moves up and down ceilingX -= 5 floorX -= 5 #backround screen.blit(backround,(bgrX,bgrY)) scoreText = myfont.render('score:' + str(score), 2, (40,30,20)) screen.blit(scoreText,(850,50)) screen.blit(player,(playerX, playerY)) #pipes screen.blit(pipes_floor,(floorX,floorY)) screen.blit(pipes_top,(ceilingX,ceilingY)) #updates pygame.display.update()

DNA to RNA to Amino Acids to Protein

This program simulates the process which DNA turns into a protein. The DNA strand is hard-coded.

Announcements
  • Test Announcement from Nexclap

    Test message from nexclap - please ignore

    2023-02-13

  • Test message

    Test message from nexclap - please ignore

    2023-02-11

  • Test message

    Test message from nexclap - please ignore

    2023-02-11

  • View all