This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

hi there

i am trying to programme something simple for mobile phones using J2ME and midlets, but the problem is a gerneral problem and someone who does not know anything on midlets or J2ME can help, but ideally someone with some background knowledge on mobile phone programming would be good.

the problem i am trying to solve is as follows :

i want to have a arrow on the screen, if you move the right cursor, the arrow should point in cockwise positions, for example suppose that the arrow is initally pointing 12:00 if the right cursor key is pressed the arrow should point 1:00 or if left is pressed the arrow should point at 11:00, when the shoot button is pressed a pixel should shoot in that direction. This involves trigonemtry any help sould be appreciated

i am trying to programme something simple for mobile phones using J2ME and midlets, but the problem is a gerneral problem and someone who does not know anything on midlets or J2ME can help, but ideally someone with some background knowledge on mobile phone programming would be good.

the problem i am trying to solve is as follows :

i want to have a arrow on the screen, if you move the right cursor, the arrow should point in cockwise positions, for example suppose that the arrow is initally pointing 12:00 if the right cursor key is pressed the arrow should point 1:00 or if left is pressed the arrow should point at 11:00, when the shoot button is pressed a pixel should shoot in that direction. This involves trigonemtry any help sould be appreciated

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get this solution by purchasing an Individual license!
Start your 7-day free trial.

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

2 posibilities are:

1) doing the calculations beforehand and simply putting the results(that would be used by the game) in an array. depending on how many factors you wish to include(wind factor, angle, power, ect) or exclude this can be memory/process efficent.

2) if you only have a limited number of selections(you can only more the arrow right 3 times or left 3 tims) then you can simply assign a "field" of where the arrow will hit. if the target is in that field then you could count it as a hit.

~Aqua

((Plus trajectory of the projectiles will almost always need to use a parametric equation, predefined vectors will not efficiently work in that case))

i havnt got the chance to see if any of your responses work yet guy, my laptop short circuited and is driving me mad, please bear with me, ill check real soon and give my response, in the mean time if any one want to extend on there response please be my guest, the more info the better =))

~Aqua

PS: Plus you use the equations I spelled out word for word for you. You increment the T value instead of leaving it the length of the line and the projectile will travel along the path of the line. If your T value is 1 you are 100% if you raise it then the length continues to go... say you have a line length 1 you say in your parametric equation you want the projectile to start at the tip of the barrel. You get the center coord by using the parametric equation with a T value of 1.. Which gives you a percentage by 1 * 100 = 100% Then say you want to make it go 2 units away... thus you use a T value of 2 which is 200%.. .Which then doubles the length of the line to 2 units.

Pretty simple. Play around with it a bit and ask questions if you can't figure it out after at least ATTEMPTING to apply my algorithm.

all i used was the drawLine(int,int,int,int);

"PS: Plus you use the equations I spelled out word for word for you. You increment the T value instead of leaving it the length of the line and the projectile will travel along the path of the line. If your T value is 1 you are 100% if you raise it then the length continues to go... say you have a line length 1 you say in your parametric equation you want the projectile to start at the tip of the barrel. You get the center coord by using the parametric equation with a T value of 1.. Which gives you a percentage by 1 * 100 = 100% Then say you want to make it go 2 units away... thus you use a T value of 2 which is 200%.. .Which then doubles the length of the line to 2 units."

DO try to read our posts before asking the same question over again!

Good Luck,

~Aqua

cheers

In all reality you use the two end points of your initial equation and use a standard parametric equation to determine the new end point. If you use a unit vector (a line of length 1) your percentage will be the unit length of the line. So essentially it pays off quite a bit to use a line of length 1 as your base line for further calculation. If you want to factor gravity, drag or wind into these calculations you can do a mutation of the final point you get and alter it's coordinates by weight and air drag. But that is probabally more than you want to get into for a cell phone game.

If you need any help with your math let me know... Just make sure you post what you have thus far so I can take a look and make the needed corrections to your algebra.

~Aqua

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free triali have used the drawline method in j2me where g.drawLine(m_prevX, m_prevY, m_x, m_y);

the following is my code:

x2,y2,x1,y1,m,c,cs,ys1,xs1

......

......

g.drawline(x,y,r,l); //where x,y is the starting position and r and l are end position draw these

.....

....

switch(getGameAction(key))

case UP: l+=50;r+=50;

x1 = x; y1 = y;

x2 = r; y2 = l;

m = (y2 - y1) / (x2 - x1);

c = y1 - m * x1;

ys1 = man[2].gety(); //target this man

xs1 = man[2].getx(); //get his x,y cordinates

cs = ys1 - (m * xs1);

if(c==cs){

System.out.println("gota yahhhhhhhhhhhhhhhhhhhhhh")

}

i dont need 2 draw the projectile, as long as the line moves over the soldier and prints out hte message "gota yahhh" im happy

m = (y2 - y1) / (x2 - x1); // get the gradient of the line

c = y1 - m * x1; //where the line crosses y axis

cs = ys1 - (m * xs1); // working out hte value guy being shot at

if(c == cs) { } // if the coordinates are the same

Game Programming

From novice to tech pro — start learning today.

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get this solution by purchasing an Individual license!
Start your 7-day free trial.

See this site for further instruction:

http://mathworld.wolfram.com/ParametricEquations.html

But to make it work you would do a 360 / 12 to get your T offset of 30.

Then you will use this formula:

x = (radius of your line) * sine(TOffset)

y = (radius of your line) * cosine(TOffset)

On mathworld it is giving you a equation that would give you a counter-clockwise rotation. Pretty much you use that equation and display the line a T Offset where your initial T Offset would be 90 to achieve the arrow pointing to 12 on a clock. Then incriment or decrment by 30 depending on which arrow is pressed.

The trajectory bullet will travel along that point so you would use another parametric equation to animate it where your radius of the line is the distance the point has traveled from the point. ;-)

Simple as that.

Let me know if you have any more questions:

~Aqua