質問編集履歴

1

文章を編集

2019/08/22 05:49

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- Dxlib 左右だけの当たり判定を作りたいそれと一緒に落下時の座標判定を直したい
1
+ Dxlib 左右だけの当たり判定を作りたいそれとに落下時の座標修正の当たり判定を別に作りたい
test CHANGED
@@ -1,4 +1,10 @@
1
- 左右当たり判定を作りその分座標をずらというプログラムを作りたいのですがそうすばいいのでょうか。ブロック上に積みげそのブロックに当ると落下時にブロックにめりこむ修正ため関数が動いてまい困っています。 
1
+ Map.cppコメント部ここですのコード部なのですが落下時の座標を修正るコードですが左右に動いてる時も値が修正さしまブロック上に上がってしまいます。これをどうしら上から落下しただけ落下時時だけに修正できるのょうか?
2
+
3
+ y座標だけ見て前の座標を違う場合のみ実行したいのですが上手く来ません
4
+
5
+ ※マリオ風アクションゲーム
6
+
7
+
2
8
 
3
9
 
4
10
 
@@ -16,7 +22,7 @@
16
22
 
17
23
  #include "Block.h"
18
24
 
19
-
25
+ #include <optional>
20
26
 
21
27
  #define CELL 64
22
28
 
@@ -26,6 +32,8 @@
26
32
 
27
33
 
28
34
 
35
+ static std::ofstream ofs("Log.txt");
36
+
29
37
 
30
38
 
31
39
  enum class mapChip
@@ -62,13 +70,13 @@
62
70
 
63
71
  {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1},
64
72
 
65
- {-1,5,5,5,5,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1},
66
-
67
73
  {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1},
68
74
 
75
+ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1},
76
+
69
77
  {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,0,-1,-1,-1,-1,-1,-1,-1,-1},
70
78
 
71
- {-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1},
79
+ {-1,0-11,-1,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1},
72
80
 
73
81
  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,-1},
74
82
 
@@ -166,6 +174,68 @@
166
174
 
167
175
 
168
176
 
177
+ /*全方位の当たり判定 return セル番号を返す*/
178
+
179
+ std::optional<Position> Map::Collision::player_col(const Position *pos)
180
+
181
+ {
182
+
183
+
184
+
185
+ for (int y = 0; y < MAP_HEIGHT; y++)
186
+
187
+ {
188
+
189
+ for (int x = 0; x < MAP_WIDTH; x++)
190
+
191
+ {
192
+
193
+ if (get_mapCell(x, y) == (int)mapChip::eBrick || get_mapCell(x, y) == (int)mapChip::eQuestion)
194
+
195
+ {
196
+
197
+ if (
198
+
199
+ (pos->get_x() < (x * CELL) && pos->get_x() + CELL >= (x * CELL) ||
200
+
201
+ pos->get_x() > (x * CELL) && pos->get_x() <= (x * CELL) + CELL) &&
202
+
203
+
204
+
205
+ (pos->get_y() < (y * CELL) && pos->get_y() + CELL >= (y * CELL) ||
206
+
207
+ pos->get_y() > (y * CELL) && pos->get_y() <= (y * CELL) + CELL)
208
+
209
+ )
210
+
211
+ {
212
+
213
+ ofs<< "player_col()\n";
214
+
215
+ std::optional<Position> p = Position(x, y);
216
+
217
+ return p.value();//セルを返す
218
+
219
+ // return true;
220
+
221
+ }
222
+
223
+ }
224
+
225
+ //pos->get_x() <= (x * CELL) && pos->get_x() + CELL >= (x * CELL)
226
+
227
+ }
228
+
229
+ }
230
+
231
+
232
+
233
+ return std::nullopt;
234
+
235
+ }
236
+
237
+
238
+
169
239
 
170
240
 
171
241
  /*計算 更新*/
@@ -266,95 +336,411 @@
266
336
 
267
337
 
268
338
 
