Skip to content

Instantly share code, notes, and snippets.

View bashbaugh's full-sized avatar
🐟
writing cod

Benjamin Ashbaugh bashbaugh

🐟
writing cod
View GitHub Profile
// Ensure that player is within canvas:
player_x = Math.max(0, Math.min(player_x, canvas_element.width))
// Draw player:
canvas.beginPath(); // Start drawing
canvas.arc(player_x, player_y, player_radius, 0, 2*Math.PI); // Draw 360 degree arc (full circle)
canvas.fillStyle = player_color; // Set color
canvas.fill(); // Fill in circle
canvas.closePath(); // End drawing
// Draw score:
canvas.fillStyle = text_color; // set color
canvas.font = "20px Arial"; // set font and font size
canvas.fillText(score, 20, 20); // draw text
function update()
{
// Set current time (milliseconds):
let time_right_now = new Date().getTime()
if (time_right_now - start_time < game_duration)
{
// Compare player coordinates to dot coordinates to see whether the player is above a dot. Increment score if so.
// Check distance from highest dot to top of screen. If greater than dot_distance_apart, create a new dot at top.
function key_pressed(key)
{
... // arrow up block
if (key.key == "ArrowLeft")
{
console.log("left");
player_x -= player_move_increment // reduce player_move_increment, which moves player left
}
// If y distance is greater than dot_distance_apart
if (dots_y[dots_y.length - 1] > dot_distance_apart)
{
// Choose random new color:
let new_color = dot_color_options[Math.floor(Math.random()*dot_color_options.length)];
// Choose random new lane:
let lane_number = Math.floor(Math.random() * (canvas_element.width / player_move_increment + 1));
// Convert to new x position:
if (game_over)
{
canvas.fillStyle = text_color; // Set color
canvas.font = "45px Arial"; // Set font
canvas.fillText("Game Over", 80, 100); // Draw line one
canvas.fillText("Final Score: " + score.toString(), 60, 150); // Draw line two
}
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Game</title>
</head>
<body onload="init()">
<h1>JavaScript Game</h1>
<p>Here is a simple JavaScript game:</p>
<canvas id="c" width="400" height="400"></canvas>
@bashbaugh
bashbaugh / spambot.py
Created May 7, 2019 15:19
A simple discord bot that generates spam (strings of random characters) when a user types `$spamhere`.
# Spambot
# A simple discord bot that generates spam (strings of random characters) when a user types `$spamhere`.
# Written by Benjamin A
from time import sleep
import string
import random
import os
import logging
import discord
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hello.
Hello. This is to verify that key "C3DB053BD7019D22F131CB523D3B00ECAD828B54" is belongs to Benjamin Ashbaugh, user scitronboy, on github.
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEw9sFO9cBnSLxMctSPTsA7K2Ci1QFAlz1vM8ACgkQPTsA7K2C
i1TOrQ//X1KkupK/6o2iwdh7Qd3ZuIPJjyxg6QKcYSL8CFLDrM3FTCYZSJOhYBz8

This is the folder shortcut for the godmode control panel in Windows 10

To access the godmode control panel, create a new folder and immediately give it this name:

GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}