Hello,
I have to make a program that looks like car rev counter. When I press key on keyboard(later it will be accelerator pedal), i get feedback how long I have been holding specific key (w). Now I need to make the graphical part, that would show rev counter and would move needle depanding on duration of the press.
It should look something like this: https://previews.123rf.com/images/rastud...rgrund.jpg
"
Kind regards,
Mario
I have to make a program that looks like car rev counter. When I press key on keyboard(later it will be accelerator pedal), i get feedback how long I have been holding specific key (w). Now I need to make the graphical part, that would show rev counter and would move needle depanding on duration of the press.
It should look something like this: https://previews.123rf.com/images/rastud...rgrund.jpg
"
import time import pygame import os os.environ["SDL_VIDEO_CENTERED"] = "1" screen = pygame.display.set_mode((600, 600)) pygame.display.set_caption("Time") clock = pygame.time.Clock() pygame.init() clock = pygame.time.Clock() running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.quit() break if event.type == pygame.KEYDOWN: if event.key == pygame.K_w: t = time.time() if event.type == pygame.KEYUP: if event.key == pygame.K_w: t = time.time() - t; t = str(t); t = t[:5] print("You are doing" ,t," rpm.") screen.fill((255, 255, 255)) pygame.display.update() clock.tick(40) import tkinter as tk import math class Point: def __init__(self, x=0, y=0): self.x = x self.y = y"
Kind regards,
Mario