mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
games/cgol: Add Conway's Game of Life
This commit introduces a new application, Conway's Game of Life (or `cgol`). It is a simple frame buffer rendering application that makes for an interesting, animated visual. Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
This commit is contained in:
parent
9bbc2fe1e4
commit
31d567e880
4 changed files with 1198 additions and 0 deletions
80
games/cgol/Kconfig
Normal file
80
games/cgol/Kconfig
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config GAMES_CGOL
|
||||
bool "Conway's Game of Life"
|
||||
depends on VIDEO_FB
|
||||
default n
|
||||
---help---
|
||||
Enable Conway's Game of Life.
|
||||
|
||||
if GAMES_CGOL
|
||||
|
||||
config GAMES_CGOL_PROGNAME
|
||||
string "Program name"
|
||||
default "cgol"
|
||||
---help---
|
||||
This is the name of the program that will be used when the NSH ELF
|
||||
program is installed.
|
||||
|
||||
config GAMES_CGOL_PRIORITY
|
||||
int "CGOL task priority"
|
||||
default 100
|
||||
|
||||
config GAMES_CGOL_STACKSIZE
|
||||
int "CGOL stack size"
|
||||
default DEFAULT_TASK_STACKSIZE
|
||||
|
||||
config GAMES_CGOL_FBDEV
|
||||
string "CGOL frame buffer device path"
|
||||
default "/dev/fb0"
|
||||
---help---
|
||||
The frame buffer device path that will be used by default for rendering.
|
||||
Device path can still be selected from first command line argument.
|
||||
|
||||
config GAMES_CGOL_DBLBUF
|
||||
bool "CGOL double buffered"
|
||||
default n
|
||||
---help---
|
||||
If enabled, CGOL will allocate enough RAM for a 'second frame buffer'.
|
||||
Rendering will be done to this buffer and copied to the real frame
|
||||
buffer once complete. This is necessary for some devices, but requires
|
||||
a lot more memory.
|
||||
|
||||
config GAMES_CGOL_MAPWIDTH
|
||||
int "Map width"
|
||||
range 1 500000
|
||||
default 256
|
||||
---help---
|
||||
This is the width of the game map. It must be greater than or equal to
|
||||
the width of the frame buffer. It must also be a multiple of the target
|
||||
device's `sizeof(unsigned int) * 8`.
|
||||
|
||||
config GAMES_CGOL_MAPHEIGHT
|
||||
int "Map height"
|
||||
range 1 500000
|
||||
default 256
|
||||
---help---
|
||||
This is the height of the game map. It must be greater than or equal to
|
||||
the height of the frame buffer.
|
||||
|
||||
config GAMES_CGOL_FRAMEDELAY
|
||||
int "Microseconds between frames"
|
||||
range 0 10000000
|
||||
default 0
|
||||
---help---
|
||||
This adds a delay between frames in microseconds. If the render is too
|
||||
fast for you to "enjoy", then you can slow it down with this.
|
||||
|
||||
config GAMES_CGOL_DENSITY
|
||||
int "Cell density"
|
||||
range 1 10000
|
||||
default 6
|
||||
---help---
|
||||
The initial cell density to populate the map with. The map will be
|
||||
randomly initialized with `TOTAL_CELLS * (1 / density)` cells, not
|
||||
accounting for overlap.
|
||||
|
||||
endif
|
||||
25
games/cgol/Make.defs
Normal file
25
games/cgol/Make.defs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
############################################################################
|
||||
# apps/games/cgol/Make.defs
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifneq ($(CONFIG_GAMES_CGOL),)
|
||||
CONFIGURED_APPS += $(APPDIR)/games/cgol
|
||||
endif
|
||||
36
games/cgol/Makefile
Normal file
36
games/cgol/Makefile
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
############################################################################
|
||||
# apps/games/cgol/Makefile
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# Snake game info
|
||||
|
||||
PROGNAME = $(CONFIG_GAMES_CGOL_PROGNAME)
|
||||
PRIORITY = $(CONFIG_GAMES_CGOL_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_GAMES_CGOL_STACKSIZE)
|
||||
MODULE = $(CONFIG_GAMES_CGOL)
|
||||
|
||||
# CGOL application
|
||||
|
||||
MAINSRC = cgol_main.c
|
||||
|
||||
include $(APPDIR)/Application.mk
|
||||
1057
games/cgol/cgol_main.c
Normal file
1057
games/cgol/cgol_main.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue