1 )I am currently making 2d tank game. I need to make panel where I could draw information about tanks etc. What is the best way to do that? Do I need to make 2 viewports (1 for game and 1 for panel) or what?
You could make a fixed area to show the information within your gui/hud. Or you could popup the text when you hover over a text. So locate where the mouse is at and if it hovers over a sprite start drawing the text at the cursor location.
Related
I'm working with opencv and I want to do the following procedure:
Every second I check the difference between the current position of the mouse and the position it was 1 second ago.
Then I want to draw a line in my screen, from the position 1 second ago and the current position. This line should stay on the screen for 1 second until the difference is evaluated again, so the line should be renderer in the new position.
I've already done all the logics, position calculations and everything. What I want to know is how to draw a line in my screen. I wish to use my PC normally while I can see those lines, that means clicking with the mouse, keyboard events and opening windows should not stop the lines from being renderer on my screen.
How can I do that?
That isn't trivial.
You need some GUI toolkit that can show a window with the following properties:
full-screen
no window decoration (title bar...)
always-on-top
"intangible", i.e. allowing mouse and keyboard events to pass through to whatever other windows are underneath it
a working alpha channel (per-pixel transparency)
That's the general idea. Pick a popular GUI toolkit, then google around. You'll likely find ways to do each and all of those points.
I don't think OpenCV does this. Its GUI facilities are a convenience, not flexible to this degree.
I am currently building a game on swift, using Storyboards. The game revolves around generating income from fishing lobsters. Users have lobster pots, which they can place into either inshore or outshone regions of the water. With no prior experience. I have minimal knowledge on how to code in swift.
My problem at the moment is understanding collision detection. There are three regions of the screen where the users can drag their pots into. The first screen is the starting position of the lobster pots, from which the player must drag the pots into either inshore or offshore locations. Currently, I have managed to code the action of dragging and dropping the pots, so they can be placed into any point on the screen. What I hope to do is to be able to have the pots to snap into position when the pots are dropped within the regions of either the inshore of offshore boxes. Furthermore, when the pots are dropped into place, I would like them to be organized in a row, equally spaced, and dropping into a row below, filling up the box.
Image -
I think I should also mention that the background is an image view, taken as a screenshot of the view when the game is running. I did this to avoid layering, as some pots would sometimes move behind the boxes when dragging them.
Thanks in advance.
Here some ideas:
You already have the code to move the tiles, that's good. All you now need is same math.
Although your background is an image, you also need some data model to keep, where your stuff is (or where your pots belong to). It is important to know, if a pot is in "My Pots" or "Inshor" or "Outshore". This information has to keep in some objects, like "myPots" and "inshore" and so on.
So dragging doesn't only move the pots on screen, it also changes where a pot belong to.
Hint: A representation of a area (myPots, ...) can be done with invisible areas. Invisible, because you already have the background. But a invisible rectangle gives you the ability to resize the ui without complicated re-calculations.
I would devide the area like this:
The coordinates are just examples for better understanding.
Most game engines work with coordinate (0,0) at top left.
So if you drag and release a pot, you have to calculate the end point of drag and compare it with your areas. No complicated collision detection necessary, because you only test if a point is in an area. But if you want collision detection, search for AABB collision detection (like here https://studiofreya.com/3d-math-and-physics/simple-aabb-vs-aabb-collision-detection/).
In your case it would be enough to have the decision:
if draggedPot.endCoordinate.y > 100 {
// in or out shore
if draggedPot.endCoordinate.x > 300 {
// outshore
}
else {
// inshore
}
}
else {
// still in myPots
}
I hope you get the idea :)
For arrange in a row it's also some math. Loop over the pots in an area, place one by one, always start-x + width-of-pot + some space. If this is greater than width of the area, set y to height of pot + some space and x starts at zero.
When a user is drawing a polygon on a map in draw mode in openlayers 3, I am detecting whenever they have any lines that self-intersect, and when this is the case, I want to prevent them from drawing any new points until the lines no longer intersect. I am able to detect when lines are intersecting, but I am having difficulty disabling the user from being able to click the map and putting down more points when the intersecting lines condition is true. Does anyone know how I could do this with openlayers 3? Thank you!
I was able to solve this by creating a tiny no click div that followed around the mouse. When I detected that two lines were intersecting I increased the z-index of this div above the map using jquery so the map could no longer be clicked on.
I have a globe, similar to http://mrdoob.github.com/three.js/examples/webgl_trackballcamera_earth.html.
My globe has some spots on different locations (f.ex. Paris, Rome or London). Whenever one of these spots come into view, a popup window with additional information to that location should popup appear, and again disappears when that spot rotates out of view, quite similar to http://workshop.chromeexperiments.com/cloudglobe/.
You need 3D coordinates of those points and you need to transform(rotate or whatever) them with globe. Then use this code http://www.opengl.org/wiki/GluProject_and_gluUnProject_code to get screen space coordinates of those points. After that it is simple question of HTML, CSS and some javascript. You know where they are on screen so, for example, you can put some absolute positioned divs with text. But you will need to check on which side of globe those spots are - use rotation phase of the sphere or z-coordinate of the point or simple do color-based picking to see if this spot is visible.
Radial menus have started appearing in several places. I'm curious whether anyone has seen or is working on a radial menu component for Delphi? We have a concept of what we'd like, shown in the animated gif at http://jmrsoftware.delaneyjoi.com/wheel.gif. (It takes about 10 seconds for the menu animation to start.)
alt text http://jmrsoftware.delaneyjoi.com/wheel.gif
Does anyone know of a component for Delphi that has similar functionality?
Thanks
Radial or "pie" menus are underrated but are praised in HCI circles for being easy to use in a precise fashion. People find it easier to remember the path to an item on a radial menu that on a traditional linear-style menu, where the cursor needs to stay within a precise area to prevent a whole cascade of submenus from disappearing.
I've not seen a Delphi component that does it, but having coded them before in Delphi I'd recommend a package like Graphics32, perhaps deriving your pie menu from a paint box or image control that covers the entire form with a transparent overlay, and then renders/animates pie segments on top of that.