Fu-Kwun Hwang
|
 |
«
Embed this message
Reply #60 on: December 21, 2010, 11:02:03 pm » posted from:Taipei,T'ai-pei,Taiwan |
|
 The applet was created many years ago (more then 10 years) with JDK1.0.2 You might get error if you use latest jave to compile it (because java has severla major change over the year) It should work fine if you use JDK1.0.2
|
|
|
Logged
|
|
|
|
jarvo250
Newbie
Offline
Posts: 9
|
 |
«
Embed this message
Reply #61 on: December 22, 2010, 06:47:16 am » posted from:Grimsby,North East Lincolnshire,United Kingdom |
|
 The applet was created many years ago (more then 10 years) with JDK1.0.2 You might get error if you use latest jave to compile it (because java has severla major change over the year)
It should work fine if you use JDK1.0.2
It compiles fine if I don't alter the code at all....I just want the levels, buttons and drop down part removed from the code. I am attempting to create a snooker game, and I am having real trouble getting started, and ideally would like to use this as a base to get going, but I don't want the options I mentioned. When I remove the codes I think are related to it, it never compiles correctly.....really tearing my hair out over this...
|
|
|
Logged
|
|
|
|
Fu-Kwun Hwang
|
 |
«
Embed this message
Reply #62 on: December 22, 2010, 10:00:31 am » posted from:Taipei,T'ai-pei,Taiwan |
|
 I think the problem might be due to "selection list". If you just remove all those GUI element, then the code can not find the selected level so there is an error. Find the name for the selection list ,and find code related to that name, replace with proper value/code.
|
|
|
Logged
|
|
|
|
jarvo250
Newbie
Offline
Posts: 9
|
 |
«
Embed this message
Reply #63 on: December 22, 2010, 07:51:46 pm » posted from:Grimsby,North East Lincolnshire,United Kingdom |
|
 I think the problem might be due to "selection list". If you just remove all those GUI element, then the code can not find the selected level so there is an error. Find the name for the selection list ,and find code related to that name, replace with proper value/code.
Ah yes, thanks so much got it. Now how would I enlarge the area in which the ball bounce off. Its quite small at the minute, and would like to ideally make it bigger....
|
|
|
Logged
|
|
|
|
Fu-Kwun Hwang
|
 |
«
Embed this message
Reply #64 on: December 22, 2010, 10:02:49 pm » posted from:Taipei,T'ai-pei,Taiwan |
|
 You do not need to re-compile it. What you need to do is to change the width and height for the applet tag.
|
|
|
Logged
|
|
|
|
ahmedelshfie
Ahmed
Hero Member
Offline
Posts: 954
|
 |
«
Embed this message
Reply #65 on: December 22, 2010, 10:14:15 pm » posted from:SAO PAULO,SAO PAULO,BRAZIL |
|
 I think the problem might be due to "selection list". If you just remove all those GUI element, then the code can not find the selected level so there is an error. Find the name for the selection list ,and find code related to that name, replace with proper value/code.
Do you mean prof i delete this part from code Reset","Clear","level1","level2","level3 And after recompile again i do it but what deleted is text in buttons and choose option but buttons stay not deleted only minimum size of buttons. I tried delete buttons totally to no appear but always give error when i recompile again.
|
|
|
Logged
|
|
|
|
Fu-Kwun Hwang
|
 |