339
+ //////////////////////////////////////////////////////ここのコード
340
+
341
+ //引数は今の座標と前の座標
342
+
269
- Position Map::Collision::get_cellPos(int px, int py)//重力落下の座標補正 関数
343
+ std::optional<Position> Map::Collision::under_col(const Position *pos,const Position *prev)//下の当たり判定
270
-
344
+
271
- {
345
+ {
272
-
273
- Position pos = 0;
346
+
274
-
275
- for (int y = 0; y < 11; y++)
347
+ if (Map::Collision::player_col(pos) != std::nullopt)
276
-
348
+
277
- {
349
+ {
278
-
350
+
279
- for (int x = 0; x < 20; x++)
351
+ if (pos->get_y() > prev->get_y())
280
352
 
281
353
  {
282
354
 
283
- if (get_mapCell(x, y) == (int)mapChip::eBrick || get_mapCell(x, y) == (int)mapChip::eQuestion)
355
+ std::optional<Position> p = Map::Collision::player_col(pos);
284
-
356
+
285
- {
357
+ p->new_pos_x(p->get_x() * CELL);
286
-
358
+
287
- if (py < (y * CELL) && (py + CELL + 1) >(y * CELL))
359
+ p->new_pos_y((p->get_y() * CELL) - CELL);
288
-
289
- {
360
+
290
-
361
+
362
+
291
- for (int dx = 0; dx <= 63; dx++)
363
+ return p.value();
292
-
293
- {
364
+
294
-
295
- if ((px + 10) >= (x * CELL) && (x * CELL) + CELL >= (px + 10) ||
296
-
297
- (px +10) <= (x * CELL) && (x * CELL) <= (px + 10))
298
-
299
- {
300
-
301
- //pos.set_x(px);
365
+ // return
302
-
303
- //pos.set_y((y * CELL) - CELL);
366
+
304
-
305
-
306
-
307
- //return pos;
367
+ //return true;
308
-
309
- return Position(px,(y * CELL) - CELL);
310
-
311
- }
312
-
313
- }
314
-
315
- }
316
-
317
- }
318
368
 
319
369
  }
320
370
 
321
- }
322
-
323
-
324
-
325
- return Position(px,py);
326
-
327
- }
328
-
329
-
330
-
331
- /*左 右 の当たり判定 実装待*/
332
-
333
- int Map::Collision::side_col(Position &pos)
334
-
335
- {
336
-
337
- #define LEFT 1
338
-
339
- #define RIGHT 2
340
-
341
- int r = 0;
342
-
343
- for (int y = 0; y < MAP_HEIGHT; y++)
344
-
345
- {
346
-
347
- for (int x = 0; x < MAP_WIDTH; x++)
371
+ else {
372
+
373
+ return std::nullopt;
374
+
375
+ }
376
+
377
+ }
378
+
379
+ else {
380
+
381
+ return std::nullopt;
382
+
383
+ }
384
+
385
+
386
+
387
+ }
388
+
389
+
390
+
391
+ ```
392
+
393
+
394
+
395
+ Player.cpp
396
+
397
+ ```
398
+
399
+ #include <iostream>
400
+
401
+ #include <fstream>
402
+
403
+ #include "Input.h"
404
+
405
+ #include "Player.h"
406
+
407
+ #include "DxLib.h"
408
+
409
+ #include "Map.h"
410
+
411
+ #include "Animation.h"
412
+
413
+
414
+
415
+ #define MOVE_SPD 5
416
+
417
+ #define JUMP_FORCE 4.0624 * 3
418
+
419
+
420
+
421
+ static std::ofstream ofs("Log.txt");
422
+
423
+
424
+
425
+ /*コンストラクタ*/
426
+
427
+ Player::Player(const char* str, int xx, int yy)
428
+
429
+ {
430
+
431
+
432
+
433
+ //LoadDivGraph(str,7,7,1,64,64,g_handle);
434
+
435
+ AnimeClip = new Animation(anime_s::ewait,str,7,7,1);
436
+
437
+ pos = new Position();
438
+
439
+ prev = new Position();
440
+
441
+
442
+
443
+ AnimeClip->setAnime(anime_s::ewalk,1,3,3);
444
+
445
+ AnimeClip->setAnime(anime_s::ewait, 0, 0, 1);
446
+
447
+ AnimeClip->setAnime(anime_s::ejump, 5, 5, 1);
448
+
449
+
450
+
451
+
452
+
453
+ }
454
+
455
+
456
+
457
+ /*計算更新*/
458
+
459
+ void Player::Update()
460
+
461
+ {
462
+
463
+
464
+
465
+
466
+
467
+ input_key();
468
+
469
+ jump_up();
470
+
471
+ //side_move();//
472
+
473
+ gravity();
474
+
475
+
476
+
477
+ AnimeClip->Update();
478
+
479
+
480
+
481
+
482
+
483
+ DrawFormatString(100, 200, GetColor(255, 255, 255), "isGround %d", isGround);
484
+
485
+ DrawFormatString(100, 280, GetColor(255, 255, 255), "isJump %d", isJump);
486
+
487
+
488
+
489
+
490
+
491
+ *prev = *pos;
492
+
493
+ }
494
+
495
+
496
+
497
+
498
+
499
+ /*描画更新*/
500
+
501
+ void Player::Draw_Update()
502
+
503
+ {
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+ if ( key == -1)
512
+
513
+ {
514
+
515
+ //DrawTurnGraph(get_x(), get_y(), g_handle[0], true);
516
+
517
+ ///////
518
+
519
+ DrawTurnGraph(pos->get_x(), pos->get_y(), AnimeClip->draw_setClip(), true);
520
+
521
+
522
+
523
+ }
524
+
525
+
526
+
527
+ /*右→*/
528
+
529
+ if (key == 1)
530
+
531
+ { ///
532
+
533
+ DrawGraph(pos->get_x(), pos->get_y(), AnimeClip->draw_setClip(), true);
534
+
535
+ }
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+ AnimeClip->Draw_Update();
546
+
547
+
548
+
549
+
550
+
551
+
552
+
553
+ }
554
+
555
+
556
+
557
+ /*キー入力*/
558
+
559
+ void Player::input_key()
560
+
561
+ {
562
+
563
+ if (keybord(KEY_INPUT_LEFT) > 0)//←
564
+
565
+ {
566
+
567
+
568
+
569
+ key = -1;
570
+
571
+ AnimeClip->Update_changeAnime(anime_s::ewalk,key);
572
+
573
+ pos->set_x(-MOVE_SPD);
574
+
575
+
576
+
577
+
578
+
579
+ }else if (keybord(KEY_INPUT_RIGHT) > 0)//→
580
+
581
+ {
582
+
583
+
584
+
585
+ key = 1;
586
+
587
+ AnimeClip->Update_changeAnime(anime_s::ewalk,key);
588
+
589
+
590
+
591
+ pos->set_x(+MOVE_SPD);
592
+
593
+
594
+
595
+ }else if (keybord(KEY_INPUT_UP) > 0)//上
596
+
597
+ {
598
+
599
+ pos->set_y(+MOVE_SPD);
600
+
601
+
602
+
603
+ }else if (keybord(KEY_INPUT_DOWN) > 0)//下
604
+
605
+ {
606
+
607
+ pos->set_y(-MOVE_SPD);
608
+
609
+ }
610
+
611
+
612
+
613
+ else if (keybord(KEY_INPUT_SPACE) > 0)//ジャンプ
614
+
615
+ {
616
+
617
+ //AnimeClip->Update_changeAnime(anime_s::ejump);
618
+
619
+ //if(Map::Collision::under_col(pos->refget_x(), pos->refget_y()) == false)
620
+
621
+ if (isGround == true && jf == 0) {
622
+
623
+ //isJump = true;
624
+
625
+ isGround = false;
626
+
627
+ jf = JUMP_FORCE;
628
+
629
+ }
630
+
631
+
632
+
633
+ AnimeClip->Update_changeAnime(anime_s::ejump);
634
+
635
+
636
+
637
+ }
638
+
639
+ else//何も押していない時
640
+
641
+ {
642
+
643
+ AnimeClip->Update_changeAnime(anime_s::ewait);
644
+
645
+
646
+
647
+ }
648
+
649
+
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+ }
658
+
659
+
660
+
661
+ /************************ジャンプ ***********************/
662
+
663
+ void Player::jump_up()
664
+
665
+ {
666
+
667
+
668
+
669
+ pos->set_y((int)jf);
670
+
671
+
672
+
673
+ //if (Fps::gframe() % 20 == 0) {
674
+
675
+
676
+
677
+ jf = ((jf -0.126953125f * 3.0f));
678
+
679
+
680
+
681
+ if (jf < -0.126953125f * 3.0f * 10.0f)
682
+
683
+ {
684
+
685
+ jf = -0.126953125f * 3.0f * 10.0f;
686
+
687
+ //pos->set_y();
688
+
689
+ }
690
+
691
+ //}
692
+
693
+
694
+
695
+
696
+
697
+
698
+
699
+ }
700
+
701
+ /*********************************************************/
702
+
703
+
704
+
705
+
706
+
707
+ /***********************重力*******************************/
708
+
709
+ void Player::gravity()
710
+
711
+ {
712
+
713
+
714
+
715
+ //落下
716
+
717
+ if (Map::Collision::under_col(pos, prev) == std::nullopt && isGround == false)
718
+
719
+ {
720
+
721
+
722
+
723
+ //DrawFormatString(200, 200, GetColor(255, 255, 255), "x %d", pos->get_x());
724
+
725
+
726
+
727
+
728
+
729
+ pos->set_y((int)jf);
730
+
731
+
732
+
733
+ jf = ((jf -0.126953125f * 3.0f));
734
+
735
+
736
+
737
+ if (jf < -0.126953125f * 3.0f * 10.0f)
348
738
 
349
739
  {
350
740
 
351
- if (get_mapCell(x, y) == (int)mapChip::eBrick || get_mapCell(x, y) == (int)mapChip::eQuestion)
741
+ jf = -0.126953125f * 3.0f * 10.0f;
352
-
742
+
353
- {
743
+ //pos->set_y();
354
-
355
-
356
-
357
- }
358
744
 
359
745
  }
360
746
 
@@ -362,546 +748,54 @@
362
748
 
363
749
 
364
750
 
365
- return -1;
366
-
367
- }
368
-
369
-
370
-
371
- bool Map::Collision::under_col(int &px, int &py)//下の当たり判定
372
-
373
- {
374
-
375
-
376
-
377
- for (int y = 0; y < 11; y++)
378
-
379
- {
380
-
381
- for (int x = 0; x < 20; x++)
382
-
383
- {
384
-
385
- if (get_mapCell(x, y) == (int)mapChip::eBrick || get_mapCell(x, y) == (int)mapChip::eQuestion)
386
-
387
- {
388
-
389
- if (py < (y * CELL) && (py + CELL + 1) > (y * CELL))
390
-
391
- {
392
-
393
- for (int dx = 0; dx <= 63; dx++)
394
-
395
- {
396
-
397
- if ((px + dx) >= (x * CELL) && (x * CELL) + CELL >= (px + dx) ||
398
-
399
- (px + dx) <= (x * CELL) && (x * CELL) <= (px + dx) )
400
-
401
- {
402
-
403
- return true;
404
-
405
- }
406
-
407
- }
408
-
409
- }
410
-
411
- //if (( py < (y * CELL) && (py + CELL ) > (y * CELL) || py > (y * CELL) && py < CELL + (y * CELL))
412
-
413
-
414
-
415
- //&& ( (x * CELL) >= px && (px + CELL) >= (x * CELL)|| (( x * CELL) <= px) && ((x * CELL) + CELL >= px ) ))
416
-
417
-
418
-
419
- }
420
-
421
- }
422
-
423
- }
424
-
425
- return false;
426
-
427
- }
751
+ /*地面着地*/
752
+
753
+ if (Map::Collision::under_col(pos, prev) != std::nullopt && jf < 0)
754
+
755
+ {
756
+
757
+ DrawFormatString(200, 280, GetColor(255, 255, 255), "y %d", pos->get_y());
758
+
759
+
760
+
761
+ std::optional<Position> p = Map::Collision::under_col(pos, prev);
762
+
763
+ pos->new_pos_y(p->get_y());
764
+
765
+ ofs << "under_col true\n";
766
+
767
+
768
+
769
+ }
770
+
771
+ else {
772
+
773
+ DrawFormatString(200, 280, GetColor(255, 255, 255), "y %d", pos->get_y());
774
+
775
+
776
+
777
+ ofs << "under_col" <<pos->get_y()<<"\n";
778
+
779
+
780
+
781
+ }
782
+
783
+
784
+
785
+
786
+
787
+
788
+
789
+ }
790
+
791
+ /**********************************************************/
792
+
793
+
794
+
795
+
796
+
797
+
428
798
 
429
799
 
430
800
 
431
801
  ```
432
-
433
-
434
-
435
- Player.cpp
436
-
437
- ```ここに言語を入力
438
-
439
- #include <iostream>
440
-
441
- #include <fstream>
442
-
443
- #include "Input.h"
444
-
445
- #include "Player.h"
446
-
447
- #include "DxLib.h"
448
-
449
- #include "Map.h"
450
-
451
- #include "Animation.h"
452
-
453
-
454
-
455
- #define MOVE_SPD 5
456
-
457
- #define JUMP_FORCE 4 * 4
458
-
459
-
460
-
461
- static std::ofstream ofs("Log.txt");
462
-
463
-
464
-
465
- /*コンストラクタ*/
466
-
467
- Player::Player(const char* str, int xx, int yy)
468
-
469
- {
470
-
471
-
472
-
473
- //LoadDivGraph(str,7,7,1,64,64,g_handle);
474
-
475
- AnimeClip = new Animation(anime_s::ewait,str,7,7,1);
476
-
477
- pos = new Position();
478
-
479
-
480
-
481
-
482
-
483
- AnimeClip->setAnime(anime_s::ewalk,1,3,3);
484
-
485
- AnimeClip->setAnime(anime_s::ewait, 0, 0, 1);
486
-
487
- AnimeClip->setAnime(anime_s::ejump, 5, 5, 1);
488
-
489
-
490
-
491
-
492
-
493
- }
494
-
495
-
496
-
497
- /*計算更新*/
498
-
499
- void Player::Update()
500
-
501
- {
502
-
503
-
504
-
505
-
506
-
507
- input_key();
508
-
509
- jump_up();
510
-
511
- side_move();//
512
-
513
- gravity();
514
-
515
-
516
-
517
- AnimeClip->Update();
518
-
519
-
520
-
521
-
522
-
523
- DrawFormatString(100, 200, GetColor(255, 255, 255), "isGround %d", isGround);
524
-
525
- DrawFormatString(100, 280, GetColor(255, 255, 255), "isJump %d", isJump);
526
-
527
-
528
-
529
-
530
-
531
- }
532
-
533
-
534
-
535
-
536
-
537
- /*描画更新*/
538
-
539
- void Player::Draw_Update()
540
-
541
- {
542
-
543
-
544
-
545
-
546
-
547
-
548
-
549
- if ( key == -1)
550
-
551
- {
552
-
553
- //DrawTurnGraph(get_x(), get_y(), g_handle[0], true);
554
-
555
- ///////
556
-
557
- DrawTurnGraph(pos->get_x(), pos->get_y(), AnimeClip->draw_setClip(), true);
558
-
559
-
560
-
561
- }
562
-
563
-
564
-
565
- /*右→*/
566
-
567
- if (key == 1)
568
-
569
- { ///
570
-
571
- DrawGraph(pos->get_x(), pos->get_y(), AnimeClip->draw_setClip(), true);
572
-
573
- }
574
-
575
-
576
-
577
-
578
-
579
-
580
-
581
-
582
-
583
- AnimeClip->Draw_Update();
584
-
585
-
586
-
587
-
588
-
589
-
590
-
591
- }
592
-
593
-
594
-
595
- /*キー入力*/
596
-
597
- void Player::input_key()
598
-
599
- {
600
-
601
- if (keybord(KEY_INPUT_LEFT) > 0)//←
602
-
603
- {
604
-
605
-
606
-
607
- key = -1;
608
-
609
- AnimeClip->Update_changeAnime(anime_s::ewalk,key);
610
-
611
- pos->set_x(-MOVE_SPD);
612
-
613
-
614
-
615
-
616
-
617
- }else if (keybord(KEY_INPUT_RIGHT) > 0)//→
618
-
619
- {
620
-
621
-
622
-
623
- key = 1;
624
-
625
- AnimeClip->Update_changeAnime(anime_s::ewalk,key);
626
-
627
-
628
-
629
- pos->set_x(+MOVE_SPD);
630
-
631
-
632
-
633
- }else if (keybord(KEY_INPUT_UP) > 0)//上
634
-
635
- {
636
-
637
- pos->set_y(+MOVE_SPD);
638
-
639
-
640
-
641
- }else if (keybord(KEY_INPUT_DOWN) > 0)//下
642
-
643
- {
644
-
645
- pos->set_y(-MOVE_SPD);
646
-
647
- }
648
-
649
-
650
-
651
- else if (keybord(KEY_INPUT_SPACE) > 0)//ジャンプ
652
-
653
- {
654
-
655
- //AnimeClip->Update_changeAnime(anime_s::ejump);
656
-
657
- //if(Map::Collision::under_col(pos->refget_x(), pos->refget_y()) == false)
658
-
659
- if (isGround == true && jf == 0) {
660
-
661
- //isJump = true;
662
-
663
- isGround = false;
664
-
665
- jf = JUMP_FORCE;
666
-
667
- }
668
-
669
-
670
-
671
- AnimeClip->Update_changeAnime(anime_s::ejump);
672
-
673
-
674
-
675
- }
676
-
677
- else//何も押していない時
678
-
679
- {
680
-
681
- AnimeClip->Update_changeAnime(anime_s::ewait);
682
-
683
-
684
-
685
- }
686
-
687
-
688
-
689
-
690
-
691
-
692
-
693
-
694
-
695
- }
696
-
697
-
698
-
699
-
700
-
701
- void Player::side_move()
702
-
703
- {
704
-
705
- #define LEFT 1
706
-
707
- #define RIGHT 2
708
-
709
-
710
-
711
-
712
-
713
- if (Map::Collision::side_col(*pos) != -1)
714
-
715
- {
716
-
717
- DrawFormatString(100, 250, GetColor(255, 255, 255), "abc");
718
-
719
- int p = Map::Collision::side_col(*pos);
720
-
721
-
722
-
723
- // pos->new_pos_x(p);
724
-
725
- }
726
-
727
-
728
-
729
-
730
-
731
-
732
-
733
-
734
-
735
- }
736
-
737
-
738
-
739
-
740
-
741
- /************************ジャンプ ***********************/
742
-
743
- void Player::jump_up()
744
-
745
- {
746
-
747
-
748
-
749
- pos->set_y((int)jf);
750
-
751
-
752
-
753
- //if (Fps::gframe() % 20 == 0) {
754
-
755
-
756
-
757
- jf = ((jf - 0.123f * 3));
758
-
759
-
760
-
761
- if (jf < -5)
762
-
763
- {
764
-
765
- jf = -5;
766
-
767
- //pos->set_y();
768
-
769
- }
770
-
771
- //}
772
-
773
-
774
-
775
-
776
-
777
-
778
-
779
- }
780
-
781
- /*********************************************************/
782
-
783
-
784
-
785
-
786
-
787
- /***********************重力*******************************/
788
-
789
- void Player::gravity()
790
-
791
- {
792
-
793
-
794
-
795
- //落下
796
-
797
-
798
-
799
- DrawFormatString(200,200,GetColor(255,255,255),"x %d",pos->get_x());
800
-
801
- DrawFormatString(200, 280, GetColor(255, 255, 255), "y %d", pos->get_y());
802
-
803
-
804
-
805
- //空中で当たっていない時
806
-
807
- if (Map::Collision::under_col(pos->refget_x(), pos->refget_y()) == false && isGround == false)
808
-
809
-
810
-
811
- //if (Map::Collision::under_col(pos->refget_x(),pos->refget_y()) == false && isGround == false)
812
-
813
- {
814
-
815
-
816
-
817
- pos->set_y((int)jf);
818
-
819
-
820
-
821
- jf = ((jf - 0.123f * 3));
822
-
823
-
824
-
825
- if (jf < -5)
826
-
827
- {
828
-
829
- jf = -5;
830
-
831
- //pos->set_y();
832
-
833
- }
834
-
835
-
836
-
837
-
838
-
839
- // jf = 0;
840
-
841
- //pos->set_y(-2);
842
-
843
- }
844
-
845
- //side_move();
846
-
847
-
848
-
849
- ////////////////////ここのコード
850
-
851
- if (Map::Collision::under_col(pos->refget_x(), pos->refget_y()) == true && jf < 0 )
852
-
853
- {
854
-
855
- Position p = 0;
856
-
857
- p = Map::Collision::get_cellPos(pos->get_x(), pos->get_y());
858
-
859
- // side_move();
860
-
861
-
862
-
863
- ofs << p.get_y() << endl;
864
-
865
- pos->new_pos_y(p.get_y());//座標補正
866
-
867
- isGround = true;
868
-
869
- jf = 0;
870
-
871
-
872
-
873
- }
874
-
875
-
876
-
877
- if (Map::Collision::under_col(pos->refget_x(), pos->refget_y()) == false)
878
-
879
- {
880
-
881
- DrawFormatString(100,100,GetColor(255,255,255),"false");
882
-
883
- //pos->set_y(1);
884
-
885
- }
886
-
887
-
888
-
889
-
890
-
891
- if (Map::Collision::under_col(pos->refget_x(), pos->refget_y()) == true)
892
-
893
- {
894
-
895
- DrawFormatString(100, 100, GetColor(255, 255, 255), "True");
896
-
897
- //pos->set_y(1);
898
-
899
- }
900
-
901
- }
902
-
903
- /**********************************************************/
904
-
905
-
906
-
907
- ```