For my code, I am getting a value for lengths of x, y and z like "getXlength(x_length)" etc... I would like to know how I can use these values to draw the prism rather than giving values for each coordinates in each face.
// create code so that 2 rectangular prisms are created and all appropriate information is displayed. // In addition to displaying all appropriate information, determine which (if any) sides are squares; // print out how many square sides there are // The first is 2 x 3 x 4 (l x w x h) // For the 2nd one, add 2 to the length and the width of the first one.
So for my assignment, I have to write code to calculate the surface area and volume for a rectangular prism that involves the use of functions. I made the program without functions and it works perfectly but as I'm putting in the required functions, it conversely made it non-functional, ironically. How to call functions correctly and the online book we're using now is confusing me even more.
I'm making a program to draw a trajectory, was using as a basis the tangent, but when I put 90 degrees, the tangent is very large, so I thought of putting an if (angle == 90) did not use the tangent.
the design is right, but after choosing it 90 degrees it stops to draw.
for example
1-30 degrees - draws 2-45 degrees ---- draws 3 draws -90 degrees --- 4-60 degrees --- not drawing 5 --- 80 degrees --- not drawing * *
I'm in the beginning stages of designing my first video game using SDL, and have run into a bit of an impasse. I attempt to draw the map using a simple tile function and nothing prints to the screen. I am going to attach the function itself.
bool Tile::draw_tiles ( void ) { GV gv;
//Open the map std::ifstream map ( "test.map" ); for ( int y = 0; y < GV::MAP_HEIGHT / 64; y++ ) { for ( int x = 0; x < GV::MAP_WIDTH / 64; x++ ) {
[Code] ....
Extra notes: 1. Compiles fine. 2. No run time errors (this function returns true). 3. Apply surface is a function that takes an x and y value for position on the map, an image, a screen to print it to, and a rectangle to cut out the image out of. 4. I did some bug testing and added another function to print the image SDLS_tiles by itself (its just a simple sprite map) after the map.close() function, and it worked fine.
i have to make an application called " paint " in c++ . It should facilitate user to draw different shapes using a mouse. Now the biggest hurdle i am facing is the usage of mouse .. what is the header file for usage of mouse ? i am using visual studio 2010 . the syntax is creating problems ..
Found a good beginner's tutorial to learn Visual C++: [URL] ....
How to change the drawing so that instead of squares, the game draws circles. Can figure out that using Ellipse in the code results in circle outlines, but the fill remains as square color shapes.
The drawing code from the tutorial is below. How to substitute filled circles for filled squares.
Code:
// CSameGameView drawing void CSameGameView::OnDraw(CDC* pDC){ // First get a pointer to the document CSameGameDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if(!pDoc)
I'm doing a project and I need to draw a square into a pgm image if certain conditions are met, but I'm not sure how to draw the square into the image.
I've been given the task of converting a java application to a c# windows form application. The program displays a Mandelbrot which then allows the user to zoom into. I've managed to display the Mandelbrot and even zoom. However when dragging a box to zoom, the box its self doesn't show, meaning the user cannot see what area they will be zooming into.
I believe I need to call the update function which draws the rectangle as I drag however no matter what I try, I get errors from a red cross instead of the Mandelbrot to compile errors. Here is the code that I believe is relevant.
public void update(Graphics g) { Color color = Color.White; Pen myPen = new Pen(color); g.DrawImage(myBitmap, 0, 0); if (rectangle) {
Now I got rid off the white border but everytime I draw a text it write on top of the previous text so after few seconds everything is a mess and the time is no longer readable.
1) Write a program that asks the user for a a single character and two XY coordinates. The two X and two Y values should all be integers between 0 and 50. The character should be a printable ASCII character with values between and including ' !' (ascii value 33) and '~' (ascii value 126).
2) Your program should then draw a rectangle made up of the user selected character where the upper left corner is at X1; Y 1 and the lower right corner is at X2; Y2. Be sure to print the appropriate number of blank lines (having spaces in the blank rows is OK) in the beginning and pad each row of your rectangle with X1 leading spaces.
The Output is supposed to be similar to this:
(X1,Y1) = (0,0) , (X2,Y2) = (4,4), the character = ^
^^^^ ^^^^ ^^^^ ^^^^
What I am having trouble understanding is printing between certain ASCII values (ASCII has never been discussed in class).
Another thing I am having trouble with is the main part of the assignment. From what we are currently discussing is loops and the assignment is covering nested loops. My code looks similar to this: Code:
#include <stdio.h> int main (void) { int X1, Y1, X2, Y2; char cRec; printf("Enter a character: "); scanf("%c", &cRec);
[Code] .....
My thinking on the assignment is that you want the X1 coordinate to increase to the value of X2 (same for Y1 and Y2). Is this thinking wrong?
Make an "analog clock" that is, a clock with hands that move. You get the time of day from the operating system through a library call. A major part of this exercise is to find the functions that give you the time of day and a way of waiting for a short period of time (e.g., a second for a clock tick) and to learn to use them based on the documentation you found. Hint: clock(), sleep().
OK, I wrote below code. It is in its primary stages and has not been completed yet.
#include <GUI.h> #include <time.h> #include <iostream> using namespace Graph_lib;
[Code] .....
I expect the system in void clock_hands() (line 38) attaches hour1 (line 41) then waits for 1000 ms (using Sleep(1000)) then detaches hour1 and attaches hour2 this time. But it doesn't occur in practice. When the system reaches Sleep(1000); it seems to go into a comma! It doesn't show the hour1 so seeing the movement of clock ticks by the clock's hands will not be possible.
I am working on a code and first i need to initialize the array depending on the size (min size 3x3, maximum size 9x9). The initialized array will descend in order. Note that it seems like a simple code and seems to work for any size from 3x3 to 7x7, but for some reason i get a strange output in the last few rows for 8x8 and 9x9. Not sure why. The second part to my problem is the very last digit of 0. I did hard code to define it but i would like to make it a character like an underscore...what is the easy way to do this?
* Implements the Game of Fifteen (generalized to d x d). * * Usage: ./fifteen d * * whereby the board's dimensions are to be d x d, * where d must be in [MIN,MAX] * * Note that usleep is obsolete, but it offers more granularity tha sleep and is simpler to use than nanosleep; `man usleep` for more.
I am drawing in a simple (square) MFC window. I realize that (0,0) starts in the upper left hand corner. I wanted to see how MFC handled drawing of angles, so I use this code:
Code: double CompassDegreesToRadians(double compassDegrees) { return((PI / 2.0f) - (compassDegrees * PI / 180.0f)); } // Make pen CPen penRed; penRed.CreatePen(PS_SOLID | PS_COSMETIC, 1, RGB(255, 0, 0)); // Test Angles
[Code] .....
Using this code, and changing the value of angle1 to these values (0, 90, 180, 270) I think MFC uses the coordinate system:
This seems like a strange coordinate system to use. Am I doing something wrong? If this is correct, how can I convert my calculations to this coordinate system? (compass degrees):
I am trying to figure out how to create a program that will draw a triangle using *'s with a base the has a user-inputted number of *'s like so:
* *** *****
It needs to take a user inputted number and draw a pyramid like the above pyramid with the number of *'s in the base matching the user inputted number (i.e., user enters 10, so the triangle has 10 *'s in the base). I figured it would be best to first create a loop to draw out the correct number of *'s before trying to create another loop to draw out the correct number of spaces, to properly align the *'s into a triangle shape.
int width = 0; int height = 0; int i = 0; int leafWidth = 0;
In 2D games, what's the best way to handle the order of drawing objects? Because most games have a background, tiles to be drawn behind the player, perhaps tiles to be drawn covering up the player, etc. My point is, with my current setup of simply looping through all objects and drawing, I have no control over what objects are drawn on top of or behind the others. My best idea so far is to hold a vector of object pointers, each vector representing a different "visibility level", like so:
class Level{ //... std::vector<Object> allObjectInstances; std::vector<Object*> visibilityOne; //background objects std::vector<Object*> visibilityTwo; //objects in front of background but not necessarily all the way in front //and so on for more objects };
If I go through with this, I'm wondering how I could loop through all my objects and add them to each vector, then shorten whatever I have to loop through for subsequent visibility vectors. handling the order of drawing objects?
I'm having issues with drawing a flat style dropdown menu in XP.
Here is the custom dropdown menu element:
public class FlattenCombo : ComboBox { private Brush BorderBrush = new SolidBrush(SystemColors.WindowFrame); private Brush ArrowBrush = new SolidBrush(SystemColors.ControlText); private Brush DropButtonBrush = new SolidBrush(SystemColors.Control); public Color HighlightColor { get; set; }
[Code] ....
Here is what it looks like in XP:
And here's what it should look like (this is how it's rendered in Windows Vista/7):
I want to show a list of graphical items in 1 or 2 columns (user selected). I will draw the items (owner-draw). I tried many hours today to find a solution with clistctrl. Is it possible to make it with clistctrl?
The question says: Make an "analog clock" that is, a clock with hands that move. You get the time of day from the operating system through a library call. A major part of this exercise is to find the functions that give you the time of day and a way of waiting for a short period of time (e.g., a second for a clock tick) and to learn to use them based on the documentation you found. Hint: clock(), sleep().
OK, I wrote below code. It is in its primary stages and has not been completed yet.
Code: #include <GUI.h> #include <time.h> #include <iostream> using namespace Graph_lib; //--------------------------------- class Dynamic_clock : public Window {
[Code] .....
I expect the system in void clock_hands() (line 38) attaches hour1 (line 41) then waits for 1000 ms (using Sleep(1000)) then detaches hour1 and attaches hour2 this time. But it doesn't occur in practice. When the system reaches Sleep(1000); it seems to go into a comma! It doesn't show the hour1 so seeing the movement of clock ticks by the clock's hands will not be possible.
How I can make 2D games in OpenGL. I have sprites, but when I load them in game, they're all big and stuff, not pixel for pixel how I'd like them. How can I do this?
I am because I don't know what to use OpenGL or DirectX? I heard some people saying I can use both. How is this? What is better for online games? And when I choose I will need some tutorials too ....