Game Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesGame Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 2nd, 2006, 03:09 PM
william_nagels william_nagels is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Location: belgium
Posts: 116 william_nagels User rank is Private First Class (20 - 50 Reputation Level)william_nagels User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 7 h 2 m 45 sec
Reputation Power: 7
Send a message via MSN to william_nagels
Half of a rectangle.

OK look here is my problem:
I'm working on a school program.
There is a rolling ball and a rectangle.
(height of the applet = 400 , width =400)
how can i find out if the ball hits above the half of the rectangle or under the half.
please help me.

William

Reply With Quote
  #2  
Old September 2nd, 2006, 03:27 PM
gimp's Avatar
gimp gimp is offline
<?PHP user_title("gimp"); ?>
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jan 2005
Location: Internet
Posts: 7,652 gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 2540 Folding Title: Novice Folder
Time spent in forums: 3 Months 6 Days 1 h 35 m 4 sec
Reputation Power: 6083
Send a message via AIM to gimp
First, I think you just posted this.
Second, you might want to post this in a language-specific forum next time, probably java? Can a mod move this there?
Third, aren't you supposed to be doing homework with your brain, a book, a compiler, and an API? We don't really like homework questions here. We can prod you in the right direction if we see that you have put some effort into this. What do you have so far?
__________________
Chat Server Project & Tutorial | WiFi-remote-control sailboat (building) | Joke Thread
“Rational thinkers deplore the excesses of democracy; it abuses the individual and elevates the mob. The death of Socrates was its finest fruit.”
Use XXX in a comment to flag something that is bogus but works. Use FIXME to flag something that is bogus and broken. Use TODO to leave yourself reminders. Calling a program finished before all these points are checked off is lazy.
-Partial Credit: Sun

If I ask you to redescribe your problem, it's because when you describe issues in detail, you often get a *click* and you suddenly know the solutions.
Ches Koblents

Reply With Quote
  #3  
Old September 2nd, 2006, 03:42 PM
william_nagels william_nagels is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Location: belgium
Posts: 116 william_nagels User rank is Private First Class (20 - 50 Reputation Level)william_nagels User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 7 h 2 m 45 sec
Reputation Power: 7
Send a message via MSN to william_nagels
i got this

I'm pretty far already but i just keep getting the same error.
It's a boolean probleme:
the boolean always changes to 'heenschuin = true' i really don't get it .

btw the language is java (applets....)
this is my code


Code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.Event.*;
public class col extends Applet implements Runnable
{
    Image Buffer;
    Graphics gBuffer;
    int x, y;
    boolean mouseInside, collide, onderdeel1;
    boolean heen, terug;
    boolean heenschuin, terugschuin;
    Rectangle r1, r2;
    Rectangle bots1,bots2; 

    public void init()
    {
        Buffer=createImage(size().width,size().height);
        gBuffer=Buffer.getGraphics();
        r1=new Rectangle(110,115,10,10);
        r2=new Rectangle(0,0,25,50);
        bots1=new Rectangle(0,0,25,25);
        heen = true;
	terug = false;
        heenschuin = false;
	terugschuin = false;
        onderdeel1 = false;

    }

    public void drawStuff()
    {
        gBuffer.setColor(Color.black);

        gBuffer.fillRect(0,0,size().width,size().height);

        gBuffer.setColor(Color.red);
        gBuffer.fillOval(r1.x, r1.y, r1.width, r1.height);

        gBuffer.setColor(Color.blue);

        gBuffer.fillRect(r2.x, r2.y, r2.width, r2.height);
        gBuffer.setColor(Color.yellow);
        gBuffer.fillRect(r2.x, r2.y, bots1.width, bots1.height);
        gBuffer.setColor(Color.black);

    }

    public boolean mouseEnter(Event evt,int x,int y)
    {
        mouseInside=true;
        repaint();

        return true;
    }

    public boolean mouseExit(Event evt,int x,int y)
    {
        mouseInside=false ;
        repaint();

        return true;
    }

    public boolean mouseMove(Event evt,int x,int y)
    {
        this.x=x;
        this.y=y;
        r2.move(x-r2.width/2, y-r2.height/2);
        drawStuff();

        repaint();
        return true;
    }

    public void update(Graphics g)
    {
        paint(g);
    }

