Click here to Skip to main content
13,089,618 members (58,847 online)
Click here to Skip to main content
Add your own
alternative version


5 bookmarked
Posted 9 Mar 2013

Projectile Motion in Picturebox C#.Net

, 9 Mar 2013
Rate this:
Please Sign up or sign in to vote.


C#.Net consist a large varieties of Libraries and namespace,  when considering an application which requires a motion that may be projectile or hyperbola. In the context of this statement C#.Net has provided System.Drawing Library and Point Class to draw the point on different Axis (x,y). Implementing projectile motion using for loops and other techniques create complexities and coding overhead for the programmers. This technique will help you to create projectile motion using timer and Graph Logic.








Projectile motion is difficult to implement in C#.Net. when placing a Position on Windows Form it immediately triggers, this is a common problem faced by different Students and professionals. 

Using the code 

This graph will help the user to draw any motion in C#.Net . As the axis are defined and Described in the above image

public Form1()
        int TimerCounter = 0;
        byte Duck_Pos = 5; 
void Duck_SmallJump()
     if (TimerCounter <= 10)
         duck.Location = new Point(duck.Location.X - 4, duck.Location.Y - 6);
     else if (TimerCounter > 10 && TimerCounter <= 15)
         duck.Location = new Point(duck.Location.X - 6, duck.Location.Y - 4);
     else if (TimerCounter > 15 && TimerCounter <= 20)
         duck.Location = new Point(duck.Location.X - 8, duck.Location.Y + 4);
     else if (TimerCounter > 20 && TimerCounter <= 30)
         duck.Location = new Point(duck.Location.X - 8, duck.Location.Y + 6);

         timer1.Enabled = false;
         TimerCounter = 0;
         Duck_Pos -= 1;

Points of Interest             

<o:p /> In Form Design, A property named Double Buffered should be checked true in order to minimize the latency of pictureBox. 

History <o:p />

Defining the Dimension are always the critical area in programming, to identify the location of axis and placing the new point on that location mostly the complex task.   


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Syed Ubaid Ali Jafri
United States United States
Information Security Expert

You may also be interested in...

Comments and Discussions

QuestionWork Pin
xaaqib12-Mar-13 10:41
memberxaaqib12-Mar-13 10:41 
AnswerRe: Work Pin
Ubaid Ali14-Mar-13 20:40
memberUbaid Ali14-Mar-13 20:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170813.1 | Last Updated 10 Mar 2013
Article Copyright 2013 by Syed Ubaid Ali Jafri
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid