回答編集履歴
3
コード修正
test
CHANGED
@@ -110,13 +110,7 @@
|
|
110
110
|
|
111
111
|
if (Drag) {//ドラッグ中は線を引く
|
112
112
|
|
113
|
-
DrawLine(BposX, BposY, posX, posY, 0x0);
|
113
|
+
DrawLine(BposX, BposY, posX, posY, 0x0, 3);
|
114
|
-
|
115
|
-
DrawLine(BposX - 1, BposY, posX - 1, posY, 0x0);
|
116
|
-
|
117
|
-
DrawLine(BposX, BposY - 1, posX, posY - 1, 0x0);
|
118
|
-
|
119
|
-
DrawLine(BposX - 1, BposY - 1, posX - 1, posY - 1, 0x0);
|
120
114
|
|
121
115
|
BposX = posX;
|
122
116
|
|
@@ -256,250 +250,234 @@
|
|
256
250
|
|
257
251
|
|
258
252
|
|
259
|
-
|
253
|
+
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
260
254
|
|
261
255
|
{
|
262
256
|
|
257
|
+
//初期化前の設定
|
258
|
+
|
259
|
+
ChangeWindowMode(TRUE);
|
260
|
+
|
261
|
+
SetGraphMode(WIN_WIDTH, WIN_HEIGHT, 32);
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
//DXライブラリ初期化
|
266
|
+
|
267
|
+
if (DxLib_Init() == -1)return -1;
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
//背景色設定
|
272
|
+
|
273
|
+
SetDrawScreen(DX_SCREEN_BACK);
|
274
|
+
|
263
|
-
|
275
|
+
SetBackgroundColor(255, 255, 255);
|
276
|
+
|
277
|
+
|
278
|
+
|
264
|
-
|
279
|
+
int linesegMaX = 1000;
|
280
|
+
|
281
|
+
int linesegCnt = 0;
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
lineseg *bline;
|
286
|
+
|
287
|
+
bline = (lineseg*)malloc(linesegMaX * sizeof(lineseg));
|
288
|
+
|
289
|
+
if (bline == NULL) {
|
290
|
+
|
291
|
+
return -1;
|
292
|
+
|
293
|
+
}
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
//マウス情報用変数
|
298
|
+
|
299
|
+
int posX, posY;
|
300
|
+
|
301
|
+
bool Drag = false, PenF = true;
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
//キー入力用変数
|
306
|
+
|
307
|
+
char KeyBuf[256];
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
//メインループ
|
312
|
+
|
313
|
+
while (!ProcessMessage())
|
314
|
+
|
315
|
+
{
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
//キー入力
|
320
|
+
|
321
|
+
GetHitKeyStateAll(KeyBuf);
|
322
|
+
|
323
|
+
if (KeyBuf[KEY_INPUT_1] == 1) { PenF= true; }
|
324
|
+
|
325
|
+
if (KeyBuf[KEY_INPUT_2] == 1) { PenF = false; Drag = false; }
|
326
|
+
|
327
|
+
if (KeyBuf[KEY_INPUT_0] == 1) { linesegCnt = 0; }//メモリ解放はしていない…
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
//マウス座標取得
|
332
|
+
|
333
|
+
GetMousePoint(&posX, &posY);
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
//マウス入力処理
|
338
|
+
|
339
|
+
if (GetMouseInput() & MOUSE_INPUT_LEFT) {
|
340
|
+
|
341
|
+
//ドラッグ中は座標を追加
|
342
|
+
|
343
|
+
//(前と座標が同じでも追加されるので、メモリ節約したい場合は移動した時だけ追加するようにした方がいい…)
|
344
|
+
|
345
|
+
bline[linesegCnt].BlackLineX = posX;
|
346
|
+
|
347
|
+
bline[linesegCnt].BlackLineY = posY;
|
348
|
+
|
349
|
+
if(PenF){
|
350
|
+
|
351
|
+
if (Drag) {//ドラッグ中は線を引く
|
352
|
+
|
353
|
+
bline[linesegCnt].Ptype = Pen;
|
354
|
+
|
355
|
+
}
|
356
|
+
|
357
|
+
else {//ドラッグ開始
|
358
|
+
|
359
|
+
Drag = true; //ドラッグフラグをオンにする
|
360
|
+
|
361
|
+
bline[linesegCnt].Ptype = Non;
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
else {
|
368
|
+
|
369
|
+
bline[linesegCnt].Ptype = Eraser;
|
370
|
+
|
371
|
+
}
|
372
|
+
|
373
|
+
linesegCnt++;
|
374
|
+
|
375
|
+
//メモリが足りなくなったら拡大
|
376
|
+
|
377
|
+
if (linesegCnt == linesegMaX) {
|
378
|
+
|
379
|
+
linesegMaX += 1000;
|
380
|
+
|
381
|
+
lineseg* tmp = (lineseg*)realloc(bline, linesegMaX * sizeof(lineseg));
|
382
|
+
|
383
|
+
if (tmp == NULL) {
|
384
|
+
|
385
|
+
free(bline);
|
386
|
+
|
387
|
+
return -1;
|
388
|
+
|
389
|
+
}
|
390
|
+
|
391
|
+
bline = tmp;
|
392
|
+
|
393
|
+
}
|
394
|
+
|
395
|
+
}
|
396
|
+
|
397
|
+
else {//マウスのキーは押されていない
|
398
|
+
|
399
|
+
if (Drag)Drag = false; //ドラッグフラグをオフにする
|
400
|
+
|
401
|
+
}
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
//画面クリア
|
406
|
+
|
407
|
+
ClearDrawScreen();
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
//bline配列の情報を描画
|
412
|
+
|
413
|
+
for (int i = 0;i< linesegCnt;i++) {
|
414
|
+
|
415
|
+
switch (bline[i].Ptype)
|
416
|
+
|
417
|
+
{
|
418
|
+
|
419
|
+
case Pen:
|
420
|
+
|
421
|
+
DrawLine(bline[i - 1].BlackLineX, bline[i - 1].BlackLineY, bline[i].BlackLineX, bline[i].BlackLineY, 0x0, 3);
|
422
|
+
|
423
|
+
break;
|
424
|
+
|
425
|
+
case Eraser:
|
426
|
+
|
427
|
+
DrawBox(bline[i].BlackLineX-20, bline[i].BlackLineY-20, bline[i].BlackLineX+20, bline[i].BlackLineY+20, 0xffffff, TRUE);
|
428
|
+
|
429
|
+
break;
|
430
|
+
|
431
|
+
}
|
432
|
+
|
433
|
+
}
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
//文字等描画
|
438
|
+
|
439
|
+
DrawString(0, 0, "キー操作:0=全削除 1=ペン 2=消しゴム", 0x0);
|
440
|
+
|
441
|
+
DrawFormatString(0, 32, GetColor(0, 0, 0), "現在の配列使用数:%d(確保数:%d)", linesegCnt, linesegMaX);
|
442
|
+
|
443
|
+
if (PenF) {
|
444
|
+
|
265
|
-
Draw
|
445
|
+
DrawString(0, 16, "現在のモード:ペン", 0x0);
|
266
|
-
|
267
|
-
|
446
|
+
|
268
|
-
|
269
|
-
DrawLine(X
|
447
|
+
DrawLine(posX, posY - 10, posX, posY + 10, 0x0);
|
448
|
+
|
449
|
+
DrawLine(posX - 10, posY, posX + 10, posY, 0x0);
|
450
|
+
|
451
|
+
}
|
452
|
+
|
453
|
+
else {
|
454
|
+
|
455
|
+
DrawString(0, 16, "現在のモード:消しゴム", 0x0);
|
456
|
+
|
457
|
+
DrawBox(posX - 20, posY - 20, posX + 20, posY + 20, 0xffffff, TRUE);
|
458
|
+
|
459
|
+
DrawBox(posX - 20, posY - 20, posX + 20, posY + 20, 0x0, FALSE);
|
460
|
+
|
461
|
+
}
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
//表画面に転送
|
466
|
+
|
467
|
+
ScreenFlip();
|
468
|
+
|
469
|
+
}
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
free(bline);
|
474
|
+
|
475
|
+
DxLib_End();
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
return 0;
|
270
480
|
|
271
481
|
}
|
272
482
|
|
273
|
-
|
274
|
-
|
275
|
-
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
276
|
-
|
277
|
-
{
|
278
|
-
|
279
|
-
//初期化前の設定
|
280
|
-
|
281
|
-
ChangeWindowMode(TRUE);
|
282
|
-
|
283
|
-
SetGraphMode(WIN_WIDTH, WIN_HEIGHT, 32);
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
//DXライブラリ初期化
|
288
|
-
|
289
|
-
if (DxLib_Init() == -1)return -1;
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
//背景色設定
|
294
|
-
|
295
|
-
SetDrawScreen(DX_SCREEN_BACK);
|
296
|
-
|
297
|
-
SetBackgroundColor(255, 255, 255);
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
int linesegMaX = 1000;
|
302
|
-
|
303
|
-
int linesegCnt = 0;
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
lineseg *bline;
|
308
|
-
|
309
|
-
bline = (lineseg*)malloc(linesegMaX * sizeof(lineseg));
|
310
|
-
|
311
|
-
if (bline == NULL) {
|
312
|
-
|
313
|
-
return -1;
|
314
|
-
|
315
|
-
}
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
//マウス情報用変数
|
320
|
-
|
321
|
-
int posX, posY;
|
322
|
-
|
323
|
-
bool Drag = false, PenF = true;
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
//キー入力用変数
|
328
|
-
|
329
|
-
char KeyBuf[256];
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
//メインループ
|
334
|
-
|
335
|
-
while (!ProcessMessage())
|
336
|
-
|
337
|
-
{
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
//キー入力
|
342
|
-
|
343
|
-
GetHitKeyStateAll(KeyBuf);
|
344
|
-
|
345
|
-
if (KeyBuf[KEY_INPUT_1] == 1) { PenF= true; }
|
346
|
-
|
347
|
-
if (KeyBuf[KEY_INPUT_2] == 1) { PenF = false; Drag = false; }
|
348
|
-
|
349
|
-
if (KeyBuf[KEY_INPUT_0] == 1) { linesegCnt = 0; }//メモリ解放はしていない…
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
//マウス座標取得
|
354
|
-
|
355
|
-
GetMousePoint(&posX, &posY);
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
//マウス入力処理
|
360
|
-
|
361
|
-
if (GetMouseInput() & MOUSE_INPUT_LEFT) {
|
362
|
-
|
363
|
-
//ドラッグ中は座標を追加
|
364
|
-
|
365
|
-
//(前と座標が同じでも追加されるので、メモリ節約したい場合は移動した時だけ追加するようにした方がいい…)
|
366
|
-
|
367
|
-
bline[linesegCnt].BlackLineX = posX;
|
368
|
-
|
369
|
-
bline[linesegCnt].BlackLineY = posY;
|
370
|
-
|
371
|
-
if(PenF){
|
372
|
-
|
373
|
-
if (Drag) {//ドラッグ中は線を引く
|
374
|
-
|
375
|
-
bline[linesegCnt].Ptype = Pen;
|
376
|
-
|
377
|
-
}
|
378
|
-
|
379
|
-
else {//ドラッグ開始
|
380
|
-
|
381
|
-
Drag = true; //ドラッグフラグをオンにする
|
382
|
-
|
383
|
-
bline[linesegCnt].Ptype = Non;
|
384
|
-
|
385
|
-
}
|
386
|
-
|
387
|
-
}
|
388
|
-
|
389
|
-
else {
|
390
|
-
|
391
|
-
bline[linesegCnt].Ptype = Eraser;
|
392
|
-
|
393
|
-
}
|
394
|
-
|
395
|
-
linesegCnt++;
|
396
|
-
|
397
|
-
//メモリが足りなくなったら拡大
|
398
|
-
|
399
|
-
if (linesegCnt == linesegMaX) {
|
400
|
-
|
401
|
-
linesegMaX += 1000;
|
402
|
-
|
403
|
-
lineseg* tmp = (lineseg*)realloc(bline, linesegMaX * sizeof(lineseg));
|
404
|
-
|
405
|
-
if (tmp == NULL) {
|
406
|
-
|
407
|
-
free(bline);
|
408
|
-
|
409
|
-
return -1;
|
410
|
-
|
411
|
-
}
|
412
|
-
|
413
|
-
bline = tmp;
|
414
|
-
|
415
|
-
}
|
416
|
-
|
417
|
-
}
|
418
|
-
|
419
|
-
else {//マウスのキーは押されていない
|
420
|
-
|
421
|
-
if (Drag)Drag = false; //ドラッグフラグをオフにする
|
422
|
-
|
423
|
-
}
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
//画面クリア
|
428
|
-
|
429
|
-
ClearDrawScreen();
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
//bline配列の情報を描画
|
434
|
-
|
435
|
-
for (int i = 0;i< linesegCnt;i++) {
|
436
|
-
|
437
|
-
switch (bline[i].Ptype)
|
438
|
-
|
439
|
-
{
|
440
|
-
|
441
|
-
case Pen:
|
442
|
-
|
443
|
-
DrawLineB(bline[i - 1].BlackLineX, bline[i - 1].BlackLineY, bline[i].BlackLineX, bline[i].BlackLineY);
|
444
|
-
|
445
|
-
break;
|
446
|
-
|
447
|
-
case Eraser:
|
448
|
-
|
449
|
-
DrawBox(bline[i].BlackLineX-20, bline[i].BlackLineY-20, bline[i].BlackLineX+20, bline[i].BlackLineY+20, 0xffffff, TRUE);
|
450
|
-
|
451
|
-
break;
|
452
|
-
|
453
|
-
}
|
454
|
-
|
455
|
-
}
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
//文字等描画
|
460
|
-
|
461
|
-
DrawString(0, 0, "キー操作:0=全削除 1=ペン 2=消しゴム", 0x0);
|
462
|
-
|
463
|
-
DrawFormatString(0, 32, GetColor(0, 0, 0), "現在の配列使用数:%d(確保数:%d)", linesegCnt, linesegMaX);
|
464
|
-
|
465
|
-
if (PenF) {
|
466
|
-
|
467
|
-
DrawString(0, 16, "現在のモード:ペン", 0x0);
|
468
|
-
|
469
|
-
DrawLine(posX, posY - 10, posX, posY + 10, 0x0);
|
470
|
-
|
471
|
-
DrawLine(posX - 10, posY, posX + 10, posY, 0x0);
|
472
|
-
|
473
|
-
}
|
474
|
-
|
475
|
-
else {
|
476
|
-
|
477
|
-
DrawString(0, 16, "現在のモード:消しゴム", 0x0);
|
478
|
-
|
479
|
-
DrawBox(posX - 20, posY - 20, posX + 20, posY + 20, 0xffffff, TRUE);
|
480
|
-
|
481
|
-
DrawBox(posX - 20, posY - 20, posX + 20, posY + 20, 0x0, FALSE);
|
482
|
-
|
483
|
-
}
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
//表画面に転送
|
488
|
-
|
489
|
-
ScreenFlip();
|
490
|
-
|
491
|
-
}
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
free(bline);
|
496
|
-
|
497
|
-
DxLib_End();
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
return 0;
|
502
|
-
|
503
|
-
}
|
504
|
-
|
505
483
|
```
|
2
コードコメント追加
test
CHANGED
@@ -360,6 +360,10 @@
|
|
360
360
|
|
361
361
|
if (GetMouseInput() & MOUSE_INPUT_LEFT) {
|
362
362
|
|
363
|
+
//ドラッグ中は座標を追加
|
364
|
+
|
365
|
+
//(前と座標が同じでも追加されるので、メモリ節約したい場合は移動した時だけ追加するようにした方がいい…)
|
366
|
+
|
363
367
|
bline[linesegCnt].BlackLineX = posX;
|
364
368
|
|
365
369
|
bline[linesegCnt].BlackLineY = posY;
|
1
追記
test
CHANGED
@@ -207,3 +207,295 @@
|
|
207
207
|
}
|
208
208
|
|
209
209
|
```
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
追記でさらにヒント↓
|
216
|
+
|
217
|
+
```C++
|
218
|
+
|
219
|
+
#include "DxLib.h"
|
220
|
+
|
221
|
+
#include <stdlib.h>
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
const int WIN_WIDTH = 600; //ウィンドウ横幅
|
226
|
+
|
227
|
+
const int WIN_HEIGHT = 400;//ウィンドウ縦幅
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
enum PTYPE
|
232
|
+
|
233
|
+
{
|
234
|
+
|
235
|
+
Non,
|
236
|
+
|
237
|
+
Pen,
|
238
|
+
|
239
|
+
Eraser,
|
240
|
+
|
241
|
+
};
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
struct lineseg
|
246
|
+
|
247
|
+
{
|
248
|
+
|
249
|
+
int BlackLineX;
|
250
|
+
|
251
|
+
int BlackLineY;
|
252
|
+
|
253
|
+
PTYPE Ptype;
|
254
|
+
|
255
|
+
};
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
void DrawLineB(int X1, int Y1, int X2, int Y2)
|
260
|
+
|
261
|
+
{
|
262
|
+
|
263
|
+
DrawLine(X1, Y1, X2, Y2, 0x0);
|
264
|
+
|
265
|
+
DrawLine(X1, Y1-1, X2, Y2-1, 0x0);
|
266
|
+
|
267
|
+
DrawLine(X1-1, Y1, X2-1, Y2, 0x0);
|
268
|
+
|
269
|
+
DrawLine(X1-1, Y1-1, X2-1, Y2-1, 0x0);
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
276
|
+
|
277
|
+
{
|
278
|
+
|
279
|
+
//初期化前の設定
|
280
|
+
|
281
|
+
ChangeWindowMode(TRUE);
|
282
|
+
|
283
|
+
SetGraphMode(WIN_WIDTH, WIN_HEIGHT, 32);
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
//DXライブラリ初期化
|
288
|
+
|
289
|
+
if (DxLib_Init() == -1)return -1;
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
//背景色設定
|
294
|
+
|
295
|
+
SetDrawScreen(DX_SCREEN_BACK);
|
296
|
+
|
297
|
+
SetBackgroundColor(255, 255, 255);
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
int linesegMaX = 1000;
|
302
|
+
|
303
|
+
int linesegCnt = 0;
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
lineseg *bline;
|
308
|
+
|
309
|
+
bline = (lineseg*)malloc(linesegMaX * sizeof(lineseg));
|
310
|
+
|
311
|
+
if (bline == NULL) {
|
312
|
+
|
313
|
+
return -1;
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
//マウス情報用変数
|
320
|
+
|
321
|
+
int posX, posY;
|
322
|
+
|
323
|
+
bool Drag = false, PenF = true;
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
//キー入力用変数
|
328
|
+
|
329
|
+
char KeyBuf[256];
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
//メインループ
|
334
|
+
|
335
|
+
while (!ProcessMessage())
|
336
|
+
|
337
|
+
{
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
//キー入力
|
342
|
+
|
343
|
+
GetHitKeyStateAll(KeyBuf);
|
344
|
+
|
345
|
+
if (KeyBuf[KEY_INPUT_1] == 1) { PenF= true; }
|
346
|
+
|
347
|
+
if (KeyBuf[KEY_INPUT_2] == 1) { PenF = false; Drag = false; }
|
348
|
+
|
349
|
+
if (KeyBuf[KEY_INPUT_0] == 1) { linesegCnt = 0; }//メモリ解放はしていない…
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
//マウス座標取得
|
354
|
+
|
355
|
+
GetMousePoint(&posX, &posY);
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
//マウス入力処理
|
360
|
+
|
361
|
+
if (GetMouseInput() & MOUSE_INPUT_LEFT) {
|
362
|
+
|
363
|
+
bline[linesegCnt].BlackLineX = posX;
|
364
|
+
|
365
|
+
bline[linesegCnt].BlackLineY = posY;
|
366
|
+
|
367
|
+
if(PenF){
|
368
|
+
|
369
|
+
if (Drag) {//ドラッグ中は線を引く
|
370
|
+
|
371
|
+
bline[linesegCnt].Ptype = Pen;
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
else {//ドラッグ開始
|
376
|
+
|
377
|
+
Drag = true; //ドラッグフラグをオンにする
|
378
|
+
|
379
|
+
bline[linesegCnt].Ptype = Non;
|
380
|
+
|
381
|
+
}
|
382
|
+
|
383
|
+
}
|
384
|
+
|
385
|
+
else {
|
386
|
+
|
387
|
+
bline[linesegCnt].Ptype = Eraser;
|
388
|
+
|
389
|
+
}
|
390
|
+
|
391
|
+
linesegCnt++;
|
392
|
+
|
393
|
+
//メモリが足りなくなったら拡大
|
394
|
+
|
395
|
+
if (linesegCnt == linesegMaX) {
|
396
|
+
|
397
|
+
linesegMaX += 1000;
|
398
|
+
|
399
|
+
lineseg* tmp = (lineseg*)realloc(bline, linesegMaX * sizeof(lineseg));
|
400
|
+
|
401
|
+
if (tmp == NULL) {
|
402
|
+
|
403
|
+
free(bline);
|
404
|
+
|
405
|
+
return -1;
|
406
|
+
|
407
|
+
}
|
408
|
+
|
409
|
+
bline = tmp;
|
410
|
+
|
411
|
+
}
|
412
|
+
|
413
|
+
}
|
414
|
+
|
415
|
+
else {//マウスのキーは押されていない
|
416
|
+
|
417
|
+
if (Drag)Drag = false; //ドラッグフラグをオフにする
|
418
|
+
|
419
|
+
}
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
//画面クリア
|
424
|
+
|
425
|
+
ClearDrawScreen();
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
//bline配列の情報を描画
|
430
|
+
|
431
|
+
for (int i = 0;i< linesegCnt;i++) {
|
432
|
+
|
433
|
+
switch (bline[i].Ptype)
|
434
|
+
|
435
|
+
{
|
436
|
+
|
437
|
+
case Pen:
|
438
|
+
|
439
|
+
DrawLineB(bline[i - 1].BlackLineX, bline[i - 1].BlackLineY, bline[i].BlackLineX, bline[i].BlackLineY);
|
440
|
+
|
441
|
+
break;
|
442
|
+
|
443
|
+
case Eraser:
|
444
|
+
|
445
|
+
DrawBox(bline[i].BlackLineX-20, bline[i].BlackLineY-20, bline[i].BlackLineX+20, bline[i].BlackLineY+20, 0xffffff, TRUE);
|
446
|
+
|
447
|
+
break;
|
448
|
+
|
449
|
+
}
|
450
|
+
|
451
|
+
}
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
//文字等描画
|
456
|
+
|
457
|
+
DrawString(0, 0, "キー操作:0=全削除 1=ペン 2=消しゴム", 0x0);
|
458
|
+
|
459
|
+
DrawFormatString(0, 32, GetColor(0, 0, 0), "現在の配列使用数:%d(確保数:%d)", linesegCnt, linesegMaX);
|
460
|
+
|
461
|
+
if (PenF) {
|
462
|
+
|
463
|
+
DrawString(0, 16, "現在のモード:ペン", 0x0);
|
464
|
+
|
465
|
+
DrawLine(posX, posY - 10, posX, posY + 10, 0x0);
|
466
|
+
|
467
|
+
DrawLine(posX - 10, posY, posX + 10, posY, 0x0);
|
468
|
+
|
469
|
+
}
|
470
|
+
|
471
|
+
else {
|
472
|
+
|
473
|
+
DrawString(0, 16, "現在のモード:消しゴム", 0x0);
|
474
|
+
|
475
|
+
DrawBox(posX - 20, posY - 20, posX + 20, posY + 20, 0xffffff, TRUE);
|
476
|
+
|
477
|
+
DrawBox(posX - 20, posY - 20, posX + 20, posY + 20, 0x0, FALSE);
|
478
|
+
|
479
|
+
}
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
//表画面に転送
|
484
|
+
|
485
|
+
ScreenFlip();
|
486
|
+
|
487
|
+
}
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
free(bline);
|
492
|
+
|
493
|
+
DxLib_End();
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
return 0;
|
498
|
+
|
499
|
+
}
|
500
|
+
|
501
|
+
```
|