Skip to content

Commit c997c3e

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

Some content is hidden

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

57 files changed

+196975
-0
lines changed

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
*node_modules*
2+
*output*
3+
*.psc-package*
4+
*.d
5+
*.o
6+
*.blend1
7+
ffi/arrays/*
8+
ffi/assert/*
9+
ffi/console/*
10+
ffi/effect/*
11+
ffi/foldable-traversable/*
12+
ffi/functions/*
13+
ffi/integers/*
14+
ffi/math/*
15+
ffi/partial/*
16+
ffi/prelude/*
17+
ffi/purescript-native-ffi*
18+
ffi/refs/*
19+
ffi/st/*
20+
ffi/unsafe_coerce/*
21+
22+
!ffi/prelude/data-ord-unsafe.cpp
23+
!ffi/arrays/data-array.cpp

.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 := main
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: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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/VfWlaSC.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.php?sdk&version=1.9.4).
25+
# Install Haskell Stack (https://docs.haskellstack.org/en/stable/README/).
26+
27+
export PATH="${PATH}:${HOME}/.local/bin"
28+
29+
# Install PureScript Native (https://github.com/andyarvanitis/purescript-native).
30+
31+
git clone https://github.com/andyarvanitis/purescript-native
32+
cd purescript-native
33+
stack install
34+
35+
cd
36+
37+
git clone https://github.com/andyarvanitis/purescript-native-ffi.git
38+
git clone https://github.com/lettier/lambda-lantern.git
39+
40+
# Copy the missing purescript-native-ffi file contents into ffi/.
41+
# Do not overwrite any files.
42+
43+
cp -nr purescript-native-ffi/. lambda-lantern/ffi/
44+
45+
cd lambda-lantern
46+
47+
# Install Node.js.
48+
49+
nvm install `cat .nvmrc` && nvm use
50+
51+
# Install PureScript and psc-package.
52+
53+
npm install -g purescript psc-package-bin-simple
54+
psc-package install
55+
56+
# Build Lambda Lantern.
57+
# Double check the include and lib paths.
58+
# You may need addtional flags for your platform.
59+
60+
make \
61+
CXXFLAGS=" \
62+
-fmax-errors=1 \
63+
-I/usr/include/python \
64+
-I/usr/include/panda3d \
65+
-I/usr/include/freetype2" \
66+
LDFLAGS=" \
67+
-L/usr/lib/panda3d \
68+
-lp3framework \
69+
-lpanda \
70+
-lpandafx \
71+
-lpandaexpress \
72+
-lp3dtoolconfig \
73+
-lp3dtool \
74+
-lp3pystub \
75+
-lp3direct \
76+
-pthread \
77+
-lpthread"
78+
79+
# Run Lambda Lantern.
80+
81+
LAMBDA_LANTERN_ASSETS_PATH="./assets" ./output/bin/main
82+
```
83+
84+
# What is the license? :scroll:
85+
86+
![Lambda Lantern](https://i.imgur.com/mwTFPkq.png)
87+
88+
For license information, see [LICENSE](LICENSE).
89+
90+
# Who wrote Lambda Lantern? :copyright:
91+
92+
![Lambda Lantern](https://i.imgur.com/iXSYP9h.png)
93+
94+
(C) 2018 David Lettier
95+
[lettier.com](https://lettier.com)

0 commit comments

Comments
 (0)