TAILIEUCHUNG - C++ Programming for Games Module II phần 6

Tham khảo tài liệu 'c++ programming for games module ii phần 6', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Next we create a global vector of Shape pointers gShapes which will maintain all the shapes we have created so that we can draw all the shapes whenever a WM_PAINT message is generated. In addition we keep a global shape pointer gShape which will be the temporary shape we will draw while the user is moving the mouse around and deciding where exactly to make the shape permanent. Notice how we can talk about shapes in general. This is because of the polymorphism. Each shape will know how to draw itself correctly based on its concrete dynamic type that is if it is a LineShape then it will know to draw a line if it is a Rectshape then it will know to draw a rectangle and so on . vector Shape gShapes Shape gShape 0 Recall that the program allows the user to draw three kinds of shapes. The primitive menu item that is selected determines the shape that will be drawn at a given time. For example if the Line menu item is selected checked then the user can draw lines. If the Rectangle menu item is selected checked then the user can draw rectangles. File Primitive Pen Color Brush Color Pen style Brush style ự Line Rectangle Ellipse Figure User can select which type of shape to draw via the menu. We need to keep track of which primitive menu item is selected so that we know which kind of shape to create. To facilitate this we keep a global variable that keeps track of the currently selected primitive int gCurrPrimSel ID PRIMITIVE LINE Later in the WM_LBUTTONDOWN message handler we create the shape based on the currently selected type switch gCurrPrimSel case ID_PRIMITIVE_LINE gShape new LineShape p0 p1 gLogPen gLogBrush break case ID_PRIMITIVE_RECTANGLE gShape new RectShape p0 p1 gLogPen gLogBrush break case ID_PRIMITIVE_ELLIPSE gShape new EllipseShape p0 p1 gLogPen gLogBrush break In addition to keeping track of the selected primitive type we will also want to keep track of the selected pen and brush color and the selected pen and brush style. For this purpose we add the

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.