CodingTrain / CodingTrain/Suggestion-Box

Desert Golfing coding challenge

Open
#1,512 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
570
Forks
85
PR merge metrics
No merged PRs in 30d

Description

![xkcd comic about desert golf](https://imgs.xkcd.com/comics/desert_golfing.png)

### Summary
There is a very old Android and iOS game called Desert Golfing, where your task is to shoot a golf ball into a hole, set in the desert. There is no tutorial, there is no menu, no level picker, no save and reload. The android app is only a few megabytes big, most of which is probably the levels. For this simplicity (and for the fact that there are no in app purchases) I love this game.

As this game is very simple, I think an even simpler version could be made in Processing or p5.

### This game has two interesting aspects in my opinion:
1. **Randomish terrain generation**
2. **a bare bones physics engine:** angle of incidence equals angle of reflection

**Of course it would be very satisfying to see an AI learn to play this game.**

### My approach to this would be the following:
``` javascript
// terrain generation:
function genTerrain(startpoint, numofPoints){
// TODO: refactor this later, make it recursive?
surface = [];
surface.push(startpoint);
for(let i = 0; i < numofPoints; i++){
lastPoint = surface[surface.length];
// each step is either followed by a slope or a flat part
if(random() < 0.4){ // do a slope
// make a vector from an angle between +100 and -100 degrees
// measured from a horizontal line with a random length
} else { // do a flat part
// Take the last point and add a vector with random length and angle 0
surface.push(newPoint)
}
}
return surface;
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.