I am making a game Pong, and have been struggling with the collision aspect between the baal hitting off the paddle. I have created a Class, to draw a rectangle, to work with collision however I dont know how to assign the rectangle to the images of the ball and paddle.
Point p1(100,100); Point p2(300,200); Graph_lib::Rectangle r(p1,p2);
And also I have a function that takes a rectangle and returns a Point of that, say, top-left corner of that rectangle. For example:
Point N(Graph_lib::Rectangle R1);
My question is that, first, how to send that Rectangle r(p1,p2) to the Point N(Graph_lib::Rectangle R1) function? And then, how to return a Point from that function?
the code draws rectangle or square it depends on you (column,row) then, put number in the center of the rectangle i don't want to extra space after putting one,two,three or four digits number in the center of the rectangle
I'm trying to make a program that prints a rectangle using "*" asterisks. I am only allowed to use "for loops" and I simply cannot get this to work properly. Here is my code so far...
Code: int main(void) { //RectangleSize represents the area of the rectangle(width*length) int length, width, RectangleSize;
how to use 3 variables to represent a rectangle in a grid instead of using 4. The traditional way is to use (x,y) (x2,y2). I propose using (x,l,h).In the traditional way as you probably know, (x,y) is the left op most corner, and (x2,y2) is the bottom right most corner. In the way I am proposing X is the left side, l is the length of the top side, and also the length of the bottom. 'h' is the height of the left and right. I think it's obvious how these three can define a rectangle same as the four.
I have having trouble looping through the list in the update section to update each object in the rectangleList. I am not sure how to format it because it is only drawing one and it does not move across the screen. I thought this section of code would work and loop through each object and make each one move but it does not.
for (int i = 0; i < rectangleList.Count; i++) { enemyPosition = new Rectangle(rectangleList[i].X + 2, rectangleList[i].Y ,enemyPosition.Width,enemyPosition.Height); } List<Rectangle> rectangleList; protected override void Initialize() { rectangleList = new List<Rectangle>();
I am new to C and am unfortunately racking my brain against this simple assignment. I believe the task is to produce a rectangle out of asterisks using while loops, yet I can only produce an "L" shape. We were given a code, with syntax errors included.We are to correct the errors and test.
Code:
#include <stdio.h> /*Houghton, Micah*/ /*ET2560 - Cordova*/ /*Unit 5 Lab - Programming Loops*/ int main(void) { int length, width; int lcount, wcount;
#include <iostream> #include <cmath> using namespace std;
//prototypes for all separate functions int chooseFunc(int); int chooseMethod(int); int numRect(int);
[Code] .....
It seems that my program will ask the user for the number of rectangles and trapezoids but will fail to compute the area under the curve from the user input. Therefore, I believe I have a logical error somewhere or I'm forgetting to call something somewhere.
[URL] .... This is what I have so far, and it isn't incorrect, but how to improve this or make it more accurate?
// subtracting the area of two circles from a rectangle #include <iostream> using namespace std; int main() { cout << "This program is designed to calculate the area of a rectangle, to exclude the area of 2 circles that have been placed inside of the rectangle." << endl << endl;
Define functions n(), s(), e(), w(), center(), ne(), se(), sw() and nw(). Each takes a Rectangle argument and returns a Point. These functions define connection points on and in the rectangle. For example, nw® is the northwest (top-left corner) of a rectangle called r.
I wrote below code for that:
#include <Simple_window.h> Point n(const Graph_lib::Rectangle& r); Point s(const Graph_lib::Rectangle& r); Point e(const Graph_lib::Rectangle& r); Point w(const Graph_lib::Rectangle& r); Point ne(const Graph_lib::Rectangle& r); Point se(const Graph_lib::Rectangle& r);
[Code]...
As you see, this just mark the top-left corner of the rectangle r. In other functions I need the specifications of that rectangle, for example its height and width. How to use these specs in those functions?
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) {
Write a program that prompts the user to input the length of a rectangle and the width of a rectangle and then displays the rectangle's area and perimeter. The program should be broken down in 3 parts:
1. Input the length and the width (two input statements)
2. Calculate the area & perimeter (results should be saved in variables
3. print results.
Format the output so the user can easily read the results. Use the tab escape so its easy to read. --------------------------------------------------------------- So here's what I have so far. I have been stuck for two days
#include iostream using namespace std; int main () { int double length; int width; int area; int perimeter;
[Code] ....
I dont want to get a zero for not turning this in...
I am writing a program to calculate a rectangle's area.
Eg. Enter top left point: 1 1 (User input) Enter bottom right point: 2 -1 (User input) Top Left x = 1.000000 y: 1.000000 Bottom Right x = 2.000000 y: -1.000000 Area = 2.000000 (Program output)
It keeps on prompting me my variable r is being used without being initialized, when I think I already did so.
I'm trying to create a PPM image for a class assignment. A black rectangle with a circle at the point 225, 175 with a radius of 75. I have to use certain specific methods, so I can't use like Bresenham's really famous method for creating a circle.
The problem is that it compiles fine, and transfers to an image fine, but always says that I have a negative or zero image size.
I'm having some issues understanding why the "rectangle" in the following code isn't resizing properly. Here's the code:
#include <iostream> using namespace std; class Rectangle { public: Rectangle(double w, double h, double f) : width(w), height(h), factor(f)
[Code] .....
I tested the code with a simple multiplication factor of "2", which should result in a new width and height of 4, but instead I get an odd value that seems be close to 4.
Output:
Numerically enter the width of the rectangle: 1 Numerically enter the height of the rectangle: 1
The width of the rectangle is: 1 The height of the rectangle is: 1 The area of the rectangle is: 1 The perimeter of the rectangle is: 4
Numerically enter a number to resize the rectangle: 2
The width of the rectangle after resizing is: 2.07408e-317 The height of the rectangle after resizing is: 2.07408e-317
I'm trying to find the fastest method to find whether or not two rectangles intersect in an effort to streamline my code. I've built this function into a rectangle class I created below.
struct rectangle{ rectangle() :X1(0), Y1(0), X2(0), Y2(0) {}; rectangle(int X1, int Y1, int X2, int Y2) :X1(X1), Y1(Y1), X2(X2), Y2(Y2) {};