Skip to content

Commit fd16062

Browse files
committed
Adds initial project files.
0 parents  commit fd16062

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+195796
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*node_modules*
2+
*output*
3+
*.psc-package*
4+
*.d
5+
*.o
6+
*.blend1
7+
ffi/*
8+
!ffi/README.md

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v10.8.0

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## [Lambda Lantern](https://github.com/lettier/lambda-lantern)
2+
3+
## Changelog
4+
5+
-------------------------------------------------------------------------------
6+
7+
### 0.0.0.0
8+
9+
#### Added
10+
11+
- Initial bindings
12+
- Models
13+
- Sounds
14+
- Music
15+
- Font
16+
- Level 0
17+
- Main menu
18+
- Logo
19+
- psc-package
20+
21+
#### Changed
22+
23+
-
24+
25+
#### Removed
26+
27+
-

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2018, David Lettier
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
* Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Makefile

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# PureScript to native binary (via C++) Makefile
2+
#
3+
# Run 'make' or 'make release' to build an optimized release build
4+
# Run 'make debug' to build a non-optimized build suitable for debugging
5+
#
6+
# You can also perform a parallel build with 'make -jN', where N is the
7+
# number of cores to use.
8+
#
9+
# PURS, SRC, OUTPUT, and BIN can all be overridden with the
10+
# command itself. For example: 'make BIN=myutil'
11+
#
12+
# Flags can be added to either the codegen or native build phases.
13+
# For example: 'make PURSFLAGS=--codegen,js CXXFLAGS=-DDEBUG LDFLAGS=lgmp'
14+
#
15+
# You can also edit the generated version of this file directly.
16+
#
17+
PURS := purs
18+
PSC_PACKAGE := psc-package
19+
PSCPP := pscpp
20+
SRC := src
21+
OUTPUT := output
22+
CC_SRC := $(OUTPUT)/src
23+
FFI_SRC := ffi
24+
BIN := lambda-lantern
25+
26+
override PURSFLAGS += compile --codegen corefn
27+
override CXXFLAGS += --std=c++11
28+
29+
CXXVERSION = $(shell $(CXX) --version)
30+
ifneq (,$(findstring g++,$(CXXVERSION)))
31+
PSCPPFLAGS += "--ucns"
32+
endif
33+
34+
DEBUG := "-DDEBUG -g"
35+
RELEASE := "-DNDEBUG -O3"
36+
37+
INCLUDES := -I $(CC_SRC)
38+
BIN_DIR := $(OUTPUT)/bin
39+
40+
PACKAGE_SOURCES = $(subst \,/,$(shell $(PSC_PACKAGE) sources))
41+
PURESCRIPT_PKGS := $(firstword $(subst /, ,$(PACKAGE_SOURCES)))
42+
43+
## Not all environments support globstar (** dir pattern)
44+
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
45+
46+
debug: codegen
47+
@$(MAKE) $(BIN) CFLAGS+=$(DEBUG) CXXFLAGS+=$(DEBUG)
48+
49+
release: codegen
50+
@$(MAKE) $(BIN) CFLAGS+=$(RELEASE) CXXFLAGS+=$(RELEASE)
51+
52+
.PHONY: corefn
53+
corefn: PURESCRIPT_PKG_SRCS=$(foreach d,$(PACKAGE_SOURCES),$(call rwildcard,$(firstword $(subst *, ,$(d))),*.purs))
54+
corefn: PURESCRIPT_SRCS=$(call rwildcard,$(SRC)/,*.purs)
55+
corefn: $(PURESCRIPT_PKGS)
56+
@$(PURS) $(PURSFLAGS) --output $(OUTPUT) $(PURESCRIPT_PKG_SRCS) $(PURESCRIPT_SRCS)
57+
58+
.PHONY: codegen
59+
codegen: COREFN_SRCS=$(call rwildcard,$(OUTPUT)/,corefn.json)
60+
codegen: corefn
61+
@$(PSCPP) $(PSCPPFLAGS) $(COREFN_SRCS)
62+
63+
$(PURESCRIPT_PKGS):
64+
@echo "Getting packages using" $(PSC_PACKAGE) "..."
65+
@$(PSC_PACKAGE) update
66+
67+
SRCS := $(call rwildcard,$(CC_SRC)/,*.cpp)
68+
SRCS += $(call rwildcard,$(FFI_SRC)/,*.cpp)
69+
SRCS += $(call rwildcard,$(FFI_SRC)/,*.cc)
70+
SRCS += $(call rwildcard,$(FFI_SRC)/,*.mm)
71+
SRCS += $(call rwildcard,$(FFI_SRC)/,*.c)
72+
SRCS += $(call rwildcard,$(FFI_SRC)/,*.m)
73+
74+
OBJS1 = $(SRCS:.cpp=.o)
75+
OBJS2 = $(OBJS1:.cc=.o)
76+
OBJS3 = $(OBJS2:.mm=.o)
77+
OBJS4 = $(OBJS3:.c=.o)
78+
OBJS = $(OBJS4:.m=.o)
79+
DEPS = $(OBJS:.o=.d)
80+
81+
$(BIN): $(OBJS)
82+
@echo "Linking" $(BIN_DIR)/$(BIN)
83+
@mkdir -p $(BIN_DIR)
84+
@$(CXX) $^ -o $(BIN_DIR)/$@ $(LDFLAGS)
85+
86+
-include $(DEPS)
87+
88+
%.o: %.cpp
89+
@echo "Creating" $@ "(C++)"
90+
@$(CXX) $(CXXFLAGS) $(INCLUDES) -MMD -MP -c $< -o $@
91+
92+
%.o: %.cc
93+
@echo "Creating" $@ "(C++)"
94+
@$(CXX) $(CXXFLAGS) $(INCLUDES) -MMD -MP -c $< -o $@
95+
96+
%.o: %.mm
97+
@echo "Creating" $@ "(Objective-C++)"
98+
@$(CXX) $(CXXFLAGS) $(INCLUDES) -MMD -MP -c $< -o $@
99+
100+
%.o: %.c
101+
@echo "Creating" $@ "(C)"
102+
@$(CXX) $(CFLAGS) $(INCLUDES) -MMD -MP -c $< -o $@
103+
104+
%.o: %.m
105+
@echo "Creating" $@ "(Objective-C)"
106+
@$(CXX) $(CFLAGS) $(INCLUDES) -MMD -MP -c $< -o $@
107+
108+
.PHONY: all
109+
all: release
110+
111+
.PHONY: clean
112+
clean:
113+
@-rm -f $(OBJS) $(DEPS)
114+
@-rm -rf $(OUTPUT)
115+
116+
.PHONY: run
117+
run:
118+
@$(BIN_DIR)/$(BIN) $(ARGS)

README.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Lambda Lantern :smiley:
2+
3+
![Lambda Lantern](https://i.imgur.com/qsocAZg.png)
4+
5+
# What is Lambda Lantern? :thinking:
6+
7+
![Lambda Lantern](https://i.imgur.com/wQBJNrS.gif)
8+
9+
Lambda Lantern is a game made with PureScript, PureScript Native, and Panda3D.
10+
The premise of the game involves collecting and using functional programming patterns
11+
to solve puzzles and ultimately escape a dungeon.
12+
13+
One of the purposes of Lambda Lantern is to demonstrate binding PureScript to C++.
14+
15+
Lambda Lantern originally started as a [GitHub Game Off submission](https://itch.io/jam/game-off-2018/rate/338096).
16+
17+
# How do I build and run Lambda Lantern? :hammer:
18+
19+
![Lambda Lantern](https://i.imgur.com/V6bVIRR.png)
20+
21+
```bash
22+
# Install Git.
23+
# Install nvm (https://github.com/creationix/nvm).
24+
# Install Panda3D (https://www.panda3d.org/download/sdk-1-10-1/).
25+
# Install Haskell Stack (https://docs.haskellstack.org/en/stable/README/).
26+
27+
cd
28+
29+
# Install PureScript Native (https://github.com/andyarvanitis/purescript-native).
30+
31+
git clone https://github.com/andyarvanitis/purescript-native.git
32+
cd purescript-native
33+
git checkout aa857adec6aa40edac91bcacfe4c3b7c5f1c3f2d
34+
stack install
35+
36+
cd
37+
38+
# Update path for PureScript Native compiler pscpp.
39+
40+
export PATH="${PATH}:${HOME}/.local/bin"
41+
42+
# Download and install the FFI exports.
43+
44+
git clone https://github.com/lettier/purescript-native-ffi.git
45+
cd purescript-native-ffi
46+
git checkout lambda-lantern
47+
48+
cd
49+
50+
git clone https://github.com/lettier/lambda-lantern.git
51+
52+
# Note the trailing dot.
53+
cp -nr purescript-native-ffi/. lambda-lantern/ffi/
54+
55+
cd lambda-lantern
56+
57+
# Install Node.js.
58+
59+
nvm install `cat .nvmrc` && nvm use
60+
61+
# Install PureScript and psc-package.
62+
63+
64+
65+
# Install the PureScript dependencies.
66+
psc-package install
67+
68+
# Build Lambda Lantern.
69+
# Double check the include and lib paths.
70+
# You may need additional flags for your platform.
71+
72+
make \
73+
CXXFLAGS=" \
74+
-fmax-errors=1 \
75+
-I/usr/include/python \
76+
-I/usr/include/panda3d \
77+
-I/usr/include/freetype2" \
78+
LDFLAGS=" \
79+
-L/usr/lib/panda3d \
80+
-lp3framework \
81+
-lpanda \
82+
-lpandafx \
83+
-lpandaexpress \
84+
-lp3dtoolconfig \
85+
-lp3dtool \
86+
-lp3pystub \
87+
-lp3direct \
88+
-pthread \
89+
-lpthread"
90+
91+
# Run Lambda Lantern.
92+
93+
LAMBDA_LANTERN_ASSETS_PATH="./assets" ./output/bin/lambda-lantern
94+
```
95+
96+
# What is the license? :scroll:
97+
98+
![Lambda Lantern](https://i.imgur.com/mwTFPkq.png)
99+
100+
For license information, see [LICENSE](LICENSE).
101+
102+
# Who wrote Lambda Lantern? :copyright:
103+
104+
![Lambda Lantern](https://i.imgur.com/gXtQR61.gif)
105+
106+
(C) 2018 David Lettier
107+
[lettier.com](https://lettier.com)

0 commit comments

Comments
 (0)