Game Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old October 14th, 2006, 11:43 AM
william_nagels william_nagels is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Location: belgium
Posts: 101 william_nagels User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 27 m 7 sec
Reputation Power: 2
Send a message via MSN to william_nagels
Making a radar

hi guys (and, or girls)
I'm building on a weird radar program but there is no collision detection, btw I'm building in java.
It says standing on no hit and doesn't change in hit when it enters the big green field.

here is my code

Code:
import java.awt.*;
import java.applet.*;

public class radar extends Applet implements Runnable
{
    Thread runner;
    Image Buffer;
    Graphics gBuffer;
    int angle;
    Rectangle hit;
    Rectangle target;
    boolean bhit;
    boolean stap1;     

    public void init()
    {   hit=new Rectangle(110,115,10,10);
        target= new Rectangle(200,0,200,200);
        Buffer=createImage(size().width,size().height);
        gBuffer=Buffer.getGraphics();
        
    }

    public void start()
    {
        if (runner == null)
        {
            runner = new Thread (this);
            runner.start();
        }
    }

    public void stop()
    {
        if (runner != null)
        {
            runner.stop();
            runner = null;
        }
    }

    public void run()
    {
        while(true)
        {   bhit  = hit.intersects(target);
            if(bhit){stap1=true;}
            else if (!bhit){stap1=false;}
            try {runner.sleep(10);}
            catch (Exception e) { }
           
            repaint();
        }
    }

    void drawStuff()
    {   
        gBuffer.setColor(Color.black);
        gBuffer.fillRect(0,0,size().width,size().height);
        Point p=new Point(size().width/2, size().height/2);   
        int LENGTH=140;
        double vector = angle * Math.PI*2 / 360.0;
        int vx=(int)(p.x+LENGTH*Math.sin(vector));
        int vy=(int)(p.y-LENGTH*Math.cos(vector));


        hit= new Rectangle(p.x,p.y,vx,vy);
        //r2.move ( r2.x,r2.y-4);
        gBuffer.setColor(Color.green);
        gBuffer.drawLine(hit.x,hit.y, hit.width ,hit.height);
        gBuffer.fillRect(target.x, target.y, target.width, target.height);
        gBuffer.setFont(new Font("Helvetica",Font.PLAIN,13));
        gBuffer.drawString("Angle="+angle+"°",10,20);
        
        if(angle<360) angle++;
         else angle=0;
         if(stap1){gBuffer.drawString("hit!!!!!!!!!",20,30);}
         else    {gBuffer.drawString("no hit",20,30);}

         }

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

    public void paint(Graphics g)
    {
        drawStuff();
        g.drawImage (Buffer,0,0, this);
    }
}

Reply With Quote
  #2  
Old October 14th, 2006, 11:53 AM
Oler1s Oler1s is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2006
Posts: 1,405 Oler1s User rank is Major (30000 - 40000 Reputation Level)Oler1s User rank is Major (30000 - 40000 Reputation Level)Oler1s User rank is Major (30000 - 40000 Reputation Level)Oler1s User rank is Major (30000 - 40000 Reputation Level)Oler1s User rank is Major (30000 - 40000 Reputation Level)Oler1s User rank is Major (30000 - 40000 Reputation Level)Oler1s User rank is Major (30000 - 40000 Reputation Level)Oler1s User rank is Major (30000 - 40000 Reputation Level)Oler1s User rank is Major (30000 - 40000 Reputation Level)Oler1s User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 3 Weeks 6 Days 1 h 29 m 8 sec
Reputation Power: 376
Quote:
Originally Posted by william_nagels
here is my code


Very nice. Anything else you would like to add to that? One of the guidelines in asking questions, is uh, ask a question...

And be specific. Something like is my code correct doesn't help. What is that compiling, trying to fix the code on your own, and googling, couldn't solve?

Reply With Quote
  #3  
Old October 14th, 2006, 11:57 AM
william_nagels william_nagels is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Location: belgium
Posts: 101 william_nagels User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 27 m 7 sec
Reputation Power: 2
Send a message via MSN to william_nagels
my question is (off course :s) why isn't there a collision detection.
Believe me i googled enough

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesGame Development > Making a radar


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway