hi! im new to this whole coding thing (first day actually) and i was wondering how you would tell an object not to go through a platform when jumping. any suggestions?


1 2 3 4 | private void platform_move() { setLocation(getX() + x_speed, getY()); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | private void player_move() { [platform actor name] moving_platform = ([platform actor name) getOneObjectAtOffset(getX(), getY()+getImage().getHeight()/ 2 , [platform actor name]); if (moving_platform != null ) { platform_x_speed = moving_platform.x_speed; } else { platform_x_speed = 0 ; } if (Greenfoot.isKeyDown( "right" )) { x_speed = 1 ; } if (Greenfoot.isKeyDown( "left" )) { x_speed = - 1 ; } setLocation(getX() + x_speed + platform_x_speed, getY()); } |