question

donovan-3047 avatar image
0 Votes"
donovan-3047 asked donovan-3047 edited

How to re-create 10-letter-wordgame

Creating this game From Lingo. 2 letters needs to swap what aren't at the correct spot. The only thing I achieved is to move in the red correct ones and move out the incorrect yellow ones. Shuffeld beforehand.

But what is next?

137030-image.png

Code:
Yes I have WPF solution and code.

         public MainWindow()
         {
             InitializeComponent();
             DrawTextblocks_10_C(Word_canvas_10_C);
             DrawTextblocks_10(Word_canvas_10);
         }
    
         public Label[] Letter_labels_10 = new Label[10];
         public Border[] Backgrounds_10 = new Border[10];
         public Label[] Letter_labels_10_2 = new Label[10];
         public Border[] Backgrounds_10_2 = new Border[10];
         public void DrawTextblocks_10_C(UniformGrid Word_canvas_10_C)
         {
             for (int j = 0; j < 10; j++)
             { 
                 RadialGradientBrush Red = new RadialGradientBrush()
                 {
    
                 };
                 GradientStop stop1 = new GradientStop(Colors.Maroon, 1.0);
                 GradientStop stop2 = new GradientStop(Colors.Red, 0.251);
                 Red.GradientStops.Add(stop1);
                 Red.GradientStops.Add(stop2);
    
                 Border Background_10 = new Border
                 {
                     Background = Red,
                     Width = size,
                     Height = size,
                     Margin = new Thickness(0, 0, 0, 0),
                     BorderBrush = new SolidColorBrush(Colors.DarkGray),
                     BorderThickness = new Thickness(6),
                 };
    
                 Label Label_10 = new Label
                 {
                     Height = size,
                     Effect = drop,
                     Width = size,
                     FontSize = 75,
                     Background = new SolidColorBrush(Colors.Transparent),
                     HorizontalContentAlignment = HorizontalAlignment.Center,
                     VerticalContentAlignment = VerticalAlignment.Center,
                     Margin = new Thickness(-5, -20, 0, 0),
                     Foreground = new SolidColorBrush(Colors.White),
                 };
    
                 Backgrounds_10_2[j] = Background_10;
                 Background_10.Child = Label_10;
                 Word_canvas_10.Children.Add(Background_10);
                 Canvas.SetLeft(Label_10, j * Word_canvas.Height);
                 Canvas.SetTop(Label_10, j * Word_canvas.Height);
                 Letter_labels_10[j] = Label_10;
    
             }
         }
    
         public void DrawTextblocks_10(UniformGrid Word_canvas_10)
         {
             for (int j = 0; j < 10; j++)
             {
                 RadialGradientBrush Yellow_block = new RadialGradientBrush
                 {
                     GradientOrigin = new Point(0.5, 0.5),
                     Center = new Point(0.5, 0.5),
                     RadiusX = 0.45,
                     RadiusY = 0.45
                 };
                 Yellow_block.GradientStops.Add(new GradientStop(Colors.Goldenrod, 1.0));
                 Yellow_block.GradientStops.Add(new GradientStop(Colors.DarkBlue, 1.0));
    
                 Border Background_10 = new Border
                 {
                     Background = Yellow_block,
                     Width = size,
                     Height = size,
                     Margin = new Thickness(0,0,0,0),
                     BorderBrush = new SolidColorBrush(Colors.DarkGray),
                     BorderThickness = new Thickness(6),
                 };
    
                 Label Label_10 = new Label
                 {
                     Height = size,
                     Effect = drop,
                     Width = size,
                     FontSize = 75,
                     Background = new SolidColorBrush(Colors.Transparent),
                     HorizontalContentAlignment = HorizontalAlignment.Center,
                     VerticalContentAlignment = VerticalAlignment.Center,
                     Margin = new Thickness(-5, -20, 0, 0),
                     Foreground = new SolidColorBrush(Colors.White),
                 };
    
                 Backgrounds_10[j] = Background_10;
                 Background_10.Child = Label_10;
                 Word_canvas_10_C.Children.Add(Background_10);
                 Canvas.SetLeft(Label_10, j * 118);
                 Canvas.SetTop(Label_10, j * 118);
                 Letter_labels_10_2[j] = Label_10;
             }
         }
    
 private async void OnKeyDownHandler(object sender, KeyEventArgs e)
         {
             if (e.Key == Key.T)
             {
                 List<string> word_10 = new List<string>(){ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
                 List<string> word_10_2 = new List<string>() { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
                 List<string> randomizedList = new List<string>();
                    
                 Random random = new Random();
                 for (int i = 10 - 1; i > 1; i--)
                 {
                     int rnd = random.Next(i + 1);
                     var value = word_10[rnd];
                     word_10[rnd] = word_10[i];
                     word_10[i] = value;
                     randomizedList.Add(value);
                 }
    
                 for (int i = 0; i < 10; i++)
                 {
                     Letter_labels_10_2[i].Content = word_10[i].ToString();
                     Letter_labels_10[i].Content = word_10_2[i].ToString();
                 }
    
                 List<int> numbers = new List<int>(10);
                 List<int> numbers_left = new List<int> { 0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 9 };
                 score_10 = 70;
                 L_score_10.Content = score_10.ToString();
    
                 SoundPlayer Lingos = new SoundPlayer { Stream = Properties.Resources.Start_woord };
                 Lingos.Play();
    
                 Word_canvas_10_C.Visibility = Visibility.Visible;
                 _10_score.Visibility = Visibility.Visible;
    
                 Word_canvas_10_C.RenderTransform = new TranslateTransform(0, 118);
                 _10_score.RenderTransform = new TranslateTransform(0, 118);
    
                 DoubleAnimation Show_10 = new DoubleAnimation(400, 0, new Duration(TimeSpan.FromMilliseconds(250)))
                 {
                     AutoReverse = false,
                     RepeatBehavior = new RepeatBehavior(1)
                 };
    
                 Storyboard.SetTarget(Show_10, Word_canvas_10_C);
                 Storyboard.SetTargetProperty(Show_10, new PropertyPath("RenderTransform.Y"));
    
    
                 DoubleAnimation show_score = new DoubleAnimation(400, 0, new Duration(TimeSpan.FromMilliseconds(250)))
                 {
                     AutoReverse = false,
                     RepeatBehavior = new RepeatBehavior(1)
                 };
    
                 Storyboard.SetTarget(show_score, _10_score);
                 Storyboard.SetTargetProperty(show_score, new PropertyPath("RenderTransform.Y"));
    
                 var sb = new Storyboard();
                 sb.Children.Add(Show_10);
                 sb.Children.Add(show_score);
                 sb.Begin();
                 await Task.Delay(1450);
    
                 while (numbers.Count < 3)
                 {
                     int rnd = new Random().Next(0, 10);
    
                     while (!numbers.Contains(rnd))
                     {
                         SoundPlayer Bonus = new SoundPlayer { Stream = Properties.Resources.Bonus_letter };
                         Bonus.Play();
                         Word_canvas_10_C.Visibility = Visibility.Visible;
    
                         Backgrounds_10[rnd].RenderTransform = new TranslateTransform(0, 118);
                         Backgrounds_10_2[rnd].RenderTransform = new TranslateTransform(0, 118);
    
                         DoubleAnimation show_in = new DoubleAnimation(0, size, new Duration(TimeSpan.FromMilliseconds(600)))
                         {
                             AutoReverse = false,
                             RepeatBehavior = new RepeatBehavior(1)
                         };
    
                         Storyboard.SetTarget(show_in, Backgrounds_10[rnd]);
                         Storyboard.SetTargetProperty(show_in, new PropertyPath("RenderTransform.Y"));
    
                         DoubleAnimation show_out = new DoubleAnimation(0, size, new Duration(TimeSpan.FromMilliseconds(600)))
                         {
                             AutoReverse = false,
                             RepeatBehavior = new RepeatBehavior(1)
                         };
    
                         Storyboard.SetTarget(show_out, Backgrounds_10_2[rnd]);
                         Storyboard.SetTargetProperty(show_out, new PropertyPath("RenderTransform.Y"));
    
                         var sb0 = new Storyboard();
                         sb0.Children.Add(show_in);
                         sb0.Children.Add(show_out);
                         sb0.Begin();
                         numbers.Add(rnd);
                         numbers_left.Remove(rnd);
                         await Task.Delay(500);
                     }
                 }


XAML

 <Window x:Class="Lingo_animations.MainWindow"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         mc:Ignorable="d"
         Title="MainWindow" Height="1002" Width="2000" WindowStartupLocation="CenterScreen" WindowStyle="None" Background="#00000000" Foreground="Black" ResizeMode="NoResize" KeyDown="OnKeyDownHandler" WindowState="Maximized">
     <Grid x:Name="Main" Margin="0,0,0,0" Background="Black">
             <Rectangle x:Name="R_score_A" HorizontalAlignment="Right" Height="120" StrokeThickness="10" VerticalAlignment="Center" Width="242" RadiusX="100" RadiusY="100" Margin="0,120,167,137" MinWidth="242" Stroke="Silver">
                 <Rectangle.Fill>
                     <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                         <GradientStop Color="DarkBlue" Offset="0.814"/>
                         <GradientStop Color="Blue" Offset="0.473"/>
                         <GradientStop Color="DarkBlue" Offset="0.116"/>
                     </LinearGradientBrush>
                 </Rectangle.Fill>
             </Rectangle>
             <Label x:Name="_10_score_A" Content="0" HorizontalAlignment="Right" VerticalAlignment="Center" Width="242" Height="120" FontSize="80" Foreground="White" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="0,120,167,137" MinWidth="242" MinHeight="120" RenderTransformOrigin="0.802,0.483"/>
             <Rectangle Height="120" Stroke="Silver" StrokeThickness="10" VerticalAlignment="Center" RadiusX="100" RadiusY="100" MinWidth="242" MinHeight="120" HorizontalAlignment="Center" Margin="564,24,564,233">
                 <Rectangle.Fill>
                     <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                         <GradientStop Color="#FFAA0000" Offset="0.814"/>
                         <GradientStop Color="OrangeRed" Offset="0.473"/>
                         <GradientStop Color="#FFAA0000" Offset="0.116"/>
                     </LinearGradientBrush>
                 </Rectangle.Fill>
             </Rectangle>
             <Label Content="70" x:Name="L_score_10" VerticalAlignment="Center" FontSize="80" Foreground="White" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" MinWidth="242" MinHeight="120" RenderTransformOrigin="0.5,0.5" Height="120" HorizontalAlignment="Center" Margin="564,24,564,233"/>
             <Rectangle x:Name="R_score_B" HorizontalAlignment="Left" Height="120" Stroke="Silver" StrokeThickness="10" VerticalAlignment="Center" Width="242" RadiusX="100" RadiusY="100" Margin="181,120,0,137">
                 <Rectangle.Fill>
                     <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                         <GradientStop Color="DarkBlue" Offset="0.814"/>
                         <GradientStop Color="Blue" Offset="0.473"/>
                         <GradientStop Color="DarkBlue" Offset="0.116"/>
                     </LinearGradientBrush>
                 </Rectangle.Fill>
             </Rectangle>
             <Label x:Name="_10_score_B" Content="0" HorizontalAlignment="Left" VerticalAlignment="Center" Width="242" Height="120" FontSize="80" Foreground="White" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="181,120,0,137" MinWidth="242" MinHeight="120"/>
             <UniformGrid x:Name="Word_canvas_10_R" HorizontalAlignment="Center" VerticalAlignment="Top" Background="Black" Columns="10" Height="100" Width="1000" ClipToBounds="True" Margin="484,300,496,0"/>
             <UniformGrid x:Name="Word_canvas_10_C"   HorizontalAlignment="Center" VerticalAlignment="Top" Background="Black" Columns="10" Height="100" Width="1000" Margin="484,200,496,0"/>
             <Rectangle Fill="Black" HorizontalAlignment="Left" Height="100" Margin="484,200,0,0" VerticalAlignment="Top" Width="1000" Visibility="Hidden"/>
         </Grid>
     </Grid>
 </Window>









dotnet-csharpwindows-wpf
image.png (75.0 KiB)
· 8
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,anonymous user-3047 . Have you created a WPF project to do your function? Could you show the code related to your problem? Do you want to reset your number to start a new round of the game?

0 Votes 0 ·

oops. Forget to insert. Updated the question. Thanks!

0 Votes 0 ·

Hi,anonymous user-3047 . What are the definitions of Word_canvas, _10_score, L_score_10 and drop in your code? Could you show your xaml code?

0 Votes 0 ·
Show more comments

0 Answers