473,216 Members | 1,266 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,216 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 2183
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.