473,395 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Shape DragOver and DragDrop

PM
Hi,

Im a student currently designing a game for a project.

As part of my game, I want to be able to drag a shape over a series of
panels. The shape needs to be able to be dropped on any of the panels.

If the shape is dropped outside any of the panels, I want it to be
returned to its original position.

Does anyone have any hints to the code I should be using?

Thanks

Jan 3 '06 #1
3 2191
PM wrote:
Hi,

Im a student currently designing a game for a project.

As part of my game, I want to be able to drag a shape over a series of
panels. The shape needs to be able to be dropped on any of the panels.

If the shape is dropped outside any of the panels, I want it to be
returned to its original position.

Does anyone have any hints to the code I should be using?

Thanks


You want to post in comp.sources.wanted. This group is for discussing
C++ *language* issues, not platform-dependent applications. See the FAQ
for what is on topic here and for some additional suggestion of where
to post:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

Cheers! --M

Jan 3 '06 #2
PM wrote:
Hi,

Im a student currently designing a game for a project.

As part of my game, I want to be able to drag a shape over a series of
panels. The shape needs to be able to be dropped on any of the panels.

If the shape is dropped outside any of the panels, I want it to be
returned to its original position.

Does anyone have any hints to the code I should be using?

Thanks


Hi,

This news group discuss the C++ language as defined by the ANSI/ISO
standard; Therefore, I assume that your "game", "shape" and "panel"
objects are standard C++ classes and further assume that you have the
methods "drop(const shape&)" and "position()" implemented somewhere in
your code.

If so, I guess you need a loop over all panels and an if-statement to
check that the shape is within all panels and a method to set the
position of your "shape" object.

If not, go to a more appropriate news group.

Regards,
Peter Jansson
http://www.jansson.net/
Jan 3 '06 #3
It will depend heavily on the GUI framework you're using, and specific
questions about that will have to be addressed in another forum than
this one. However, I can give you a general indication of how that
functionality is likely to be implemented.

GUIs are generally implemented with an event loop. Events such as
mouse clicks occur, and you write handlers for them. Often it's rolled
up into a big switch statement, with a case for each kind of event.
Some pseudocode for a case like you described:

void processEvent(Event e) {
switch (e.eventType) {
case MOUSE_DOWN:
// Grab hold of a shape
break;
case MOUSE_UP:
if (draggingShape)
if (inPanel())
dropShape();
else revertShape();
break;
// etc.
}
}

HTH,
Luke

Jan 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Kate | last post by:
Hi: I have a form with a picture box and some command buttons to make certain shapes appear in the picture box. The shapes are drawn on blank UserControls added like this: 'at top of form...
0
by: asra_baig | last post by:
Wherever I see the dragOver(DropTargetDragEvent ev) method in the examples, it calls the dropTargetDrag(DropTargetDragEvent ev) method which calls ev.acceptDrag method. I can't seem to find when is...
1
by: KS | last post by:
In want to visualy drag a Button to a Label and when I depress the mousebutton on top of the label I want to show some dato from the Button in a MsgBox - that's my primary goal. I have made a...
0
by: Flack | last post by:
Hello, Is it possible to find out how many methods are listening to a certain event? For example, if a number of methods subscribed to a controls DragDrop event using +=, can I find out how many...
0
by: Gene Hubert | last post by:
Well, it seems fundamental to me anyway. Hopefully it is simple enough. The question is for when the source for the dragdrop is a different application that the target for the dragdrop. How...
3
by: Gary Dunne | last post by:
I'm writing an app that requires drag and drop operation between a ListView and a TreeView control. (The source is the ListView). During the drag drop operation I want to be able to detect the...
7
by: JohnR | last post by:
I am using dragdrop to drag and drop a custom class instance. When I drag/drop from one window to another window in the same application everything works fine. But when trying to move between the...
1
by: Gary Brown | last post by:
Hi, I just implemented drag drop in one of my programs. In researching there are implementations that use DragEnter, a few use DragOver, and a some use both. From the available documentation...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.