«
Embed this message
Reply #66 on: December 22, 2010, 11:14:33 pm » posted from:Taipei,T'ai-pei,Taiwan |
|
 String rts,STR[]={"Reset","Clear","level1","level2","level3"}; p.add(cb=new Choice()); for(int i=2;i cb.addItem(STR[i]);
The above code add selection list . If you remove the above code. It will produce error at the following code level=cb.getSelectedIndex(); because cb is not exist any more. public void reset(boolean status){ level=cb.getSelectedIndex(); clear(status); running=false; m.stop(); s.stop(); }
|
|
|
Logged
|
|
|
|
ahmedelshfie
Ahmed
Hero Member
Offline
Posts: 954
|
 |
«
Embed this message
Reply #67 on: December 22, 2010, 11:30:52 pm » posted from:SAO PAULO,SAO PAULO,BRAZIL |
|
 I close also this code // level=cb.getSelectedIndex(); Recompile again but didn't change, i believe i didn't understand good your explain prof.
|
|
|
Logged
|
|
|
|
jarvo250
Newbie
Offline
Posts: 9
|
 |
«
Embed this message
Reply #68 on: December 23, 2010, 12:00:11 am » posted from:Grimsby,North East Lincolnshire,United Kingdom |
|
 I now have it to the size that I would like....however, the problem now is that I don't wont the balls to appear in random places upon start-up of the applet. I want to set the x and y coordinates of both balls, and still allow them to move freely when colliding.
EDIT: I HAVE NOW FIGURED THIS OUT, HOWEVER, HOW DO I ADD MORE BALLS!!!
|
|
« Last Edit: December 23, 2010, 12:15:28 am by mariner1990 »
|
Logged
|
|
|
|
Fu-Kwun Hwang
|
 |
«
Embed this message
Reply #69 on: December 23, 2010, 12:23:40 am » posted from:Taipei,T'ai-pei,Taiwan |
|
 1. The position was random because there are assigned as x=Math.random()*wx; y=Math.random()*wy; You need to change all those code to whatever you want. 2. There are only two balls in the code movingballs m,s; You need to add more and initialize each ball. If you have more than two balls. You need a double loop to take care of collision between all balls. e.g. ball A,B,C You need to take care of collision between AB, BC and CA You are welcomed to check out Browian motion or particle model for solid/liquid/gas states in 3D3. If there is any error when compile the code, check out the error message (it will point out the line numeber where the error occur) and try to solve it according to what the message say.
|
|
|
Logged
|
|
|
|
jarvo250
Newbie
Offline
Posts: 9
|
 |
«
Embed this message
Reply #70 on: December 23, 2010, 01:16:55 am » posted from:Grimsby,North East Lincolnshire,United Kingdom |
|
 Ok so I have a new ball appearing, but it appears under an existing ball (one of the originals that was in the code). And I have it so that the white ball collides with it but the ball doesnt move. I assume this is to do with that double loop you were on about.....where abouts is this in the code and what do I add.
|
|
|
Logged
|
|
|
|
jarvo250
Newbie
Offline
Posts: 9
|
 |
«
Embed this message
Reply #71 on: December 23, 2010, 06:54:55 am » posted from:Grimsby,North East Lincolnshire,United Kingdom |
|
 I have multiple balls on screen now, and each ball collides successfully. The only problem I have now is with the random positioning of the balls. I know how to change it so its not random. However, when I do change it two of the three balls go into the same place, and then the collisions are messed up. How can I set the position and allow the balls to collide.
|
|
|
Logged
|
|
|
|
Fu-Kwun Hwang
|
 |
«
Embed this message
Reply #72 on: December 23, 2010, 07:05:14 pm » posted from:Taipei,T'ai-pei,Taiwan |
|
 The code to process collision will fail if you have two balls at the same position. (This would not happened in real life). If you have more than two ball , i.e. n ball You need a double loop to process possible collision between any two balls. The original code only process collision between two ball. Change it a function e.g. collision(i,j) which will process collision between particle i and j. The double will look like for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ collision(i,j); } } You are welcomed to check out Collision 2D to find more information.
|
|
|
Logged
|
|
|
|
jarvo250
Newbie
Offline
Posts: 9
|
 |
«
Embed this message
Reply #73 on: December 23, 2010, 10:02:45 pm » posted from:Grimsby,North East Lincolnshire,United Kingdom |
|
 The code to process collision will fail if you have two balls at the same position. (This would not happened in real life). If you have more than two ball , i.e. n ball You need a double loop to process possible collision between any two balls. The original code only process collision between two ball. Change it a function e.g. collision(i,j) which will process collision between particle i and j. The double will look like for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ collision(i,j); } } You are welcomed to check out Collision 2D to find more information. Am totally lost. There is already something similar to that in the code. Are you saying I need to do that again or not? Honestly can't get it done....
|
|
« Last Edit: December 23, 2010, 11:00:38 pm by jarvo250 »
|
Logged
|
|
|
|
Fu-Kwun Hwang
|
 |
«
Embed this message
Reply #74 on: December 23, 2010, 11:40:45 pm » posted from:Taipei,T'ai-pei,Taiwan |
|
 You do not need to add more loop if you already have double loop in your code. However, you have to do it correctly. I do not know how you did it and I do not know how can I help?
|
|
|
Logged
|
|
|
|
jarvo250
Newbie
Offline
Posts: 9
|
 |
«
Embed this message
Reply #75 on: December 23, 2010, 11:58:36 pm » posted from:Grimsby,North East Lincolnshire,United Kingdom |
|
 I've managed to delete the existing double loop without effecting the applet.
|
|
|
Logged
|
|
|
|
jarvo250
Newbie
Offline
Posts: 9
|
 |
«
Embed this message
Reply #76 on: December 24, 2010, 12:16:59 am » posted from:Grimsby,North East Lincolnshire,United Kingdom |
|
 I have more than two balls colliding...i.e AB, BC, CA can all collide. The problem I have is with placing balls B and C at set coordinates. I have ball A working in set coordinates, but ball B and C share the same X and Y coordinates i.e: x=Math.random()*wx; y=Math.random()*wy; When i change the above to say, 100 and 200, both B and C balls move to that place. I need separate X and Y coordinates to be assigned but also work in the collision method. I have new instance of a ball which allows me the third ball, but the new instance has the same value as B the second ball.
|
|
« Last Edit: December 24, 2010, 01:22:47 am by jarvo250 »
|
Logged
|
|
|
|
Fu-Kwun Hwang
|
 |
«
Embed this message
Reply #77 on: December 24, 2010, 09:54:42 pm » posted from:Taipei,T'ai-pei,Taiwan |
|
 Idefined movingballs(int xd,int yd,int sizei) and add the following code inside x=Math.random()*xd; y=Math.random()*yd;
That is the reason why x,y are created randomly. You can define something like movingballs(int xd,int yd,int xi,int yi,int sizei) if you need to assign it to a new position (xi,yi) and change the above code to x=xi; y=yi;
Then you can initialize new particle with new xi,yi value set.
|
|
|
Logged
|
|
|
|
koclup1580
watchlist
Newbie
Offline
Posts: 16
|
 |
«
Embed this message
Reply #78 on: December 29, 2012, 01:22:40 pm » posted from:,,Satellite Provider |
|
 oh good.
|
|
|
Logged
|
|
|
|
|