Question

In: Computer Science

Please do this in C#. Stay on the Screen! Animation in video games is just like...

Please do this in C#. Stay on the Screen! Animation in video games is just like animation in movies – it’s drawn image by image (called “frames”). Before the game can draw a frame, it needs to update the position of the objects based on their velocities (among other things). To do that is relatively simple: add the velocity to the position of the object each frame.

For this program, imagine we want to track an object and detect if it goes off the left or right side of the screen (that is, it’s X position is less than 0 and greater than the width of the screen, say, 100). Write a program that asks the user for the starting X and Y position of the object as well as the starting X and Y velocity, then prints out its position each frame until the object moves off of the screen. Design (pseudocode) and implement (source code) for this program.

Sample run 1:

Enter the starting X position: 50

Enter the starting Y position: 50

Enter the starting X velocity: 4.7

Enter the starting Y velocity: 2

X:50    Y:50

X:54.7 Y:52

X:59.4 Y:54

X:64.1 Y:56

X:68.8 Y:58

X:73.5 Y:60

X:78.2 Y:62

X:82.9 Y:64

X:87.6 Y:66

X:92.3 Y:68

X:97    Y:70

X:101.7 Y:72

Solutions

Expert Solution

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new Console Application in C# is created using Visual Studio 2017 with name "AnimationApplication".This application contains a class with name "Program.cs".Below are the details of this class.

Program.cs :

//namespace
using System;
//application namespace
namespace AnimationApplication
{
class Program //C# program
{
//entry point of the program , Main() method
static void Main(string[] args)
{
//asking user starting X position
Console.Write("Enter the starting X position:");
//reading X position
double xPosition = double.Parse(Console.ReadLine());
//asking user starting Y position
Console.Write("Enter the starting Y position:");
//reading Y position
double yPosition = double.Parse(Console.ReadLine());
//asking user starting X velocity
Console.Write("Enter the starting X velocity:");
//reading X velocity
double xVelocity = double.Parse(Console.ReadLine());
//asking user starting Y velocity
Console.Write("Enter the starting Y velocity:");
//reading Y velocity
double yVelocity = double.Parse(Console.ReadLine());
//using while loop finding X and Y positions
while(xPosition>0 && xPosition<100)
{
Console.WriteLine("X:"+xPosition+" Y:"+yPosition);
//to find new X position add X velocity
xPosition += xVelocity;
//to find new Y position add Y velocity
yPosition += yVelocity;
}
//used to print last line
Console.WriteLine("X:" + xPosition + " Y:" + yPosition);
//to hold the screen
Console.ReadKey();

}
}
}
======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :Program.cs

Screen 2:

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.


Related Solutions

Please do in Java!! Stay on the Screen! Animation in video games is just like animation...
Please do in Java!! Stay on the Screen! Animation in video games is just like animation in movies – it’s drawn image by image (called “frames”). Before the game can draw a frame, it needs to update the position of the objects based on their velocities (among other things). To do that is relatively simple: add the velocity to the position of the object each frame. For this program, imagine we want to track an object and detect if it...
Castle View Games would like to invest in a division to develop software for video games....
Castle View Games would like to invest in a division to develop software for video games. To evaluate this decision, the firm first attempts to project the working capital needs for this operation. Its chief financial officer has developed the following estimates (in millions of dollars): Year 1 Year 2 Year 3 Year 4 Year 5 Cash 6 12 15 15 15 Accounts receivable 21 22 24 24 24 Inventory 5 7 10 12 13 Accounts payable 18 22 24...
What is the influence of the media on children? Do you think exposure to video games...
What is the influence of the media on children? Do you think exposure to video games may be creating anxiety, anger, hostility, or even psychological disorders, such as oppositional defiant disorder, conduct disorder and ADHD?
Do violent video games play a role in school shootings and mass violence?
Do violent video games play a role in school shootings and mass violence?
1. What impact do video games have on the school age child’s acquisition of physical and...
1. What impact do video games have on the school age child’s acquisition of physical and cognitive skills? 2. How can an adolescent achieve a sense of their own identity?
observational learning and violence. Do you believe that watching violence on video games and/or television leads...
observational learning and violence. Do you believe that watching violence on video games and/or television leads to violent behavior? How does the information in your assigned reading and the statistics presented support or challenge your beliefs?
Please C++ create a program that will do one of two functions using a menu, like...
Please C++ create a program that will do one of two functions using a menu, like so: 1. Do Catalan numbers 2. Do Fibonacci numbers (recursive) 0. Quit Enter selection: 1 Enter Catalan number to calculate: 3 Catalan number at 3 is 5 1. Do Catalan numbers 2. Do Fibonacci numbers (recursive) 0. Quit Enter selection: 2 Enter Fibonacci number to calculate: 6 Fibonacci number 6 is 8 Create a function of catalan that will take a parameter and return...
Is aggression a learned behavior? How do television/movies/video games influence this aggression. Does this matter? Is...
Is aggression a learned behavior? How do television/movies/video games influence this aggression. Does this matter? Is there a connection between violence in the media and violence in society?
Please complete just Form 1040 (you do not need to fill out a Schedule C or...
Please complete just Form 1040 (you do not need to fill out a Schedule C or Schedule D, but you can use them to calculate numbers to enter into Form 1040) for a client with the following tax situation: Paul Gigornovich Address: 123 HillCrest Lane, San Diego, CA 92101 Wage income: $45,000/00 W2 Federal Tax Withholdings: $4,000.00 Net Long Term Stock Sales Gain: $8,000.00 Net Short Term Sock Sale Loss: -$12,000.00 Sole Proprietorship Business Gross Income: $80,000.00 Expenses: Interest: $8,000.00...
please watch this video TED Talk: "What it's like to be the child of immigrants" Michael...
please watch this video TED Talk: "What it's like to be the child of immigrants" Michael Rain. Question 1. What are two of the challenges that michael rain discussed as being a child of an immigrant? Question 2. How has the media, your family, and your community shaped your perception of immigrants and refuges? Is this an accurate perception.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT