How about

```python
if keyCode == UP and pts < 40:
    pts += 1
```
etc.?