Letti42Lvl 6
- Windows
can someone code something cool or like what happened
I'm actually so bored
I need someone to argue with
can someone code something cool or like what happened
I'm actually so bored
I need someone to argue with
lol yeah
ok heres something to argue about
what sandwich is the best, but dont says something basic like grilled cheese or pbj choose the most exotic sandwich youve ever had
Letti42 well i was working on a little something but technically i wanted @Mellow's opinion on it since it was technically their game in which i swap out the prompt for my updated highscore keyboard prompt that i never got to use though I'll probably need asset work to make the blank space look cooler which i have a few ideas in mind anyways here's the updated code for those who are interested https://studio.code.org/projects/gamelab/uocOU_kIa5hAv7k1AOComRexvUgZXKqEvAyuYoYyqfI/view if anyone has any suggestions I'm totally down to hear from anyone as it may or may not be apart of the trilogy project that i stitched together, (which apparently has fans that re upload it) that way it'll look nicer and not break the immersion as much
Here's pygame you can argue about
print("Python has begun running . . .")
#Imports
import time
import math
import pygame
import threading
import ctypes
from sys import exit
#pygame startup
pygame.init()
info = pygame.display.Info()
print(info)
screen = pygame.display.set_mode((info.current_w, info.current_h), pygame.RESIZABLE | pygame.DOUBLEBUF | pygame.HWSURFACE)
pygame.display.set_caption("Survivion")
pygame.display.set_icon(pygame.image.load("fg/assets/player.svg"))
clock = pygame.time.Clock()
#mouse setup
pygame.mouse.set_visible(False)
cursorImg = pygame.image.load("fg/assets/cursor.png")
#Classes and Functions
class Tmo:
def __init__(self):
self.timers = {}
self.timer_id = 0
def setTimeout(self, fn, delay, *args, **kwargs):
def timer_callback():
self.timers.pop(timer_id, None)
fn(*args, **kwargs)
timer_id = self.timer_id
self.timer_id += 1
t = threading.Timer(delay / 1000, timer_callback)
self.timers[timer_id] = t
t.start()
return timer_id
def clearTimeout(self, timer_id):
t = self.timers.pop(timer_id, None)
if t is not None:
t.cancel()
class Ints:
def __init__(self):
self.timers = {}
self.timer_id = 0
def setInterval(self, fn, time, *args):
def interval_callback():
fn(*args)
self.timers[timer_id] = threading.Timer(time, interval_callback)
self.timers[timer_id].start()
timer_id = self.timer_id
self.timer_id += 1
self.timers[timer_id] = threading.Timer(time, interval_callback)
self.timers[timer_id].start()
def clearInterval(self, fn):
for timer_id in self.timers:
if self.timers[timer_id].function == fn:
self.timers[timer_id].cancel()
del self.timers[timer_id]
break
tmo = Tmo()
ints = Ints()
class Stats:
def __init__(self):
self.clock = pygame.time.Clock()
self.font = pygame.font.Font("fg/fonts/LilitaOne.ttf", 20)
self.fps = 0
self.ms = self.font.render(f"{ms}ms", True, (255, 255, 255))
self.visible = True
def render(self, display):
self.fps = self.font.render(f"{round(self.clock.get_fps())}fps", True, (255, 255, 255))
if self.visible:
screen.blit(self.fps, (30, 15))
screen.blit(self.ms, (30, 45))
class Player(object):
def __init__(self):
self.width = 34
self.height = 30
self.x = (info.current_w/2) - self.width/2
self.y = (info.current_h/2) - self.height/2
self.keys = [False, False, False, False]
self.sprite = pygame.image.load('fg/assets/player.svg').convert_alpha()
self.sprite = pygame.transform.scale(self.sprite, (self.width, self.height))
self.movementSpeed = 1
self.rotation = 0
def update(self):
if (self.keys[0] and not self.keys[1]):
self.y -= self.movementSpeed
if (self.keys[1] and not self.keys[0]):
self.y += self.movementSpeed
if (self.keys[2] and not self.keys[3]):
self.x -= self.movementSpeed
if (self.keys[3] and not self.keys[2]):
self.x += self.movementSpeed
#Rotation towards mouse
angle = math.atan2(mouse["y"] - 16 - self.y + (self.height/2), mouse["x"] - self.x - 16 + (self.width/2))
self.rotation = angle;
degrees = math.degrees(self.rotation)
self.spriteR = pygame.transform.rotate(self.sprite, -degrees)
#THIS STEP IS VERY IMPORTANT. IT ANCHORS TO THE CENTER OF THE SPRITE, AND NOT THE TOP LEFT
sprite_rect = self.spriteR.get_rect(center=(self.x + self.width / 2, self.y + self.height / 2))
screen.blit(self.spriteR, sprite_rect)
def perform(self):
self.update()
class Background(object):
def __init__(self):
self.screen_width = info.current_w
self.screen_height = info.current_h
self.sprite = pygame.image.load('fg/assets/background.jpg').convert_alpha()
self.backgrounds = []
bg_width, bg_height = self.sprite.get_size()
for x in range(0, self.screen_width, bg_width):
for y in range(0, self.screen_height, bg_height):
self.backgrounds.append((x, y))
def perform(self):
for x, y in self.backgrounds:
screen.blit(self.sprite, (x, y))
def cursor(x, y):
screen.blit(cursorImg, (x, y))
#Variables
mouse = {
"x": 0,
"y": 0,
"holding": False
}
ms = 0
ds, de = 0, 0
stats = Stats()
#Sprites
background = Background()
player = Player()
#Loop
while True:
ds = pygame.time.get_ticks()
mouse["x"], mouse["y"] = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_w:
player.keys[0] = True
if event.key == pygame.K_s:
player.keys[1] = True
if event.key == pygame.K_a:
player.keys[2] = True
if event.key == pygame.K_d:
player.keys[3] = True
if event.type == pygame.KEYUP:
if event.key == pygame.K_w:
player.keys[0] = False
if event.key == pygame.K_s:
player.keys[1] = False
if event.key == pygame.K_a:
player.keys[2] = False
if event.key == pygame.K_d:
player.keys[3] = False
background.perform()
player.perform()
cursor(mouse["x"], mouse["y"])
de = pygame.time.get_ticks()
ms = abs(round(ds - de))
stats.render(screen)
pygame.display.update()
stats.clock.tick(65)
def calcMS():
self.ms = self.font.render(f"{ms}ms", True, (255, 255, 255))
ints.setInterval(calcMS, 0.5)
Letti42
working on a giant top down battle royale game, done with mechanics now adding content
will be out soon
person
get both(duh)
worst-case scenario, you can't finish the food so you have leftovers for the next day
my bank balance is $-10.40 im not buying both
Vietnamese is just so underrated at my school we did this sandwich bracket (thats why i asked you guys) and most kids hadent even heard of falafel, let alone the banh mi
okay so everyone's talking food. i believe that pho is also very good. spicy and yummy 😋
Blockyheadman
Don’t tell me ur one of those people who put so much siracha in their soup that it turns red
what-
ackvonhuelio oh hell nah. i don't put Sriracha in my pho at all. the way i had it was too good to have that in it
Flowey_the_Flower now you did you escape the underground? that or you have access to our internet. (i love undertale)