Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 1,000 results for
balls
- Page 1
Re: Bouncing Balls: Creating a new ball when two balls collide
Programming
Software Development
2 Weeks Ago
by toneewa
… = 50; public BallPanel(Ball[]
balls
) { b.addAll(Arrays.asList(
balls
)); timer = new Timer(delay, …new ball's parameters } } } } } // draw the
balls
for (int i = 0; i < b.size(); …
Re: Bouncing Balls: Creating a new ball when two balls collide
Programming
Software Development
2 Weeks Ago
by toneewa
…50; public BallPanel(Ball[]
balls
) { b.addAll(Arrays.asList(
balls
)); timer = new Timer(…s parameters } } } } } // Draw the
balls
for (Ball ball : b) { // Draw the…
Bouncing Balls: Creating a new ball when two balls collide
Programming
Software Development
3 Weeks Ago
by jprog1000
….paintComponent( g ); g.setColor(Color.red); // move the
balls
for (int i = 0; i <b.length; i… b[i].changeDirection(b[j]); } } } // draw the
balls
for (int i = 0; i <b.length; i…
Re: Bouncing Balls: Creating a new ball when two balls collide
Programming
Software Development
1 Week Ago
by vortex_1
…could be determined based on the properties of the colliding
balls
. However, it's important to consider how this …the simulation. If the primary goal of the bouncing
balls
simulation is to accurately model and demonstrate the physics … a new ball is created when two
balls
collide in a bouncing
balls
simulation should be based on the intended…
Re: Bouncing Balls: Creating a new ball when two balls collide
Programming
Software Development
2 Weeks Ago
by jprog1000
Hello, Thank you again so much! All your additions are clear, but it seems like whenever two
balls
collide, more than one ball is added to the arraylist and painted. Any way to have just one ball added to the panel for every collision? Have some kind of a toggle flag in paintcomponent? Regards
Re: Bouncing Balls: Creating a new ball when two balls collide
Programming
Software Development
2 Weeks Ago
by jprog1000
Thank you so much for your reply and additions! It is certainly working as I wanted. I will read through the code you have added and ask you any questions I might have. I hope you don't mind. Regards
Re: Bouncing Balls: Creating a new ball when two balls collide
Programming
Software Development
2 Weeks Ago
by Dani
I’ll mark this question solved :)
Re: Bouncing Balls: Creating a new ball when two balls collide
Programming
Software Development
2 Weeks Ago
by Dani
… oh, sorry, missed the bit about you still needing clarifications. Feel feee to ask :) I’ll now unmark this topic as solved. /facepalm
Re: Bouncing Balls: Creating a new ball when two balls collide
Programming
Software Development
2 Weeks Ago
by toneewa
Yes, this is true. Overlapping ball spawns can do that causing a chain reaction. Something like that could be done. How you handle the spawning of the new ball is what I played with a bit before. You will see better collision detection changing to: g.fillOval(ball.getX(), ball.getY(), 1 * ball.getRadius(), 1 * ball.getRadius());
Re: Bouncing Balls: Creating a new ball when two balls collide
Programming
Software Development
1 Week Ago
by jprog1000
Got it. Thank you so much!
Re: Bouncing Balls: Creating a new ball when two balls collide
Programming
Software Development
1 Week Ago
by jprog1000
Great reply, vortex! Agree with all your points.
Re: Bouncing Balls: Creating a new ball when two balls collide
Programming
Software Development
1 Week Ago
by aishamushtaq
Hi, Its helpful for me. I got my answer.
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by Traevel
…from the terribly confusing naming for
balls
and lists of
balls
, you call `updateball` to add
balls
every few ticks, then you … other tick, you update their position and redraw the
balls
on their new position, this probably also means you'… clear the entire panel, and redraw pacman and the
balls
on that every tick. And I'd strongly suggest using…
Java array of balls
Programming
Software Development
12 Years Ago
by Stevo812
…/**Ball class which contains the code for creating the
balls
and setting the * boundaries of the screen. …2; /**double which declares the friction applied to the
balls
when traveling * along the table. */ private double friction… contains the code for collisions between * the
balls
. */ collision.update(this, b, b2); …
problem in showing balls
Programming
Software Development
9 Years Ago
by toring
… void updateball(){ for(
Balls
bb:ball){ ball.add(new
Balls
(xPos,yPos)); } } } class
Balls
{ int x,y; public
Balls
(){ } public
Balls
(int x,int y…
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by toring
…, yPos = 35; int arcMouth=300;
Balls
pacmanball = new
Balls
(); List<
Balls
>ball = new ArrayList<
Balls
>(); public Mypanel(){ myTimer(); } protected void…
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by toring
…int arcMouth=300;
Balls
pacmanball = new
Balls
(); List<
Balls
>listball = new ArrayList<
Balls
>(); public Mypanel…fillArc(xPos,yPos,30,30,30,arcMouth); for(
Balls
b:listball){ b.drawballs(g); } } public…
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by toring
…i < 10; i++) { listball.add(new
Balls
(xPos+5,yPos+15)); } myTimer(); } protected …fillArc(xPos,yPos,30,30,30,arcMouth); for(
Balls
b:listball){ b.drawballs(g); } } public…
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by Traevel
…words, you can't draw the
balls
until the jPanel **has** a Graphics…after the repaint method or the
balls
will never stay visible long …repaint(); updateball(); } public void updateball(){ for(
Balls
b:listball){ b.moveBalls(); if(super.getGraphics()!=…
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by Traevel
Because
Balls
does not extend jPanel (more specifically, a jComponent). You're … means it has to be present in the super class.
Balls
doesn't have a super class.
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by toring
@Traevel, so if i will not extend my Class
Balls
to JPanel,I could not use the method paintComponent in my
Balls
Class ?... Thank you in avdvance.
Re: how to add more balls ?
Programming
Software Development
12 Years Ago
by autorunman22
… addBalls(); System.out.println("!"); Thread.sleep(4000);
Balls
balls
= new
Balls
();
balls
.paintMe(g); }catch(Exception ex){} } public static void main… directionX =2; static int directionY = 2; static int widx; public
Balls
() { Thread gameThread = new Thread() { public void run() { while(true)…
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by Traevel
If by behind you mean they don't get updated at the same pace as pacman it's because you're only updating the
balls
when pacman has its mouth open.
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by toring
why is it cannot replace the drawballs method in my
Balls
Class into this protected void paintComponent(Graphics g) { super.paintComponent(…
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by Traevel
If you don't extend
Balls
to a jComponent, then no you can't use that method in that manner.
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by Traevel
… in drawing position? If I run your code now the
balls
are not moving and it just draws a rectangle at…
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by Traevel
I don't know what your goal is, but what I'm seeing is a blue rectangle moving away from pacman yes. It could be that there are 10
balls
that all start in the same spot moving at the same pace, judging from what I'm seeing in your constructor though.
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by toring
….RED); g.fillArc(xPos,yPos,30,30,30,arcMouth); for(
Balls
b:listball){//how to perform this without inside b.drawballs…
Re: problem in showing balls
Programming
Software Development
9 Years Ago
by toring
….RED); g.fillArc(xPos,yPos,30,30,30,arcMouth); for(
Balls
b:listball){//how to perform this without inside b.drawballs…
Bouncing Balls in Panel
Programming
Software Development
13 Years Ago
by renovatiotr
…swing-book/Chapter8_files/image002.gif[/URL] There are moving
balls
in seperate panels(not imaages). Smaller the panel's… area, faster the
balls
move. I did the JSplitPane and Panels but failed… to do the Moving
Balls
Part. [CODE] import java.awt.*; import javax.swing.*;…
1
2
3
17
Next
Last
Search
Search
Forum Categories
Hardware/Software
Programming
Digital Media
Community Center
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Meet People
Forums
Top Members
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC