Skip to content

Instantly share code, notes, and snippets.

@Shurastei
Shurastei / adivinha_numerico
Last active December 18, 2020 01:06
Jogo da Advinhação
import random
def main():
# Iniciando
acima = 0
abaixo = 0
certo = 0
number = random.randint(1, 100)
@Shurastei
Shurastei / fractal_arvore
Created December 18, 2020 02:16
Tartaruguinha fractando uma arvorezinha
import turtle
turtle.shape("turtle")
turtle.speed(speed=1)
MINIMUM_BRANCH_LENGTH = 5
def build_tree(t, branch_length, shorten_by, angle):
if branch_length > MINIMUM_BRANCH_LENGTH:
t.forward(branch_length)
new_length = branch_length - shorten_by
@Shurastei
Shurastei / Tetris
Created December 18, 2020 05:13
Para jogar Tetris
import pygame
import random
# Tetris, na moralzinha ;)
colors = [
(0, 0, 0),
(120, 37, 179),
(100, 179, 179),
(80, 34, 22),
(80, 134, 22),
@Shurastei
Shurastei / Temperatura
Created December 22, 2020 00:10
Programa que peça a temperatura em graus Fahrenheit, transforme e mostre a temperatura em graus Celsius.
tc = float(input('Temperatura em Celsius: '))
print ('Temperatura em Fahrenheit: %.2f' %(9*tc/5 + 32))
@Shurastei
Shurastei / encurtar_url
Created December 23, 2020 15:00
Encurtar URL
import requests
api_key = "db495e6f05aacf29d13e7dae7e1c033e728e1"
# URL
url = "https://www.google.com"
# Name
api_url = f"https://cutt.ly/api/api.php?key={api_key}&short={url}"
# ou
# api_url = f"https://cutt.ly/api/api.php?key={api_key}&short={url}&name=some_unique_name"
# Request
@Shurastei
Shurastei / labirinto
Created December 23, 2020 15:55
Labirinto
from random import shuffle, randrange
def make_maze(w = 16, h = 8):
""" Cria um labirinto aleatório e o desenha na tela em ASCII Art
Parâmetros:
w - o número de colunas do labirinto (padrão: 16)
h - o número de linhas do labirinto (padrão: 8)
"""
# Matriz de células visitadas (0 = não visitada, 1 = visitada)
@Shurastei
Shurastei / pong
Created December 30, 2020 10:48
jogo clássico pong!
# pong!
import pygame
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
# Coordenadas p1, p2 and ball
x1 = 490
y1 = 250
x2 = 0
@Shurastei
Shurastei / connect4_python
Created December 31, 2020 02:38
Jogo Connect4
import numpy as np
import pygame
import sys
import math
BLUE = (0,0,255)
BLACK = (0,0,0)
RED = (255,0,0)
YELLOW = (255,255,0)
@Shurastei
Shurastei / jogodavelha
Created January 3, 2021 14:34
Jogo da Velha S2
#Jogo da Velha!
theBoard = {'7': ' ' , '8': ' ' , '9': ' ' ,
'4': ' ' , '5': ' ' , '6': ' ' ,
'1': ' ' , '2': ' ' , '3': ' ' }
board_keys = []
for key in theBoard:
board_keys.append(key)
@Shurastei
Shurastei / liga_pontos
Created January 17, 2021 10:40
Jogo do Liga Pontos
from tkinter import *
import numpy as np
size_of_board = 600
number_of_dots = 6
symbol_size = (size_of_board / 3 - size_of_board / 8) / 2
symbol_thickness = 50
dot_color = '#7BC043'
player1_color = '#0492CF'
player1_color_light = '#67B0CF'