Add Hiragana image display grid to Japanese screen with scrolling

This commit is contained in:
2026-05-09 00:23:35 +02:00
parent 182eabf515
commit 2ab3aa60d2
+84 -2
View File
@@ -88,6 +88,10 @@ func main() {
currentScreen := ScreenMenu currentScreen := ScreenMenu
prevScreen := ScreenMenu prevScreen := ScreenMenu
// Japanese screen state
var japaneseTextures []rl.Texture2D
var imageStartY int32 = 0
// Main game loop // Main game loop
for !rl.WindowShouldClose() { for !rl.WindowShouldClose() {
// Get mouse position // Get mouse position
@@ -180,11 +184,89 @@ func main() {
} }
case ScreenJapanese: case ScreenJapanese:
rl.DrawText("Japanese Language Screen", screenWidth/2-140, screenHeight/2-20, 30, rl.Green) rl.DrawText("Hiragana Characters", 20, 20, 30, rl.Green)
rl.DrawText("Press ESC to return to menu", screenWidth/2-120, screenHeight/2+30, 20, rl.Black) rl.DrawText("Press ESC to return to menu", screenWidth-200, 20, 20, rl.Black)
// Load and display Hiragana images in a grid
imagePath := "japanese/images/"
hiraganaImages := []string{
"あ_a.png", "い_i.png", "う_u.png", "え_e.png", "お_o.png",
"か_ka.png", "き_ki.png", "く_ku.png", "け_ke.png", "こ_ko.png",
"さ_sa.png", "し_shi.png", "す_su.png", "せ_se.png", "そ_so.png",
"た_ta.png", "ち_chi.png", "つ_tsu.png", "て_te.png", "と_to.png",
"な_na.png", "に_ni.png", "ぬ_nu.png", "ね_ne.png", "の_no.png",
"は_ha.png", "ひ_hi.png", "ふ_fu.png", "へ_he.png", "ほ_ho.png",
"ま_ma.png", "み_mi.png", "む_mu.png", "め_me.png", "も_mo.png",
"や_ya.png", "ゆ_yu.png", "よ_yo.png",
"ら_ra.png", "り_ri.png", "る_ru.png", "れ_re.png", "ろ_ro.png",
"わ_wa.png", "ゐ_wi.png", "ゑ_we.png", "を_wo.png", "ん_n.png",
"が_ga.png", "ぎ_gi.png", "ぐ_gu.png", "げ_ge.png", "ご_go.png",
"ざ_za.png", "じ_ji.png", "ず_zu.png", "ぜ_ze.png", "ぞ_zo.png",
"だ_da.png", "ぢ_di.png", "づ_du.png", "で_de.png", "ど_do.png",
"ば_ba.png", "び_bi.png", "ぶ_bu.png", "べ_be.png", "ぼ_bo.png",
"ぱ_pa.png", "ぴ_pi.png", "ぷ_pu.png", "ぺ_pe.png", "ぽ_po.png",
}
// Grid layout
columns := 7
imageWidth := int32(64)
imageHeight := int32(64)
spacing := int32(10)
startX := int32(20)
startY := int32(60)
// Load images on first frame
if len(japaneseTextures) == 0 {
for _, imgName := range hiraganaImages {
texture := rl.LoadTexture(imagePath + imgName)
if texture != (rl.Texture2D{}) {
japaneseTextures = append(japaneseTextures, texture)
} else {
japaneseTextures = append(japaneseTextures, rl.Texture2D{})
}
}
}
// Draw images in grid
for i, texture := range japaneseTextures {
if texture.ID != 0 {
row := i / columns
col := i % columns
x := startX + int32(col)*(imageWidth+spacing)
y := startY + int32(row)*(imageHeight+spacing) - imageStartY
// Draw background for image
rl.DrawRectangle(x, y, imageWidth, imageHeight, rl.LightGray)
// Draw the texture
rl.DrawTexture(texture, int32(x), int32(y), rl.White)
// Draw border
rl.DrawRectangleLines(x, y, imageWidth, imageHeight, rl.Black)
}
}
// Handle scroll with mouse wheel
scroll := rl.GetMouseWheelMove()
if scroll != 0 {
imageStartY += int32(scroll) * 10
if imageStartY < 0 {
imageStartY = 0
}
}
if rl.IsKeyPressed(rl.KeyEscape) { if rl.IsKeyPressed(rl.KeyEscape) {
currentScreen = ScreenMenu currentScreen = ScreenMenu
// Unload textures when leaving
for _, tex := range japaneseTextures {
rl.UnloadTexture(tex)
}
japaneseTextures = nil
imageStartY = 0
} }
// Draw scroll hint
rl.DrawText("Use mouse wheel to scroll", screenWidth/2-100, screenHeight-30, 16, rl.Gray)
} }
// Draw FPS counter // Draw FPS counter