Created
September 29, 2011 16:54
-
-
Save torazuka/1251258 to your computer and use it in GitHub Desktop.
Chapter13_drill_PPPC++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Simple_window.h" | |
#include "Graph.h" | |
int main() | |
{ | |
// ドリル(1) | |
Simple_window win1(Point(20, 20), 800, 1000, "Chapter13 Drill"); | |
// ドリル(2) | |
int x_size = 800; | |
int y_size = 800; | |
int x_grid = 100; | |
int y_grid = 100; | |
Lines grid; | |
for(int x = x_grid; x < x_size; x += x_grid){ | |
grid.add(Point(x, 0), Point(x, y_size)); | |
} | |
for(int y = y_grid; y < y_size; y+= y_grid){ | |
grid.add(Point(0, y), Point(x_size, y)); | |
} | |
win1.attach(grid); | |
// ドリル(3) | |
Vector_ref<Graph_lib::Rectangle> rec; | |
for(int i = 0; i < x_size; i += x_grid){ | |
rec.push_back(new Graph_lib::Rectangle(Point(i, i), x_grid, y_grid)); | |
} | |
for(int i = 0; i < rec.size(); i++){ | |
rec[i].set_fill_color(Color::red); | |
win1.attach(rec[i]); | |
} | |
// ドリル(4) | |
Image img1(Point(200, 0), "hoge.jpg"); | |
Image img2(Point(400, 200), "hoge.jpg"); | |
Image img3(Point(600, 400), "hoge.jpg"); | |
win1.attach(img1); | |
win1.attach(img2); | |
win1.attach(img3); | |
// ドリル(5) | |
int x_p = 0; | |
int y_p = 0; | |
Image img4(Point(x_p, y_p), "moga.jpg"); | |
win1.attach(img4); | |
while(x_p < x_size && y_p < y_size){ | |
win1.wait_for_button(); | |
img4.move(x_grid, y_grid); | |
x_p += x_grid; | |
y_p += y_grid; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment