![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
test avoid bulled game
Dependencies: C12832_lcd LCD_fonts mbed mbed-rtos
Diff: Person.cpp
- Revision:
- 2:50a76ed8bf55
- Child:
- 4:0fe59e58def9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Person.cpp Fri Dec 02 06:16:50 2016 +0000 @@ -0,0 +1,38 @@ +#include<point.h> +#include<models.h> + +Person::Person(){ + p = {DEFAULT_X, DEFAULT_Y}; + jump_count = 0; + jump_time = 0; +} + +point Person::update(){ + if(jump_time == 0){ + //not jump + return p; + }else if(jump_time == MAX_JUMP_TIME){ + //down + p.y -= 1; + }else{ + //up + jump_time++; + p.y++; + } + return p; +} + +point Person::ground(){ + jump_count = 0; + jump_time = 0; + return p; +} + +point Person::jump(){ + if(jump_count < MAX_JUMP_COUNT){ + p.y++; + jump_time = 1; + jump_count++; + } + return p; +} \ No newline at end of file