Create a 2D world [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Ive got a project for school that is to create the tanks game ( like worms or something else )
With a little research I found that the best way to create the 2D world would be to hold a bitmap of 1 and 0 to switch between background and foreground. So that I could load 2 images one for the background like the worms game the sea or something and another image with the map that is placed on it. Now because of that bitmap if I shoot something I could simply replace a 1 in a 0 so that there is a whole in the map..
With QT I could then just draw a canvas where I could display that bitmap.
I just don't find how to program this, maybe someone could help me out, where to start?

What you're describing with the 1's and 0's is called transparency and bitmaps can be made to encode this information in them, usually known as the alpha channel.
The key is to break down the problem into smaller parts and then tackle each small part - your question is very broad. So, break it down like this:
Create a window
Draw a bitmap on the window (no transparency - it's the background)
Draw a second bitmap with transparency
Modify transparency of second bitmap at run time

Although I think the qt is not the right tool for that, you can start with Graphics View Examples. That should give you a quick start.

Related

Using homography for a virtual monitor [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm currently working on a project where I need to create a virtual screen for feedback during a game
My program draws an image at a tracked position. What I wan't it to do is to have this image follow my 4 tracked points, so it scales and rotates.
What I need for this is to get the homography to work, and I'm sorry to ask this question, because I know there's a lot of different articles, and I've been trying to go through quite many of these, but they don't make much sense to me. The issue i'm facing right now is that I don't know how to.
I can get it to scale the texture or the content of the image but it remains the same format of height and width. It doesn't rotate it, right now since I don't have a update function for it yet, which I don't know how to create either. I need it to stretch the picture itself so it scales accordingly to the points tracked.
With this post I hope you can help me in the right direction for just scaling the format of my image accordingly, that would be a major break-through for me.
I'm using openframeworks with openCV and ofxCV addons in Codeblocks (C++) on windows 7.
There's some functions in the addons of ofxCv, I'm pretty confused about:
For instance, I have not much idea of how the "imitate();" works and what it does.
This neither:
"homography = findHomography(Mat(dstPoints), Mat(srcPoints);"
and the: "warpPerspective(origImg, warpImg, homography, CV_INTER_LINEAR);"
I'm not sure I'm using these correctly, and have had difficulties finding proper documentation on these, that makes sense to me.
Another thing I have doubts about, is the usage of matrices in regards to this task.
As you've propably already figured out, I'm really not an experienced programmer. Any help in the right direction would be much appreciated!
This is a paste of all of the code: http://pastebin.com/MFfJqGZ1
The most interesting part, or where I personally believe I'm missing something or have done something wrong is between line 199-223.
And heres the header file: http://pastebin.com/XfQySAmh
Thanks so much in advance
Best regards
Jesper

how to simulate a lamp in libgdx? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am using libgdx and I was wondering how to simulate a lamp.
What I mean is that I have a background texture and all the colors in it are pretty dark becuase it is suppose to a dark environment. What I want to do is to grab a region of the texture and make all the colors brighter like if it there was a lamp somewhere.
Now, the lamp is supposed to be moving and that will be calculated at run time so it is unpredictable to know where it would be, and the only thing that comes to my mind is to get every pixel from the texture and get the color and just change the rgb values to be higher to have that effect.
The thing is that the lamp is suppose to be moving a lot. It wont stop moving until the game is over and I feel that changing the color of every pixel is kind of a heavy process. Is there another way to it?
By the way, the game is a cartoon so I don't need the lamp too be realistic.
Could you instead layer an alpha blended transparency to darken the visible area except where the lamp is? I plan to use this to achieve a pseudo-lighting effect in a game.

Draw text around circle with C++ MFC functions [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have problem with text drawing around Circle.
I found great sample in C# http://www.codeproject.com/Articles/30090/Text-On-A-Path-in-WPF
Bu I need to implement this in VC 6.0 and C# sample isn't working for me for that reason.
Maybe exist some basic algorithm to implement this?
All drawings must be drawn in CDC.
CDC is a thin wrapper around GDI. GDI doesn't provide much support for what you want to do, so it will be a lot of work. Here are a couple of approaches:
Draw the text normally (in a straight line) to an off-screen DIB section, and then do a pixelwise transformation to make another off-screen DIB section with the text in a circle. Then you can blit the transformed DIB section to the output device.
For each character, create a logical font with the escapement and orientation set to the appropriate angle for the current position, then draw the character with that font. Repeat for each character. The problem here is that, even with TrueType or OpenType fonts, the rotations aren't always very good, depending on the quality of the font, hinting, etc.
Use a TrueType or OpenType font and get GDI to give you the vectors (line segments and bezier curves) that define the actual character shapes. Assemble these into a straight row, and then apply a Cartesian to polar coordinate transform. Draw the result using one of the path functions.

Pixel Manipulation with C++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I want to take an image in jpg format, split it up in pixels and then manipulate those pixels (duplicate them, change their position etc..)
Of course I'm not asking for the code :-) but the tools to do it. I am newbie in programming.
I know nothing about reading from an image, manipulating and outputing it. Do I need special libraries to import? Special commands to use in order to manipulate the image?
What I want to do is experiment with zooming a jpg to infinity by manipulating the number and position of pixels.
There are a few libraries that can be used for manipulating images. I recommend ImageMagick (see documentation for the C++ interface), but there's also DevIL.
Using ImageMagick, all the details are hidden from you, and manipulating the pixel data can be as simple as in this example:
Image my_image(); // create an *empty* image using the default Image constructor
my_image.read("picture.jpg");
my_image.pixelColor(50,50,Color("red")); // set the pixel at position (50,50) to red
my_image.write("saved_picture.jpg");
You can use CImg Library, Also you might find something on this list

How to create this desktop recorder? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want to create a desktop recorder that require very little HD space.
It should capture the current display into a buffer, compare it to the previous state, and save only the rectangles that differ to the previous state.
What API, function or library I have to use ?
Well if you want to save the differences from each frame to frame only you could simply use a substraction-method. Simply substract the color values at image(t+1) from image(t)... All parts that stay equal haven't changed... only the parts that are different will result in something non-zero. You can then extract the rectangles around it and save them. But of course be aware since there might be more than one part changing of course and you probably wanna save each one instead of the big rectangle that contains all changes...
You could use OpenCV for this... it has all basic functions for image substraction, rectangle fitting, cropping, ...
Hope that helps...
Consider using Windows Media Screen Capture encoder for the task. You will feed your captured frames to it, and it will do the rest and create highly efficient wmv file for you.