File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -4,11 +4,12 @@ export const gravity = 0.02;
44// Player 関連
55export const playerWidth = 0.6 ;
66export const playerHeight = 0.9 ;
7- export const maxMoveVX = 0.1 ;
7+ export const maxMoveVX = 0.1 ; // これを超えると player の入力では加速しなくなるが、ジャンプで加速できる
88export const playerAccelOnGround = 0.05 ;
99export const playerDecelOnGround = 0.05 ;
1010export const playerAccelInAir = 0.01 ;
1111export const playerDecelInAir = 0.01 ;
12+ export const jumpAccelRate = 1.1 ; // ジャンプした瞬間に加速
1213export const jumpVY = 0.12 ;
1314export const jumpFrames = 10 ;
1415// Fallable block 関連
Original file line number Diff line number Diff line change @@ -140,15 +140,13 @@ export function tick(cx: Context, ticker: Ticker) {
140140 }
141141 switch ( playerIntent ) {
142142 case 1 :
143- player . vx += accel * blockSize ;
144- if ( player . vx >= consts . maxMoveVX * blockSize ) {
145- player . vx = consts . maxMoveVX * blockSize ;
143+ if ( player . vx < consts . maxMoveVX * blockSize ) {
144+ player . vx += accel * blockSize ;
146145 }
147146 break ;
148147 case - 1 :
149- player . vx -= decel * blockSize ;
150- if ( player . vx <= - consts . maxMoveVX * blockSize ) {
151- player . vx = - consts . maxMoveVX * blockSize ;
148+ if ( player . vx > - consts . maxMoveVX * blockSize ) {
149+ player . vx -= decel * blockSize ;
152150 }
153151 break ;
154152 case 0 :
@@ -168,6 +166,7 @@ export function tick(cx: Context, ticker: Ticker) {
168166 if ( player . onGround ) {
169167 player . vy = - consts . jumpVY * blockSize ;
170168 player . jumpingBegin = elapsed ;
169+ player . vx *= consts . jumpAccelRate ;
171170 } else if ( player . jumpingBegin && elapsed - player . jumpingBegin < consts . jumpFrames ) {
172171 player . vy = - consts . jumpVY * blockSize ;
173172 } else {
You can’t perform that action at this time.
0 commit comments