sunbal7 commited on
Commit
d4f137e
Β·
verified Β·
1 Parent(s): 31a11ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -343
app.py CHANGED
@@ -173,35 +173,6 @@ st.markdown("""
173
  width: 100%;
174
  margin-top: 10px;
175
  }
176
-
177
- .real-world-card {
178
- background: rgba(255, 255, 255, 0.85);
179
- border-radius: 15px;
180
- padding: 1.5rem;
181
- margin: 1rem 0;
182
- box-shadow: 0 4px 8px rgba(0,0,0,0.1);
183
- border-left: 5px solid #4caf50;
184
- }
185
-
186
- .age-group {
187
- background: #ff9800;
188
- color: white;
189
- border-radius: 20px;
190
- padding: 0.5rem 1rem;
191
- display: inline-block;
192
- font-weight: bold;
193
- margin: 0.5rem 0;
194
- }
195
-
196
- .problem-solver-badge {
197
- background: #9c27b0;
198
- color: white;
199
- border-radius: 10px;
200
- padding: 0.5rem;
201
- font-size: 0.9rem;
202
- display: inline-block;
203
- margin: 0.2rem;
204
- }
205
  </style>
206
  """, unsafe_allow_html=True)
207
 
@@ -273,15 +244,6 @@ def generate_sprite_animation(story, character="spaceship", theme="space", num_f
273
  elif theme == "medieval":
274
  bg_color = (139, 69, 19)
275
  star_color = None
276
- elif theme == "ocean":
277
- bg_color = (0, 105, 148)
278
- star_color = None
279
- elif theme == "city":
280
- bg_color = (70, 70, 70)
281
- star_color = None
282
- elif theme == "farm":
283
- bg_color = (139, 195, 74)
284
- star_color = None
285
  else:
286
  bg_color = (0, 0, 30)
287
  star_color = (255, 255, 255)
@@ -342,42 +304,6 @@ def generate_sprite_animation(story, character="spaceship", theme="space", num_f
342
  # Draw sword swing
343
  draw.line([(knight_x+25, knight_y+12), (knight_x+45, knight_y-10)], fill=(255, 255, 0), width=2)
344
 
345
- elif character == "eco-robot":
346
- robot_x = 50 + i * 40
347
- robot_y = 120
348
- # Draw robot body
349
- draw.rectangle([robot_x, robot_y, robot_x+30, robot_y+40], fill=(100, 100, 200))
350
- # Draw robot head
351
- draw.ellipse([robot_x+5, robot_y-10, robot_x+25, robot_y+10], fill=(200, 200, 200))
352
- # Draw arm
353
- draw.rectangle([robot_x+30, robot_y+10, robot_x+40, robot_y+20], fill=(100, 100, 200))
354
- # Draw planting tool
355
- if "plant" in story.lower() and i > 0:
356
- draw.ellipse([robot_x+40, robot_y+5, robot_x+50, robot_y+15], fill=(34, 139, 34))
357
-
358
- elif character == "submarine":
359
- sub_x = 50 + i * 40
360
- sub_y = 100
361
- # Draw submarine body
362
- draw.ellipse([sub_x, sub_y, sub_x+50, sub_y+20], fill=(100, 149, 237))
363
- # Draw top
364
- draw.rectangle([sub_x+15, sub_y-10, sub_x+35, sub_y], fill=(100, 149, 237))
365
- # Draw light
366
- if "collect" in story.lower() and i > 1:
367
- draw.ellipse([sub_x+50, sub_y+5, sub_x+70, sub_y+15], fill=(255, 255, 0))
368
-
369
- elif character == "drone":
370
- drone_x = 50 + i * 40
371
- drone_y = 80
372
- # Draw drone body
373
- draw.ellipse([drone_x, drone_y, drone_x+30, drone_y+15], fill=(169, 169, 169))
374
- # Draw propellers
375
- draw.rectangle([drone_x-5, drone_y-5, drone_x+5, drone_y+20], fill=(100, 100, 100))
376
- draw.rectangle([drone_x+25, drone_y-5, drone_x+35, drone_y+20], fill=(100, 100, 100))
377
- # Draw package
378
- if "deliver" in story.lower() and i > 0:
379
- draw.rectangle([drone_x+10, drone_y+15, drone_x+20, drone_y+25], fill=(255, 0, 0))
380
-
381
  # Draw enemies based on theme
382
  if theme == "space" and "alien" in story.lower():
383
  alien_x = 200
@@ -399,26 +325,6 @@ def generate_sprite_animation(story, character="spaceship", theme="space", num_f
399
  draw.ellipse([dragon_x, dragon_y, dragon_x+40, dragon_y+20], fill=(178, 34, 34))
400
  draw.line([(dragon_x+40, dragon_y+10), (dragon_x+60, dragon_y)], fill=(178, 34, 34), width=3)
401
 
402
- elif theme == "ocean" and "plastic" in story.lower():
403
- plastic_x = 200
404
- plastic_y = 100 - i*5
405
- draw.rectangle([plastic_x, plastic_y, plastic_x+15, plastic_y+20], fill=(255, 255, 100, 128))
406
- if i > 1:
407
- draw.rectangle([plastic_x+30, plastic_y+10, plastic_x+45, plastic_y+25], fill=(200, 100, 200, 128))
408
-
409
- elif theme == "city" and "tree" in story.lower():
410
- tree_x = 200
411
- tree_y = 150 - i*5
412
- draw.rectangle([tree_x, tree_y, tree_x+10, tree_y+30], fill=(139, 69, 19))
413
- draw.ellipse([tree_x-15, tree_y-10, tree_x+25, tree_y+20], fill=(34, 139, 34))
414
-
415
- elif theme == "farm" and "crop" in story.lower():
416
- crop_x = 200
417
- crop_y = 150
418
- for j in range(3):
419
- offset = j * 20
420
- draw.rectangle([crop_x+offset, crop_y, crop_x+offset+5, crop_y+20], fill=(34, 139, 34))
421
-
422
  frames.append(img)
423
 
424
  return frames
@@ -470,9 +376,7 @@ ACHIEVEMENTS = {
470
  "code_master": {"name": "Code Master", "icon": "πŸ’»", "description": "Used 5 different coding concepts"},
471
  "animator": {"name": "Animator", "icon": "🎬", "description": "Created 3 animations"},
472
  "voice_artist": {"name": "Voice Artist", "icon": "🎀", "description": "Used text-to-speech feature"},
473
- "character_designer": {"name": "Character Designer", "icon": "πŸ‘Ύ", "description": "Created a custom character"},
474
- "problem_solver": {"name": "Problem Solver", "icon": "🌍", "description": "Solved a real-world challenge"},
475
- "eco_hero": {"name": "Eco Hero", "icon": "🌱", "description": "Completed an environmental challenge"}
476
  }
477
 
478
  def unlock_achievement(achievement_id):
@@ -483,90 +387,10 @@ def unlock_achievement(achievement_id):
483
  return True
484
  return False
485
 
486
- # Age-appropriate settings
487
- AGE_SETTINGS = {
488
- "5-7": {
489
- "max_story_length": 50,
490
- "concepts": ["move", "jump", "collect"],
491
- "challenges": ["Clean the park", "Feed the animals"],
492
- "voice_speed": "slow"
493
- },
494
- "8-10": {
495
- "max_story_length": 100,
496
- "concepts": ["move", "collect", "avoid", "score"],
497
- "challenges": ["Recycle waste", "Plant trees"],
498
- "voice_speed": "normal"
499
- },
500
- "11-13": {
501
- "max_story_length": 200,
502
- "concepts": ["move", "collect", "avoid", "solve", "build"],
503
- "challenges": ["Stop pollution", "Build a community garden"],
504
- "voice_speed": "fast"
505
- }
506
- }
507
-
508
- # Real-world problem scenarios
509
- REAL_WORLD_PROBLEMS = [
510
- {
511
- "title": "🌱 Plant Trees in the City",
512
- "description": "Help the community plant trees to clean the air!",
513
- "story": "The eco-robot plants trees in empty lots around the city to fight pollution.",
514
- "coding_concept": "Loops and placement",
515
- "age_groups": ["8-10", "11-13"],
516
- "character": "eco-robot",
517
- "theme": "city"
518
- },
519
- {
520
- "title": "♻️ Clean the Ocean",
521
- "description": "Collect plastic waste from the ocean to save marine life!",
522
- "story": "The submarine robot collects plastic bags and bottles from the ocean.",
523
- "coding_concept": "Collection and counters",
524
- "age_groups": ["5-7", "8-10"],
525
- "character": "submarine",
526
- "theme": "ocean"
527
- },
528
- {
529
- "title": "πŸ₯ Deliver Medicine",
530
- "description": "Transport medicine to people in remote villages!",
531
- "story": "The drone flies over mountains to deliver medicine to sick people.",
532
- "coding_concept": "Pathfinding and obstacles",
533
- "age_groups": ["11-13"],
534
- "character": "drone",
535
- "theme": "medieval"
536
- },
537
- {
538
- "title": "🌦️ Predict the Weather",
539
- "description": "Help farmers prepare for changing weather conditions!",
540
- "story": "The weather robot analyzes clouds and temperature to predict rain.",
541
- "coding_concept": "Conditional logic",
542
- "age_groups": ["8-10", "11-13"],
543
- "character": "spaceship",
544
- "theme": "farm"
545
- },
546
- {
547
- "title": "🦸 Superhero Cleanup",
548
- "description": "Clean up the park to make it safe for everyone!",
549
- "story": "The superhero robot collects trash from the park playground.",
550
- "coding_concept": "Movement and collection",
551
- "age_groups": ["5-7"],
552
- "character": "knight",
553
- "theme": "city"
554
- },
555
- {
556
- "title": "🐼 Feed Hungry Animals",
557
- "description": "Help feed animals in the forest sanctuary!",
558
- "story": "The animal helper delivers food to hungry pandas and monkeys.",
559
- "coding_concept": "Delivery paths",
560
- "age_groups": ["5-7"],
561
- "character": "dragon",
562
- "theme": "jungle"
563
- }
564
- ]
565
-
566
  # Header section
567
  st.markdown('<div class="header">CodeTales ✨</div>', unsafe_allow_html=True)
568
  st.markdown('<div class="subheader">Storytime + Coding Magic</div>', unsafe_allow_html=True)
569
- st.markdown('<div style="text-align:center; color:white; font-size:1.2rem; margin-bottom:2rem;">Turn wild stories into playable games while solving real-world problems!</div>', unsafe_allow_html=True)
570
 
571
  # How it works section
572
  with st.expander("✨ How It Works (Like Baking a Cake) πŸŽ‚"):
@@ -583,10 +407,7 @@ with st.expander("✨ How It Works (Like Baking a Cake) πŸŽ‚"):
583
  **4. Robot Teacher Explains πŸ€–**
584
  Tavus shows: *"See? 'spaceship.move_right()' makes it fly! That's coding!"*
585
 
586
- **5. Solve Real Problems 🌍**
587
- Help clean oceans, plant trees, and more!
588
-
589
- **6. Level Up! πŸ†**
590
  Earn achievements as you learn and create!
591
  """)
592
 
@@ -622,85 +443,23 @@ if 'voice_enabled' not in st.session_state:
622
  st.session_state.voice_enabled = False
623
  if 'custom_character' not in st.session_state:
624
  st.session_state.custom_character = None
625
- if 'age_group' not in st.session_state:
626
- st.session_state.age_group = "8-10" # Default age group
627
- if 'selected_problem' not in st.session_state:
628
- st.session_state.selected_problem = None
629
 
630
  # Story templates
631
  story_templates = {
632
  "None": "",
633
  "Space Adventure": "A brave spaceship zooms through space, shooting lasers at alien spaceships!",
634
  "Dragon Quest": "A knight fights a fire-breathing dragon to save the princess in the castle.",
635
- "Jungle Explorer": "An explorer runs through the jungle, jumping over snakes and swinging on vines.",
636
- "Real-World Challenge": "Select a challenge from below!"
637
  }
638
 
639
- # Age group selection in sidebar
640
- st.sidebar.markdown("## πŸ‘Ά Age Group Selection")
641
- new_age_group = st.sidebar.radio(
642
- "Select age group for content:",
643
- ["5-7", "8-10", "11-13"],
644
- index=["5-7", "8-10", "11-13"].index(st.session_state.age_group)
645
- )
646
- if new_age_group != st.session_state.age_group:
647
- st.session_state.age_group = new_age_group
648
- st.session_state.animation_generated = False
649
- st.rerun()
650
-
651
- # Display age group information
652
- settings = AGE_SETTINGS[st.session_state.age_group]
653
- st.sidebar.markdown(f"### Age Group: **{st.session_state.age_group}**")
654
- st.sidebar.markdown(f"**Concepts Taught:**")
655
- for concept in settings["concepts"]:
656
- st.sidebar.markdown(f"- {concept.capitalize()}")
657
- st.sidebar.markdown(f"**Real-World Problems:**")
658
- for challenge in settings["challenges"]:
659
- st.sidebar.markdown(f"- {challenge}")
660
-
661
- # Real-world problem solver section
662
- st.markdown("## 🌍 Real-World Problem Solver")
663
- st.markdown("Help solve real-world challenges with coding!")
664
-
665
- # Display problem cards in columns
666
- prob_cols = st.columns(2)
667
- for i, problem in enumerate(REAL_WORLD_PROBLEMS):
668
- if st.session_state.age_group in problem["age_groups"]:
669
- with prob_cols[i % 2]:
670
- st.markdown(f'<div class="real-world-card">', unsafe_allow_html=True)
671
- st.markdown(f"### {problem['title']}")
672
- st.markdown(problem["description"])
673
- st.markdown(f"**Coding Concept:** {problem['coding_concept']}")
674
- st.markdown(f"**Age Groups:** {', '.join(problem['age_groups'])}")
675
-
676
- if st.button(f"Select {problem['title'].split()[-1]} Challenge",
677
- key=f"prob_{i}",
678
- use_container_width=True,
679
- help=f"Use this challenge for {st.session_state.age_group} year olds"):
680
- st.session_state.selected_problem = problem
681
- st.session_state.story_text = problem["story"]
682
- st.session_state.selected_character = problem["character"]
683
- st.session_state.selected_theme = problem["theme"]
684
- st.rerun()
685
-
686
- st.markdown('</div>', unsafe_allow_html=True)
687
-
688
  # Main content
689
- st.markdown(f'<div class="level-indicator">Level {st.session_state.level} ✨ XP: {st.session_state.xp}/100 | Age Group: {st.session_state.age_group}</div>', unsafe_allow_html=True)
690
  progress = st.progress(st.session_state.xp / 100)
691
 
692
  col1, col2 = st.columns([1, 1])
693
 
694
  with col1:
695
  st.markdown('<div class="story-box">', unsafe_allow_html=True)
696
-
697
- # Show selected problem
698
- if st.session_state.selected_problem:
699
- problem = st.session_state.selected_problem
700
- st.markdown(f"### 🌟 Selected Challenge: {problem['title']}")
701
- st.info(f"**Your Mission:** {problem['description']}")
702
- st.markdown(f"**Story Starter:** {problem['story']}")
703
-
704
  st.markdown("### πŸ“– Write Your Story Here:")
705
 
706
  # Story template selector
@@ -724,14 +483,11 @@ with col1:
724
  characters = {
725
  "spaceship": "πŸš€ Spaceship",
726
  "dragon": "πŸ‰ Dragon",
727
- "knight": "πŸ›‘οΈ Knight",
728
- "eco-robot": "πŸ€– Eco-Robot",
729
- "submarine": "🚀 Submarine",
730
- "drone": "🚁 Drone"
731
  }
732
 
733
  for i, (char_key, char_label) in enumerate(characters.items()):
734
- with char_cols[i % 3]:
735
  if st.button(
736
  char_label,
737
  key=f"char_{char_key}",
@@ -746,14 +502,11 @@ with col1:
746
  themes = {
747
  "space": "🌌 Space",
748
  "jungle": "🌿 Jungle",
749
- "medieval": "🏰 Medieval",
750
- "ocean": "🌊 Ocean",
751
- "city": "πŸ™οΈ City",
752
- "farm": "🚜 Farm"
753
  }
754
 
755
  for i, (theme_key, theme_label) in enumerate(themes.items()):
756
- with theme_cols[i % 3]:
757
  if st.button(
758
  theme_label,
759
  key=f"theme_{theme_key}",
@@ -800,11 +553,6 @@ with col1:
800
  if st.session_state.story_count == 1:
801
  unlock_achievement("first_story")
802
 
803
- if st.session_state.selected_problem:
804
- unlock_achievement("problem_solver")
805
- if "clean" in st.session_state.selected_problem["title"].lower() or "eco" in st.session_state.selected_problem["title"].lower():
806
- unlock_achievement("eco_hero")
807
-
808
  # Generate speech if enabled
809
  if st.session_state.voice_enabled:
810
  st.session_state.speech_data = text_to_speech(st.session_state.code_explanation)
@@ -889,19 +637,9 @@ if st.session_state.animation_generated and st.session_state.story_text:
889
  st.markdown('<div class="robot-speech">', unsafe_allow_html=True)
890
  st.markdown("### πŸ€– Tavus the Robot Teacher says:")
891
 
892
- # Real-world connection
893
- if st.session_state.selected_problem:
894
- problem = st.session_state.selected_problem
895
- st.markdown(f"### 🌍 Solving Real-World Problems")
896
- st.markdown(f"**We're working on:** {problem['title']}")
897
- st.markdown(f"**How coding helps:** {problem['description']}")
898
- st.markdown(f"**Coding concept used:** `{problem['coding_concept']}`")
899
- st.markdown("---")
900
-
901
  # Extract action words from story
902
  action_words = ["zoom", "shoot", "fly", "move", "jump", "run", "attack", "laser", "alien", "spaceship",
903
- "dragon", "fire", "hero", "sword", "castle", "run", "escape", "fight", "win", "plant",
904
- "collect", "clean", "deliver", "help", "save", "predict", "recycle"]
905
  found_actions = [word for word in action_words if word in st.session_state.story_text.lower()]
906
 
907
  if found_actions:
@@ -961,30 +699,6 @@ if st.session_state.animation_generated and st.session_state.story_text:
961
  elif action == "win":
962
  explanations.append("creates victory conditions!")
963
  code_snippets.append("if player.score > 100: show_victory_screen()")
964
- elif action == "plant":
965
- explanations.append("helps grow new trees and plants!")
966
- code_snippets.append("eco_robot.plant_tree(position)")
967
- elif action == "collect":
968
- explanations.append("gathers important items!")
969
- code_snippets.append("plastic = submarine.collect_trash()")
970
- elif action == "clean":
971
- explanations.append("makes the environment better!")
972
- code_snippets.append("park.clean_area()")
973
- elif action == "deliver":
974
- explanations.append("transports important items to people in need!")
975
- code_snippets.append("drone.deliver_package(location)")
976
- elif action == "help":
977
- explanations.append("makes the world a better place!")
978
- code_snippets.append("character.help_others()")
979
- elif action == "save":
980
- explanations.append("protects people and animals!")
981
- code_snippets.append("hero.save_endangered_animal()")
982
- elif action == "predict":
983
- explanations.append("uses data to forecast the future!")
984
- code_snippets.append("weather = analyze_data(temperature, clouds)")
985
- elif action == "recycle":
986
- explanations.append("reuses materials to protect the environment!")
987
- code_snippets.append("eco_robot.sort_recycling()")
988
 
989
  st.markdown("See how your story became real code? Here's what happened:")
990
 
@@ -1052,59 +766,18 @@ character.jump(20)
1052
  st.success("+5 XP! Character jumped!")
1053
 
1054
  with challenge_cols[2]:
1055
- st.markdown("#### Challenge 3: The Helper")
1056
  st.code("""
1057
- # Make the character help someone
1058
- character.help_person()
1059
  """)
1060
  if st.button("Run Challenge 3", key="challenge3"):
1061
  st.session_state.xp += 5
1062
- st.success("+5 XP! Character helped someone!")
1063
-
1064
- # Real-world coding skills section
1065
- st.markdown("## πŸ› οΈ Real-World Coding Skills You're Learning")
1066
- skill_cols = st.columns(4)
1067
- with skill_cols[0]:
1068
- st.markdown("### πŸ” Problem Analysis")
1069
- st.markdown("Breaking big problems into smaller steps")
1070
- st.markdown('<span class="problem-solver-badge">Age 5-13</span>', unsafe_allow_html=True)
1071
-
1072
- with skill_cols[1]:
1073
- st.markdown("### 🧩 Logical Thinking")
1074
- st.markdown("Creating step-by-step solutions")
1075
- st.markdown('<span class="problem-solver-badge">Age 5-13</span>', unsafe_allow_html=True)
1076
-
1077
- with skill_cols[2]:
1078
- st.markdown("### ♻️ Systems Thinking")
1079
- st.markdown("Understanding how things connect")
1080
- st.markdown('<span class="problem-solver-badge">Age 8-13</span>', unsafe_allow_html=True)
1081
-
1082
- with skill_cols[3]:
1083
- st.markdown("### πŸ’‘ Creative Solutions")
1084
- st.markdown("Inventing new ways to solve problems")
1085
- st.markdown('<span class="problem-solver-badge">Age 5-13</span>', unsafe_allow_html=True)
1086
-
1087
- # Age-specific features section
1088
- st.markdown("## πŸ‘§πŸ‘¦ Age-Appropriate Learning")
1089
- age_cols = st.columns(3)
1090
- with age_cols[0]:
1091
- st.markdown("### 5-7 Years")
1092
- st.markdown("- Simple cause & effect\n- Basic movement\n- Colorful animations\n- Voice explanations\n- Collecting items")
1093
- st.markdown("**Real-World Focus:**\nHelping animals, cleaning up")
1094
-
1095
- with age_cols[1]:
1096
- st.markdown("### 8-10 Years")
1097
- st.markdown("- Problem-solving basics\n- Simple conditionals\n- Scoring systems\n- Resource management\n- Basic physics")
1098
- st.markdown("**Real-World Focus:**\nRecycling, planting, community help")
1099
-
1100
- with age_cols[2]:
1101
- st.markdown("### 11-13 Years")
1102
- st.markdown("- Advanced logic\n- Variables & functions\n- Pathfinding\n- Complex systems\n- Data concepts")
1103
- st.markdown("**Real-World Focus:**\nEnvironmental protection, delivery systems, prediction")
1104
 
1105
  # Benefits section
1106
  st.markdown("""
1107
- ## ❀ Love CodeTales
1108
 
1109
  | For Kids πŸ‘§πŸ‘¦ | For Parents & Teachers πŸ‘ͺπŸ‘©β€πŸ« |
1110
  |--------------|----------------------------|
@@ -1115,7 +788,6 @@ st.markdown("""
1115
  | 🌟 100% private with no API keys | πŸ’° Completely free and open-source |
1116
  | πŸ† Achievement system motivates learning | πŸ“ˆ Progress tracking shows growth |
1117
  | πŸ—£οΈ Voice explanations for accessibility | 🎨 Creative expression through stories |
1118
- | 🌍 Solves real-world problems | 🌱 Teaches environmental awareness |
1119
  """)
1120
 
1121
  # Footer
 
173
  width: 100%;
174
  margin-top: 10px;
175
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  </style>
177
  """, unsafe_allow_html=True)
178
 
 
244
  elif theme == "medieval":
245
  bg_color = (139, 69, 19)
246
  star_color = None
 
 
 
 
 
 
 
 
 
247
  else:
248
  bg_color = (0, 0, 30)
249
  star_color = (255, 255, 255)
 
304
  # Draw sword swing
305
  draw.line([(knight_x+25, knight_y+12), (knight_x+45, knight_y-10)], fill=(255, 255, 0), width=2)
306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  # Draw enemies based on theme
308
  if theme == "space" and "alien" in story.lower():
309
  alien_x = 200
 
325
  draw.ellipse([dragon_x, dragon_y, dragon_x+40, dragon_y+20], fill=(178, 34, 34))
326
  draw.line([(dragon_x+40, dragon_y+10), (dragon_x+60, dragon_y)], fill=(178, 34, 34), width=3)
327
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  frames.append(img)
329
 
330
  return frames
 
376
  "code_master": {"name": "Code Master", "icon": "πŸ’»", "description": "Used 5 different coding concepts"},
377
  "animator": {"name": "Animator", "icon": "🎬", "description": "Created 3 animations"},
378
  "voice_artist": {"name": "Voice Artist", "icon": "🎀", "description": "Used text-to-speech feature"},
379
+ "character_designer": {"name": "Character Designer", "icon": "πŸ‘Ύ", "description": "Created a custom character"}
 
 
380
  }
381
 
382
  def unlock_achievement(achievement_id):
 
387
  return True
388
  return False
389
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
390
  # Header section
391
  st.markdown('<div class="header">CodeTales ✨</div>', unsafe_allow_html=True)
392
  st.markdown('<div class="subheader">Storytime + Coding Magic</div>', unsafe_allow_html=True)
393
+ st.markdown('<div style="text-align:center; color:white; font-size:1.2rem; margin-bottom:2rem;">Turn wild stories into playable games with open-source AI magic!</div>', unsafe_allow_html=True)
394
 
395
  # How it works section
396
  with st.expander("✨ How It Works (Like Baking a Cake) πŸŽ‚"):
 
407
  **4. Robot Teacher Explains πŸ€–**
408
  Tavus shows: *"See? 'spaceship.move_right()' makes it fly! That's coding!"*
409
 
410
+ **5. Level Up! πŸ†**
 
 
 
411
  Earn achievements as you learn and create!
412
  """)
413
 
 
443
  st.session_state.voice_enabled = False
444
  if 'custom_character' not in st.session_state:
445
  st.session_state.custom_character = None
 
 
 
 
446
 
447
  # Story templates
448
  story_templates = {
449
  "None": "",
450
  "Space Adventure": "A brave spaceship zooms through space, shooting lasers at alien spaceships!",
451
  "Dragon Quest": "A knight fights a fire-breathing dragon to save the princess in the castle.",
452
+ "Jungle Explorer": "An explorer runs through the jungle, jumping over snakes and swinging on vines."
 
453
  }
454
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
455
  # Main content
456
+ st.markdown(f'<div class="level-indicator">Level {st.session_state.level} ✨ XP: {st.session_state.xp}/100</div>', unsafe_allow_html=True)
457
  progress = st.progress(st.session_state.xp / 100)
458
 
459
  col1, col2 = st.columns([1, 1])
460
 
461
  with col1:
462
  st.markdown('<div class="story-box">', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
463
  st.markdown("### πŸ“– Write Your Story Here:")
464
 
465
  # Story template selector
 
483
  characters = {
484
  "spaceship": "πŸš€ Spaceship",
485
  "dragon": "πŸ‰ Dragon",
486
+ "knight": "πŸ›‘οΈ Knight"
 
 
 
487
  }
488
 
489
  for i, (char_key, char_label) in enumerate(characters.items()):
490
+ with char_cols[i]:
491
  if st.button(
492
  char_label,
493
  key=f"char_{char_key}",
 
502
  themes = {
503
  "space": "🌌 Space",
504
  "jungle": "🌿 Jungle",
505
+ "medieval": "🏰 Medieval"
 
 
 
506
  }
507
 
508
  for i, (theme_key, theme_label) in enumerate(themes.items()):
509
+ with theme_cols[i]:
510
  if st.button(
511
  theme_label,
512
  key=f"theme_{theme_key}",
 
553
  if st.session_state.story_count == 1:
554
  unlock_achievement("first_story")
555
 
 
 
 
 
 
556
  # Generate speech if enabled
557
  if st.session_state.voice_enabled:
558
  st.session_state.speech_data = text_to_speech(st.session_state.code_explanation)
 
637
  st.markdown('<div class="robot-speech">', unsafe_allow_html=True)
638
  st.markdown("### πŸ€– Tavus the Robot Teacher says:")
639
 
 
 
 
 
 
 
 
 
 
640
  # Extract action words from story
641
  action_words = ["zoom", "shoot", "fly", "move", "jump", "run", "attack", "laser", "alien", "spaceship",
642
+ "dragon", "fire", "hero", "sword", "castle", "run", "escape", "fight", "win"]
 
643
  found_actions = [word for word in action_words if word in st.session_state.story_text.lower()]
644
 
645
  if found_actions:
 
699
  elif action == "win":
700
  explanations.append("creates victory conditions!")
701
  code_snippets.append("if player.score > 100: show_victory_screen()")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
702
 
703
  st.markdown("See how your story became real code? Here's what happened:")
704
 
 
766
  st.success("+5 XP! Character jumped!")
767
 
768
  with challenge_cols[2]:
769
+ st.markdown("#### Challenge 3: The Shooter")
770
  st.code("""
771
+ # Make the character shoot a laser
772
+ laser = character.shoot()
773
  """)
774
  if st.button("Run Challenge 3", key="challenge3"):
775
  st.session_state.xp += 5
776
+ st.success("+5 XP! Laser fired!")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
777
 
778
  # Benefits section
779
  st.markdown("""
780
+ ## ❀ Why Everyone Will Love CodeTales
781
 
782
  | For Kids πŸ‘§πŸ‘¦ | For Parents & Teachers πŸ‘ͺπŸ‘©β€πŸ« |
783
  |--------------|----------------------------|
 
788
  | 🌟 100% private with no API keys | πŸ’° Completely free and open-source |
789
  | πŸ† Achievement system motivates learning | πŸ“ˆ Progress tracking shows growth |
790
  | πŸ—£οΈ Voice explanations for accessibility | 🎨 Creative expression through stories |
 
791
  """)
792
 
793
  # Footer