GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Apr-2009, 06:37
S8G Legend SG S8G Legend SG is offline
New Member
 
Join Date: Feb 2009
Posts: 4
S8G Legend SG is on a distinguished road

Tower Defense Game UI


Im designing a tower defense game, so far i have the game logic figured out, i just need to coordinate my control panel and my game panel.

when there is a mouse click, I iterate through all my panels and check to see which panel the click happend in, that panel's response method is called.

im trying to be able to click on a "Button" in my control panel, and the next time i click on a point in the Game Panel, a new Tower is placed there, if that point is not on my creep's "path"

JAVA Code:
 public synchronized void handleMouseClick(MouseEvent e)
    {
        if(control.hasTower())
        {
            if(map.hasPoint(e.getPoint()))
                ;
            else
            {
                entityManager.add(new BasicTower(new Point2D(e.getX(), e.getY())));
            }
        }
    }

void handleClick(MouseEvent e) 
    {
        if(TB.hasPoint(e.getPoint()))
        {
            hasTower = true;
        }
        else
            hasTower = false;
    }

JAVA Code:
public boolean hasPoint(Point p)
    {
        if(p.x >= location.getX() && p.x <= location.getX() + width)
        {
            if(p.y >= location.getY() && p.y <= location.getY() + width)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        else
            return false;
    }
Last edited by admin : 28-May-2009 at 06:08. Reason: Please insert your Java code between [java] & [/java] tags
  #2  
Old 28-May-2009, 05:53
Mexican Bob's Avatar
Mexican Bob Mexican Bob is offline
Regular Member
 
Join Date: Mar 2008
Location: Chicxulub, Yucatán
Posts: 342
Mexican Bob is a jewel in the roughMexican Bob is a jewel in the roughMexican Bob is a jewel in the roughMexican Bob is a jewel in the rough

Re: Tower Defense Game UI


Quote:
Originally Posted by S8G Legend SG
when there is a mouse click, I iterate through all my panels and check to see which panel the click happend in, that panel's response method is called.

Why not e.getComponent? Why iterate at all?


MxB
 
 

Recent GIDBlogVista ?Widgets? on Windows XP by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with a simple "dragon" game. ddaigle C++ Forum 13 04-Dec-2007 06:06
Tips for game troubleshooting pcxgamer Computer Software Forum - Games 0 02-Jan-2004 05:27

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 05:28.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.