Change speeds, make better color changes for Auto Mode
This commit is contained in:
1 parent
347d4d7215
commit
4b0b013b01
1 file changed
+30
-10
+30
-10
@@ -1,13 +1,16 @@
|
|||||||
import requests
|
import requests
|
||||||
import os
|
import os
|
||||||
import pygame
|
|
||||||
import random
|
import random
|
||||||
import shutil
|
import shutil
|
||||||
from sys import exit
|
from sys import exit
|
||||||
|
|
||||||
|
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
|
||||||
|
|
||||||
|
import pygame
|
||||||
|
|
||||||
version_num = 1
|
version_num = 1
|
||||||
|
|
||||||
app_folder = os.path.join(os.environ['APPDATA'].replace("\\", "/"), "Foodie Dash")
|
app_folder = os.path.join(os.environ['APPDATA'], "Foodie Dash")
|
||||||
resources_folder = os.path.join(app_folder, "Resources")
|
resources_folder = os.path.join(app_folder, "Resources")
|
||||||
|
|
||||||
icon_path = f"{resources_folder}/icon_{version_num}.png"
|
icon_path = f"{resources_folder}/icon_{version_num}.png"
|
||||||
@@ -57,11 +60,11 @@ COLOR = (141, 103, 216)
|
|||||||
|
|
||||||
player_width = 128
|
player_width = 128
|
||||||
player_height = 128
|
player_height = 128
|
||||||
player_speed = 30
|
player_speed = 15
|
||||||
|
|
||||||
food_width = 128
|
food_width = 128
|
||||||
food_height = 128
|
food_height = 128
|
||||||
food_speed = 15
|
food_speed = 8
|
||||||
|
|
||||||
player_hitbox_width = 128
|
player_hitbox_width = 128
|
||||||
player_hitbox_height = 128
|
player_hitbox_height = 128
|
||||||
@@ -105,6 +108,8 @@ eat_sound_channel = pygame.mixer.Channel(2)
|
|||||||
|
|
||||||
flipped = False
|
flipped = False
|
||||||
|
|
||||||
|
gradient_progress = 0.0
|
||||||
|
|
||||||
def should_change_color():
|
def should_change_color():
|
||||||
global auto_color_change_timer
|
global auto_color_change_timer
|
||||||
current_time = pygame.time.get_ticks()
|
current_time = pygame.time.get_ticks()
|
||||||
@@ -113,8 +118,11 @@ def should_change_color():
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def lerp(start, end, t):
|
||||||
|
return int(start + (end - start) * t)
|
||||||
|
|
||||||
def COLORraw_window():
|
def COLORraw_window():
|
||||||
global red, green, blue
|
global red, green, blue, gradient_progress
|
||||||
|
|
||||||
window.fill((30, 30, 30))
|
window.fill((30, 30, 30))
|
||||||
|
|
||||||
@@ -128,18 +136,30 @@ def COLORraw_window():
|
|||||||
if score != "Auto":
|
if score != "Auto":
|
||||||
score_text = font.render("Points: " + str(score), True, COLOR)
|
score_text = font.render("Points: " + str(score), True, COLOR)
|
||||||
else:
|
else:
|
||||||
if should_change_color():
|
if gradient_progress < 0.333:
|
||||||
red = random.randint(0, 255)
|
red = lerp(255, 0, gradient_progress * 3)
|
||||||
green = random.randint(0, 255)
|
green = lerp(0, 255, gradient_progress * 3)
|
||||||
blue = random.randint(0, 255)
|
blue = 0
|
||||||
|
elif gradient_progress < 0.666:
|
||||||
|
red = 0
|
||||||
|
green = lerp(255, 0, (gradient_progress - 0.333) * 3)
|
||||||
|
blue = lerp(0, 255, (gradient_progress - 0.333) * 3)
|
||||||
|
else:
|
||||||
|
red = lerp(0, 255, (gradient_progress - 0.666) * 3)
|
||||||
|
green = 0
|
||||||
|
blue = lerp(255, 0, (gradient_progress - 0.666) * 3)
|
||||||
|
|
||||||
|
gradient_progress += 0.00025
|
||||||
|
if gradient_progress >= 1.0:
|
||||||
|
gradient_progress = 0.0
|
||||||
|
|
||||||
score_text = font.render("Auto Mode", True, (red, green, blue))
|
score_text = font.render("Auto Mode", True, (red, green, blue))
|
||||||
|
|
||||||
score_rect = score_text.get_rect(center=(WIDTH // 2, 50))
|
score_rect = score_text.get_rect(center=(WIDTH // 2, 50))
|
||||||
window.blit(score_text, score_rect)
|
window.blit(score_text, score_rect)
|
||||||
|
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
|
|
||||||
|
|
||||||
def check_collision():
|
def check_collision():
|
||||||
player_hitbox = pygame.Rect(player_x, player_y, player_hitbox_width, player_hitbox_height)
|
player_hitbox = pygame.Rect(player_x, player_y, player_hitbox_width, player_hitbox_height)
|
||||||
food_hitbox = pygame.Rect(food_x, food_y, food_hitbox_width, food_hitbox_height)
|
food_hitbox = pygame.Rect(food_x, food_y, food_hitbox_width, food_hitbox_height)
|
||||||
|
|||||||
Reference in new issue
Block a user