I am making a pool game as my project. I am having troubles of declaring the ellipse image to link with the class so that I can use it with the physics engine later on. I was left with this code to finish and I've already research for 5 hours just to figure out this problem.
At XAML
<Ellipse Canvas.Left="314" Canvas.Top="305" Height="35" Name="Ball1" Stroke="Black" Width="35" StrokeThickness="0.01">
<Ellipse.Fill>
<ImageBrush ImageSource="/FYPJ;component/Images/Balls/1.png" />
</Ellipse.Fill>
</Ellipse>
Class
public Point Position { get; set; }
public int BallNum
{
get
{
return ballNum;
}
set
{
if (value <= 7)
IsSolid = true;
else
IsSolid = false;
ballNum = value;
}
}
public Ball(int ballNumber, Point position)
{
this.BallNum = ballNumber;
this.Position = position;
// TODO: rember to add physics behavior later
}
At XAML.cs
private void Page_Loaded(object sender, RoutedEventArgs e)
{
// init ball position
foreach (Ball ball in balls)
{
Ellipse ballImage = this.GetBallImage(ball);
Console.WriteLine("ball " + ball.BallNum); // For Testing according to my teacher
ball.Position.X = ; // Unfinished Code
ball.Position.Y = ; // Unfinished Code
}
}
If you think there are still code that I missed out on this question. Feel free to comment it out. Thank you.