Anyhow, now that it is established that you're always right (at least to the person who counts most) - how about helping out the folks who request solutions in "coding questions"? They can be sure they're getting good solid code and answers.
small 2D shooter with some impressive effects
-
mp303
- Joakim Christiansen
- Addict

- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
I would recommend initializing the position and orientation of the bullets as follows:Joakim Christiansen wrote:One little question mp303, how did you make the bullets appear from that relative position?
Code: Select all
bullet\xPos = ship\xPos + cos( ship\angle ) * ship\radius
bullet\yPos = ship\yPos - sin( ship\angle ) * ship\radius
bullet\angle = ship\angle
Code: Select all
bullet\xPos = bullet\xPos + cos( ship\angle -90 ) * gunDist
bullet\yPos = bullet\yPos - sin( ship\angle -90 ) * gunDist
The angles I've used are in degrees, but in think (haven't checked, I'm at work) that the input to cos() and sin() should be radians. If so, you'll need to convert the input like this:
Code: Select all
... cos( ship\angle * Pi / 180 ) ...Anyways, hope this helps, or hopefully mp303 will give you the correct answer
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. (Nathaniel Borenstein)
http://www.wirednerd.com
http://www.wirednerd.com
- Joakim Christiansen
- Addict

- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
Thank you u9, but I don't think it will help much in my case.
I have many different images (for different weapons) and for each I have a XY value of where the bullet should be created on the image, but when the image rotates i'm having difficulty calculating where this would be...
I have many different images (for different weapons) and for each I have a XY value of where the bullet should be created on the image, but when the image rotates i'm having difficulty calculating where this would be...
Last edited by Joakim Christiansen on Thu Jun 15, 2006 8:23 pm, edited 2 times in total.
I like logic, hence I dislike humans but love computers.
Ok, then I don't understand the problem. Maybe mp303 might know.
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. (Nathaniel Borenstein)
http://www.wirednerd.com
http://www.wirednerd.com
Does this help:

This matrix rotates XY coordinates around the origo theta radians. But your XY coordinates need to be relative to the center by which you rotate your image. Let me know if you don't know how to multiply two matrices. The image is from wikipedia

This matrix rotates XY coordinates around the origo theta radians. But your XY coordinates need to be relative to the center by which you rotate your image. Let me know if you don't know how to multiply two matrices. The image is from wikipedia
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. (Nathaniel Borenstein)
http://www.wirednerd.com
http://www.wirednerd.com
-
mp303
what u9 described, is basically what I'm doing.Joakim Christiansen wrote:Thank you u9, but I don't think it will help much in my case.
I have many different images (for different weapons) and for each I have a XY value of where the bullet should be created on the image, but when the image rotates i'm having difficulty calculating where this would be...
your situation is a bit different. you probably need to create a vector from the origo of rotation, to the XY of your bullet's starting position. then rotate that vector around the same origo. (I don't know if that's at all useful to you - I'm not very good at "formal" maths, I just sort of look at things and use my common sense)
Thanks for sharing
Thank you for sharing mp303.
What I have liked about this forum is that people can say pretty much what they want. Try saying PureBasic in the IBasic forum and chances are that your post is deleted or locked.
Why do we start all this oop thing all over? As far as I am concerned (no I am not god
) mp303 is entitled to his opinion as is every one else. If you can live without oop use purebasic, if not it is oviously the wrong tool. Buy something else.
Making the asumption that people are less eperienced programmers just because they use a basic langugage is just plain stupid. Most people here use other languages as well. It is possible to develop pretty much any software using pretty much any programming language. Like all other things in life it is a question of selecting the right tool for the job you want to get done. You can even do a lot of things with the wrong tool, it's just more work.
Why do I even bother, it is all so obvious - isn't it?
Have a nice summer all!
// Storck
What I have liked about this forum is that people can say pretty much what they want. Try saying PureBasic in the IBasic forum and chances are that your post is deleted or locked.
Why do we start all this oop thing all over? As far as I am concerned (no I am not god
Making the asumption that people are less eperienced programmers just because they use a basic langugage is just plain stupid. Most people here use other languages as well. It is possible to develop pretty much any software using pretty much any programming language. Like all other things in life it is a question of selecting the right tool for the job you want to get done. You can even do a lot of things with the wrong tool, it's just more work.
Why do I even bother, it is all so obvious - isn't it?
Have a nice summer all!
// Storck
-
mp303
Re: Thanks for sharing
I never made that assumption, certain others just assumed that I did.storck wrote:Making the asumption that people are less eperienced programmers just because they use a basic langugage is just plain stupid.
What I said was, that a lot of beginners use Basic, which is the truth. I think PB is a pretty damn good Basic for beginners, as in a single day, I was able to teach my 11-year old boy how to do a basic sprite that moves around on screen and fires a bullet. I myself was doing similar stuff at that age, studying the excellent "kiddie programming books" (don't remember their names) for the C=64 by Erwin Neutzky-Wulff...
Anyways, I never said that 11-year olds was the ONLY audience for a Basic compiler. That was somebody else's assumption.
Basic is an excellent learning language, was basically my only point. I never said that's all it was good for.
- Joakim Christiansen
- Addict

- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
-
mp303
well, more people have had questions, and let's be realistic - I'm never going to finish this ... so I've decided to make the source code available:
download here.
Enjoy!
download here.
Enjoy!
- Joakim Christiansen
- Addict

- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
@ mp303
Anyways, who really cares. Why don't we just go on with our lives. I am sure that you never intended having this discussion when posting your demo. I should have kept my mouth shut. For me this debate ends right here. I think your demo is great. Also, thank you for sharing the source.
// Storck
Sounds a little bit like making the asumption that people here are less eperienced programmers. A lot of people here have been programming for years and a fair share have been using different (if not lots of) high-level programming languages as well.Are you going to tell me that this forum is full of programmers with many years of experience with lots of different high-level programming languages? I think you'd be wrong.
Anyways, who really cares. Why don't we just go on with our lives. I am sure that you never intended having this discussion when posting your demo. I should have kept my mouth shut. For me this debate ends right here. I think your demo is great. Also, thank you for sharing the source.
// Storck
