made sub level transitions a bit smoother

This commit is contained in:
JHDev2006
2025-09-20 19:09:34 +01:00
parent 99066de39b
commit 4cc6e938fc
11 changed files with 2839 additions and 2708 deletions

View File

@@ -7,6 +7,8 @@ var level_thumbnail = null
var level_id := ""
var thumbnail_url := ""
var ratings := []
var difficulty := "Easy"
var featured = false
@@ -38,10 +40,19 @@ func setup_visuals() -> void:
print(difficulty)
var difficulty_int = DIFFICULTY_TO_STAR_TRANSLATION[difficulty]
for i in %DifficultyStars.get_children():
i.region_rect.position.x = 24 if idx > difficulty_int else [0, 0, 8, 8, 16][difficulty_int]
i.region_rect.position.x = 32 if idx > difficulty_int else [0, 8, 8, 16, 24][difficulty_int]
idx += 1
setup_rating_stars()
get_thumbnail()
func setup_rating_stars() -> void:
var rating = calculate_rating()
var idx := 0
for i in %RatingStars.get_children():
i.region_rect.position.x = 16 if idx > rating else (0 if abs(idx - rating) >= 0.5 else 8)
idx += 1
func get_thumbnail() -> void:
if cached_thumbnails.has(level_id):
%LevelIcon.texture = cached_thumbnails[level_id]
@@ -53,6 +64,17 @@ func get_thumbnail() -> void:
return
$ThumbnailDownloader.request(thumbnail_url, [], HTTPClient.METHOD_GET)
func calculate_rating() -> int:
var rating := -1.0
var total := 0
if ratings.is_empty():
return 0
for i in ratings:
total += i
rating = total / float(ratings.size())
print(rating)
return rating
func on_request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray) -> void:
var image = Image.new()
if thumbnail_url.contains(".webp"):