I'm writing a sample game where a block falls down forever, and you need to steer it from side to side. If you hit the walls, you lose. I'm trying to randomly and continually generate the level so there's always a way through, and so the path gets progressively narrower.
# #
# #
# ##
# ###
# ####
# #####
## #####
## #####
## ####
### ####
### ###
#### ###
#### ###
### ###
### ###
## ####
## ####
## #####
## #####
## ######
## ######
## ######
## ######
My current approach is to have an array of possible paths, then I randomly select a row. The problem is that the path is not smooth, and at times, it becomes impossible:
# #
# ####
# #####
### ###
## #####
### ####
# ###
## #####
#### ### <--- can't get through here
## ####
#### ###
### ###
# ##
## ######
## #####
## ######
## #####
## #####
## ####
## ####
# #
### ###
## ###### <--- or here
# #
## ######
## ######
What class of algorithms would help me get started with this?
Aucun commentaire:
Enregistrer un commentaire