Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Making my plane shoot!

Author
Message
Ninja_Je5us
14
Years of Service
User Offline
Joined: 1st Feb 2010
Location:
Posted: 2nd Jan 2011 22:35
I am having a lot of trouble making a 3d game in which my plane will shoot at targets.

The first problem is that my plane will not shoot. I have a plane that flies (although not realistically enough for my tutor!) and a terrain.

I have tried using an array to initialize a sphere on the press of a button. This did create a sphere but it messed up the camera that i've got.

Any help on making something simple would be greatly appreciated.
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 2nd Jan 2011 23:38
Try:

If you already have that then can't really help without seeing any code.

DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 3rd Jan 2011 23:30
I posted on another thread about your flying game, but you never responded after I posted some code. Did you ever get the code I posted?
Here is the code again:


This is a complete program. READ THE COMMENTS AND CHANGE THE OBJECT NUMBERS. You can can take the code of the method declaration and definition along with the global vars and paste it into your code. You need to also copy the "camandplanex();" into your main loop.

This should be realistic enough for you. the only thing that would make it significantly more realistic is to add stalling and/or the effects of gravity.

I'll get a new signature someday.
Ninja_Je5us
14
Years of Service
User Offline
Joined: 1st Feb 2010
Location:
Posted: 6th Jan 2011 03:27
Hi there, thanks for your help. I have asked about shooting before and am currrently trying to implement a class developed by another user that would be suitable for my game.

My main trouble is we havent even learnt how to implement classes properly at uni and yet I have to have a game prototype with classes done within the next five days!!

Any help on implementing this class and finally making my plane shoot would be VERY greatly appreciated. Here's my code:



This is the code that clearly isnt mine, noting the tidyness!

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 6th Jan 2011 15:08
You don't have to use a class to it's fullest capability. You can simply use a class for ease of information storage. For bullets, you will need a minimum of:
position
direction (an unnormaled direction would include the speed)
lifetime (set it to some maximum time and count down each frame)



In your game declare an array of BULLET and simply reuse the bullets as they "die".

That's a simple way to use a class. Hope that helps.

The fastest code is the code never written.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 6th Jan 2011 15:43 Edited at: 6th Jan 2011 15:47
why are you looping 1000 times each frame, when there is a very little amount of bullets being used? i'd suggest using an std::vector of BULLETs (std::vector<BULLET> bulletV), everytime you shoot a bullet, create a BULLET class and assign values to it's members, then use bulletV.push_back ( theNewBulletStruct );

also, i believe it's better to have lifetime of bullets in seconds not frames

and last thing is: dont use a sphere as a bullet! not even a custom mesh, bullets are very small, and very fast, they are either unseen or just a plain textured with something that could make it look like "a fast object", we do that in order to avoid any FPS loss (on slow computers, yes it matters)

Your signature has been erased by a mod - Please reduce it to 600x120 maximum size
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 6th Jan 2011 15:58
Quote: "why are you looping 1000 times each frame, when there is a very little amount of bullets being used?"
I know... It's an example of how you CAN do it. Sure, there are several ways to do the same thing, but Ninja_Je5us wanted a simple way to go about it. If 1000 is too much, he could easily change it to 100 or 50 or whatever he feels appropriate.
Quote: "also, i believe it's better to have lifetime of bullets in seconds not frames"
Yes, but once again we are dealing with a novice. Once he gets used to classes, he can move to more complicated things. Time-based movement is just another step to making it better.
Quote: "dont use a sphere as a bullet"
Use anything.... A sphere doesn't need to be rotated like a billboard. He could use a cube if he wanted to.

I'm just trying to make it simple for him. He asked about classes in an earlier post, but he still hasn't received enough help on the concept. That was my attempt to help with his "class" question.

The fastest code is the code never written.

Login to post a reply

Server time is: 2024-06-28 01:10:37
Your offset time is: 2024-06-28 01:10:37