This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I am fairly competent at using c to control hardware such as Atmega chips esp32 etc.
So I wanted to have a go at a simple bit of software as a challenge because I've found thats how I learn best.
I picked something very simple I was familiar with, a basic 2d artillery game. I then set about plotting sample shots to hopefully gain insight on what was going on, after getting some data points I tried to predict where the shots would land; some small successes but not entirely accurate.
The program is as simple as it gets as of now: Just a console app, you right click firing position, right click the target, then it displays vertical and horizontal distances in pixels, then click 'o' to simulate a mouse click for the calculated duration for the power such that at a 45 degree angle the target is hit
As the shots move further away from the player they no longer fall off in a linear fashion but do so exponentially (I think) as you'd expect.
Height difference is also a factor, for example if you are higher than your target assuming 45 degree shooting angle you'll have to use less power by an amount.
I was just wondering the best method and by which means you'd try figuring this out, at the moment I've just got a huge amount of if statements which are essentially just recorded sample shots instead of an actual equation that describes the trajectory itself.
I suspect it is my weakathmatical skills holding me back here.
So my questions:
How might I come to an equation that describes the trajectory?
Is just tagging on a modifier to the firing solution based on pixel height difference between shooter and target sufficient?
Thanks for any useful answers! :)
Subreddit
Post Details
- Posted
- 4 months ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/AskProgramm...