    public void paint(Graphics g)
    {
        drawStuff();
        g.drawImage (Buffer,0,0, this);
    }
public void start(){
      		   Thread tbal = new Thread (this);
                   tbal.start(); 
                   }
public void run (){
      		while (true){ 
		            collide=r2.intersects(r1); 
 		            onderdeel1=bots1.intersects(r1);   
                            if (collide){
                                        if(onderdeel1){
                                                      terug = false;
						      heen  = true;
                                                      collide=false;
                                                      heenschuin = false;
	                                              terugschuin = false;
	                                              onderdeel1 =false;
                                                      }
                                        else{
                                        terug = false;
					heen  = false;
                                        collide=false;
                                        heenschuin = true;
	                                terugschuin = false;
	                                onderdeel1 =false;
                                             }
                                         }
			   else{}
                    
		if(heen && collide==false){
			if ( r1.x >400){
                                      heen = false; terug = true;
			              }
		        else{
                            r1.x=r1.x+2;
                            }
                                          }
		if(heenschuin && collide==false){
			r1.x = r1.x+2;
			r1.y = r1.y+2;
                        }
		if(terug && collide== false){
			if ( r1.x <10){
                                      heen = true; 
                                      terug = false;
			              }
		        else{
                            r1.x=r1.x-2;
                            }
                        }
		if(terugschuin && collide== false){
			r1.x = r1.x-2;
			r1.y = r1.y+2;
                        }	
 repaint();
            			try{
                  		   Thread.sleep (20);
			           }
            			   catch (InterruptedException ex){}
			    repaint();
                            } 
                  }
                                        }

Reply With Quote
  #4  
Old September 2nd, 2006, 06:45 PM
gimp's Avatar
gimp gimp is offline
<?PHP user_title("gimp"); ?>
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jan 2005
Location: Internet
Posts: 7,652 gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 2540 Folding Title: Novice Folder
Time spent in forums: 3 Months 6 Days 1 h 35 m 4 sec
Reputation Power: 6083
Send a message via AIM to gimp
All you need to do is check the collision coordinates.

Do you have a collision detection algorithm?

Reply With Quote
  #5  
Old September 3rd, 2006, 07:02 AM
william_nagels william_nagels is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Location: belgium
Posts: 116 william_nagels User rank is Private First Class (20 - 50 Reputation Level)william_nagels User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 7 h 2 m 45 sec
Reputation Power: 7
Send a message via MSN to william_nagels
i fixed the probleme but thanks anyway

Reply With Quote
  #6  
Old September 3rd, 2006, 11:37 PM
Viper_SB's Avatar
Viper_SB Viper_SB is offline
Psycho Canadian
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jan 2001
Location: Canada
Posts: 4,845 Viper_SB User rank is Brigadier General (60000 - 70000 Reputation Level)Viper_SB User rank is Brigadier General (60000 - 70000 Reputation Level)Viper_SB User rank is Brigadier General (60000 - 70000 Reputation Level)Viper_SB User rank is Brigadier General (60000 - 70000 Reputation Level)Viper_SB User rank is Brigadier General (60000 - 70000 Reputation Level)Viper_SB User rank is Brigadier General (60000 - 70000 Reputation Level)Viper_SB User rank is Brigadier General (60000 - 70000 Reputation Level)Viper_SB User rank is Brigadier General (60000 - 70000 Reputation Level)Viper_SB User rank is Brigadier General (60000 - 70000 Reputation Level)Viper_SB User rank is Brigadier General (60000 - 70000 Reputation Level)Viper_SB User rank is Brigadier General (60000 - 70000 Reputation Level)Viper_SB User rank is Brigadier General (60000 - 70000 Reputation Level)Viper_SB User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 20 h 16 m 27 sec
Reputation Power: 634
Quote:
Originally Posted by gimp
First, I think you just posted this.
Second, you might want to post this in a language-specific forum next time, probably java? Can a mod move this there?
Third, aren't you supposed to be doing homework with your brain, a book, a compiler, and an API? We don't really like homework questions here. We can prod you in the right direction if we see that you have put some effort into this. What do you have so far?
FYI gimp that is the whole point of this forum, for questions like this.

Reply With Quote
  #7  
Old September 4th, 2006, 07:44 PM
gimp's Avatar
gimp gimp is offline
<?PHP user_title("gimp"); ?>
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jan 2005
Location: Internet
Posts: 7,652 gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 2540 Folding Title: Novice Folder
Time spent in forums: 3 Months 6 Days 1 h 35 m 4 sec
Reputation Power: 6083
Send a message via AIM to gimp
Yeah, but I always assumed language-specific problems should be in language-specific forums? Guess I was wrong, then...

Reply With Quote
  #8  
Old September 4th, 2006, 10:32 PM
xlordt's Avatar
xlordt xlordt is offline
Only the strong survives!!.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2003
Location: A World of wonders.
Posts: 5,573 xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 11 h 9 m 33 sec
Reputation Power: 406
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt Send a message via Google Talk to xlordt Send a message via Skype to xlordt
Facebook MySpace
Quote:
Originally Posted by Viper_SB
FYI gimp that is the whole point of this forum, for questions like this.
Not for nothing.. but the post did sound like a language spacific problem though

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesGame Development > Half of a rectangle.

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap