Page 8 of 11

Posted: Thu Jun 15, 2006 9:33 am
by Dare
lol, mp303. :lol:

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. :)

Posted: Thu Jun 15, 2006 1:53 pm
by mp303
Dare wrote:now that it is established that you're always right...
all I've established so far, is my right to have an opinion. ;)

Posted: Thu Jun 15, 2006 7:09 pm
by Joakim Christiansen
One little question mp303, how did you make the bullets appear from that relative position?

Posted: Thu Jun 15, 2006 8:03 pm
by u9
Joakim Christiansen wrote:One little question mp303, how did you make the bullets appear from that relative position?
I would recommend initializing the position and orientation of the bullets as follows:

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
No offence to anyone, bullet and ship are structs, not objects :P Anyways, this places the bullet centered in front of the ship. As the guns on the ship are a bit off-center, you can add that distance to the bullets initial position as follows:

Code: Select all

bullet\xPos = bullet\xPos + cos( ship\angle -90 ) * gunDist
bullet\yPos = bullet\yPos - sin( ship\angle -90 ) * gunDist
Where gunDist is the distance from the center of the ship to the gun. This code moves the bullet in front of one of the guns. Notice that to move the bullet in front of the other gun you need to add +90 to the ships angle instead of subtracting.

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 ) ...
Come to think of it, if Pi is not defined either you can approximate it using 22/7 - or maybe it's a constant (#Pi).

Anyways, hope this helps, or hopefully mp303 will give you the correct answer ;)

Posted: Thu Jun 15, 2006 8:09 pm
by Joakim Christiansen
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... :oops:

Posted: Thu Jun 15, 2006 8:19 pm
by u9
Ok, then I don't understand the problem. Maybe mp303 might know.

Posted: Thu Jun 15, 2006 10:05 pm
by u9
Does this help:
Image
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

Posted: Fri Jun 16, 2006 7:28 pm
by mp303
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... :oops:
what u9 described, is basically what I'm doing.

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

Posted: Tue Jun 27, 2006 2:10 pm
by storck
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

Re: Thanks for sharing

Posted: Wed Jun 28, 2006 9:26 pm
by mp303
storck wrote:Making the asumption that people are less eperienced programmers just because they use a basic langugage is just plain stupid.
I never made that assumption, certain others just assumed that I did.

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.

Posted: Thu Jun 29, 2006 2:32 am
by Dare
This is old now. Time to beat swords into ploughshares, methinks.

Posted: Fri Jun 30, 2006 2:07 am
by Joakim Christiansen
mp303, How are you able to draw a sprite smooth like that?

Posted: Fri Jun 30, 2006 5:37 pm
by 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! :)

Posted: Fri Jun 30, 2006 7:17 pm
by Joakim Christiansen
mp303, Thank you, that's very nice of you! :D

Posted: Fri Jun 30, 2006 9:02 pm
by storck
@ mp303
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.
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.

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