Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,150,238 members, 7,807,793 topics. Date: Wednesday, 24 April 2024 at 07:24 PM |
Nairaland Forum / Science/Technology / Programming / Help With Java Programing: Changing Motion Of A Particle In A Jpanel (1475 Views)
Android Programing And Web Programing, Which One Is Better? / Creating A Proxy Server With Java. / Learning To Program With Java by the Fulaman (2) (3) (4)
(1) (Reply)
Help With Java Programing: Changing Motion Of A Particle In A Jpanel by Nobody: 11:38am On Feb 25, 2016 |
I wrote a program in in which I created a Java.awt.Point object. and I set the co-ordinates to change with respect to time with a certain function. basically, I used a javax.swing.Timer object. everytime the timer fires, a int variable increases by 1, and the new value of the int is fed into a function, which is then used to change the point's location on the Panel. I then used a graphics object to paint a circle on that point. the resulting effect is that the user sees a ball moving across the screen. the problem is that, I want the co-ordinates to change their motion when they reach a certain point. for instance if the ball was falling before, when it gets to a certain y co-ordinate, it should start moving horizontally to the right. Here's what my code looks like. but it work. the ball just disappears when it's supposed to change motion.
If there is anything else needed from the original code, kindly say. this is an experiment. |
Re: Help With Java Programing: Changing Motion Of A Particle In A Jpanel by Booyakasha(f): 4:42pm On Feb 26, 2016 |
Teempakguy: Java is not really my thing, at least for now... but here could be where your problem lies.. "if(point.y <= 0 && ticks !=0)" you know how operator precedence works with the && Operator. |
Re: Help With Java Programing: Changing Motion Of A Particle In A Jpanel by Nobody: 3:00pm On Feb 27, 2016 |
Booyakasha:Thanks for the input. it turns out my entire program was garbage. the co-ordinates i specified are outside the visible window. I've solved the problem. but thanks anyway. |
(1) (Reply)
Print ("how Long Will It Take To Be An Expert Python Programmer") / Please Help, Which Is The Best Computing Skill To Attain? / Can Someone Learn PHP In Four Contact
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 20 |