• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
ronnieb555

Could anyone help me?

7 posts in this topic

Hi,
For my assignment at University I am required to create an old arcade game, I chose Missile Command. I have some things working in the game but something I cannot get to work is getting the rocket to fly towards the crosshair (the player) and then stop/explode when it reaches the crosshair location. Does anyone know how I can do it? #

So far I have the rocket flying towards the crosshair but the rocket is not starting from the base (blue triangle), it is starting at the same X coordinate as the crosshair.

My game will be attached to this thread.

To get the game to run you will need to change the directory of the images located on lines 113+ on Form1 as I have not found out how to save the image files within the program.

If you can help can you reply as soon as possible as I have a deadline that is fast approaching and I am focusing all my attention to this part of the game as it it the most important part. Please ignore the falling missiles from the top of the screen, I am also working on this to get them to spawn randomly across the X coordinates.

I have been using Visual Studio 2008 as that is the version used by my Uni.

Thanks.

Edit: To play the game the controls are set up with W, A, S, D for movement and Space for shooting, I am working on getting it to use the mouse.

Edit 2: The Bullet class is the players Rocket (The blue one) and the Rocket class is the NPC rockets (The Red ones). Edited by ronnieb555
0

Share this post


Link to post
Share on other sites
I'm not a C# user, but looking at your bullet.cs I see what looks like some problems.

Firstly, you have a member function named "draw" which is doing work that is not related to drawing: namely it's updating the bullet logic and then performing the draw.

Updating the logic for the object should belong to its own function.

Examining the logic in question, you adjust the position of the bullet according to the velocity factors which the object was created with and then do some bounds testing. While this could work theoretically I think you'd have better luck using point-to-point interpolation:

*When you create the object give it a starting position, an ending position and a velocity..
*Use Pythagorean Theorem to calculate the distance between the two points. (dest_x - start_x is your triangle's base, dest_y - start_y is your triangle's height. The hypotenuse is the distance you need to travel.)
*Determine how many frames/steps are required to travel this distance at the desired velocity.

*Then during the bullet's update set its X to ((dest_x - start_x) * cur_step) / total_steps
*And it's Y to ((dest_y - start_y) * cur_step) / total_steps
*Increment cur_step
*When cur_step == total_steps then explode the bullet

As a side note, this isn't really a DirectX or XNA related question, and your topic title isn't really helpful for grabbing the attention of people that may know answers to your specific question.

Hope that helps. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Good luck with the project!

P.S. - Depending on your coordinate orientation you may need to reverse (dest_y - start_y) to (start_y - dest_y) and possibly also with the x dimension. If the bullet goes the wrong direction, that's your sign. ;) Edited by Khatharr
0

Share this post


Link to post
Share on other sites
Thanks for the reply. I posted it in this area because I was told by my lecturer that this code was directx, is it not?

Would you be able to provide a more simple explanation for the method you have described? This is my first "big" programming assignment and I am fairly new to this type of programming.

Thanks.
0

Share this post


Link to post
Share on other sites
I have managed to implement your method I think, but only up until this section;

"
[left][background=rgb(250, 251, 252)]*Then during the bullet's update set its X to ((dest_x - start_x) * cur_step) / total_steps[/background][/left]

[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]*And it's Y to ((dest_y - start_y) * cur_step) / total_steps"[/background][/size][/font][/color][/left]


[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]Up to there the bullet does not travel across the screen and pops onto the screen only when the player(crosshair) is on the left, top of the screen.[/background][/size][/font][/color][/left]


[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]I also have a u question, how can I work out the cur_step and the total_step? [/background][/size][/font][/color][/left]


[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]I have attached the file with your code implemented as best I could.[/background][/size][/font][/color][/left]

[left][attachment=8964:Missile Command.rar][/left]
0

Share this post


Link to post
Share on other sites
I have a bit more time right now than I did last time I replied. So I'll take a closer look. While you may be using DirectX for rendering this issue is more of a general programming issue. It may be better under the C# section. :)

I'll edit after I've taken a look at your code.
0

Share this post


Link to post
Share on other sites
Okay, it's not showing me an edit button and I CBA to reload, so I'll just make a new post.

Since I don't know C# I'll show you a rough Ruby version of the class to demonstrate the technique.

[CODE]class Bullet
def initialize(start_x, start_y, dest_x, dest_y, velocity)
@start_x = start_x
@start_y = start_y
@dist_x = dest_x - start_x
@dist_y = dest_y - start_y
distance = Math.sqrt((dist_x * dist_x) + (dist_y * dist_y)).to_i
@total_steps = distance / velocity #assuming velocity is measured in distance per frame

@curstep = 0
@x = @start_x
@y = @start_y
end

def update
if @curstep == @total_steps
explode
else
@x = @start_x + ((@dist_x * @curstep) / @total_steps)
@y = @start_y + ((@dist_y * @curstep) / @total_steps)

@curstep += 1
end
end

def draw
#draw the bullet (no movement should be processed here)
end
end[/CODE]

Of course that's pretty rough example, but it should demonstrate the technique. Calculate your distance in the ctor and use that distance to determine the number of frames it will take. (If velocity is distance-per-frame then total frames will be distance / velocity.)

When you update your position the math is:

(total distance) * (current step / total steps)

but since you're using integers you want to make sure that the multiplication takes place before the division (to prevent loss of precision).

For instance, to calculate half of 4 mathematically you'd say:

4 * (1 / 2)

But in programming, if you're using integers then you'd get a result of zero from that because (1 / 2) rounds down to zero. So instead you'd say:

(4 * 1) / 2

Which would evaluate to 2.

Generally when you're mixing multiplications and divisions you should try to do the divisions last since division reduces precision.

Because of this our position calculation becomes:

(total distance * current step) / (total steps)

You do that calculate the x and y positions separately this way for every frame. The idea is that (current step / total steps) represents the fraction of the total motion that you've reached. Multiplying that fraction by the total distance you need to move gives you the correct position for that frame. When current steps becomes equal to total steps then you've reached the final frame and you can explode the bullet. This technique is called "interpolation". The start and end are the "poles" and you're calculating an inter-pole position. This is a useful technique used in several ways in graphics programming.

You may want to take a Physics 100 course if you're planning on making games. A 100 course is usually pretty easy and basic physics deals a lot with this kind of calculation.

I'm not familiar with the C# syntax, but in your ctor could you test the value of 'Form1.Base.xfire' by printing it out or looking at it in the debugger and see if it's the correct value? I see you're using Visual Studio. VS has a very nice debugger. It can really help out with problems like this. You may want to spend a few minutes to familiarize yourself with its use.

Hope that helps! [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by Khatharr
0

Share this post


Link to post
Share on other sites
I know you are not familiar with C# but the distance part wouldn't work, I could add it as a Boolean but then I cannot use the .to_i at the end. Also I set the velocity in the main form (Form1) on line 176. When I added everything except the distance parts the bullet would draw but only flash on the screen above and below the cross hair.

I have posted this thread on the game programming and general programming threads so hopefully someone that knows how to use C# will help, thanks for your help though Khatharr I will let you know how I get on. If you have anymore suggestions please feel free to let me know.
0

Share this post


Link to post
Share on other sites
Sorry about the double post.

If anyone still has any suggestions I would be so grateful for them.

I have attached the newest version with some changes over the original (the NPC missiles now spawn randomly and fall down, the cities blow up when hit, the npc missiles can now be destroyed by the player rockets.

Thanks for any help.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0