Skip to content

Commit

Permalink
Version 0.8, running in main thread (Mac), examples fix, gui brush up
Browse files Browse the repository at this point in the history
  • Loading branch information
urs-of-the-backwoods committed Aug 14, 2016
1 parent 4d40881 commit 9757f02
Show file tree
Hide file tree
Showing 33 changed files with 824 additions and 441 deletions.
4 changes: 2 additions & 2 deletions create_project/CreateProject
Expand Up @@ -28,9 +28,9 @@ limitations under the License.
signingkey = "https://www.github.com/urs-of-the-backwoods.keys"

[[Impls]]
location = "http://www.hgamer3d.org/downloads/scripts-0.1.3.tar.gz"
location = "http://www.hgamer3d.org/downloads/scripts-0.2.0.tar.gz"
signingkey = "https://www.github.com/urs-of-the-backwoods.keys"
version = "0.1.3"
version = "0.2.0"
architecture = "*"
os = "*"
command = "create_project.lua"
Expand Down
42 changes: 42 additions & 0 deletions create_project/CreateProject-0.8
@@ -0,0 +1,42 @@
# arriccio.toml file for HGamer3D - Create Project utility script

Id = "http://www.hgamer3d.org/component/CreateProject-0.8"
Purpose = "Scaffolding a basic HGamer3D project"
Description = """
Using this command you can create a basic project in the current folder.
Make sure you start it in an empty target folder.
"""

License = "Apache 2.0 License"

FullLicenseText = """
Copyright 2016 Peter Althainz

Licensed 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.
"""

signingkey = "https://www.github.com/urs-of-the-backwoods.keys"

[[Impls]]
location = "http://www.hgamer3d.org/downloads/scripts-0.2.0.tar.gz"
signingkey = "https://www.github.com/urs-of-the-backwoods.keys"
version = "0.2.0"
architecture = "*"
os = "*"
command = "create_project.lua"
environment = ["add-path LUA_PATH ./?.lua"]

[[Impls.dependencies]]
Id = "http://www.hgamer3d.org/component/Lua"
VersionConstraint = "5.2"

2 changes: 2 additions & 0 deletions create_project/CreateProject-0.8.sig
@@ -0,0 +1,2 @@
ssh-rsa
NkY8A0UzK7o00P3c6MgvrtSSNim+AOPXXZRhMvUB/wiJ5QiJf5Mkpg+xmPvtGK2aKJTHoKaHYmKzfZegb0Dc0PElvbe7659qBIglewFzt5N4nBzCdSCZ6JCV+rjbL4KZBFoBYCuaJooWu2mKbBw/qh53nGROq2bHa7JwAXLd0Nap8aMLs5mnb6k5CdtOPLXdogJA3HezcKHJOn3lq9MsY4hhOgQaI5Y9lUZu2YdDAmIOjJWB/UY+uTgkH9z8QVci2URHl4KHzsFbkWR+9UIZSx6N7Msz/FYtfoO5uJ6TY5HLx1nWTkcyHWGx+1t0y1CRVlSGNN6WGn6g/biX6GgRdUx++R7xx4a0mbd0kjtCLM6LkxOuEL5nOjSno/MRZmMGFA8MPBJ1+3VU/fEh0FFioJpIrsRkTERa776LvdvPF/5IlfIMWtIjzvuaeqotb+nKmm/KugY/6uGMTgCqKD9RB9H1mciiVNXKW1vAh9mfeSwzHtmWwu1jeBZg5550ghUm1TdYfKl3iR81eDHFvyhy/cwCuCCCSlsQb8m5+0QgWlmvzMQgb1eBJkWH72uoXx6cnUL6PqvqiOFh8biB4/bnDFFBUycmHEcgRehrtlKBq8SQGUtckL416Xt+y+gDaBuWhVm5bHBHSeU52jcDIk5QUsqTyrLeM7aHA54m+tCIitI=
38 changes: 16 additions & 22 deletions create_project/create_project.lua
Expand Up @@ -24,7 +24,7 @@ executable game
hs-source-dirs: .
main-is: game.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends: base, text, HGamer3D >= 0.7.1
build-depends: base, text, HGamer3D (>= 0.8.0 && < 2.0.0)
default-language: Haskell2010
]]

Expand Down Expand Up @@ -67,7 +67,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]

yaml_file = [[
extra-deps: ["HGamer3D-0.7.1", "fresco-binding-0.1.1", "vect-0.4.7"]
extra-deps: ["HGamer3D-0.8.0", "fresco-binding-0.2.0", "vect-0.4.7"]
resolver: lts-5.8
flags: {}
packages: ["."]
Expand All @@ -84,13 +84,10 @@ import Control.Concurrent
import Control.Monad
import System.Exit
start = do
-- initialize system
hg3d <- configureHG3D -- initialize
gameLogic hg3d = do
-- create minimum elements, like a camera
eCam <- newE [
eCam <- newE hg3d [
ctCamera #: FullViewCamera,
ctPosition #: Vec3 1 1 (-30.0),
ctLight #: Light PointLight 1.0 1000.0 1.0
Expand All @@ -99,33 +96,30 @@ start = do
-- do something interesting here, in this example case, it is a text and
-- a rotating cube
eText <- newE [
eText <- newE hg3d [
ctText #: "Rotating Cube Example",
ctScreenRect #: Rectangle 10 10 100 25
]
eGeo <- newE [
eGeo <- newE hg3d [
ctGeometry #: ShapeGeometry Cube,
ctMaterial #: matBlue,
ctScale #: Vec3 10.0 10.0 10.0,
ctPosition #: Vec3 0.0 0.0 0.0,
ctOrientation #: unitU
]
return (eGeo, hg3d)
let rotateCube = do
forever $ do
updateC eGeo ctOrientation (\u -> (rotU vec3Z 0.02) .*. u)
updateC eGeo ctOrientation (\u -> (rotU vec3X 0.015) .*. u)
sleepFor (msecT 12)
rotateCube eGeo = do
forever $ do
updateC eGeo ctOrientation (\u -> (rotU vec3Z 0.02) .*. u)
updateC eGeo ctOrientation (\u -> (rotU vec3X 0.015) .*. u)
sleepFor (msecT 12)
forkIO rotateCube
return ()
main = do
(eGeo, hg3d) <- start
forkIO $ rotateCube eGeo
loopHG3D hg3d (msecT 20) (return True) -- allow close on windows click
runGame standardGraphics3DConfig gameLogic (msecT 20)
return ()
]]

Expand All @@ -143,11 +137,11 @@ writeIt("Setup.hs", setup_file)
writeIt("game.cabal", cabal_file)

run_file = [[
aio start http://www.hgamer3d.org/component/Run-0.7 ./game
aio start http://www.hgamer3d.org/component/Run-1 ./game
]]

run_file_windows = [[
aio start http://www.hgamer3d.org/component/Run-0.7 game.exe
aio start http://www.hgamer3d.org/component/Run-1 game.exe
]]

if this_os == "Windows" then
Expand All @@ -158,7 +152,7 @@ else
end

repl_file = [[
aio http://www.hgamer3d.org/component/Run-0.7 aio http://www.hgamer3d.org/component/Stack ghci
aio http://www.hgamer3d.org/component/Run-1 aio http://www.hgamer3d.org/component/Stack ghci
]]

if this_os == "Windows" then
Expand Down
56 changes: 26 additions & 30 deletions examples/Billion.hs
Expand Up @@ -23,41 +23,38 @@ import Control.Monad

import Data.List

startWorld = do
eG3D <- configureHG3D
return eG3D
-- CH3-2e

-- CH3-3s
-- small tool, to create entities
creator l = newE l
creator w l = newE w l

-- entity creation tools
camera pos = creator [
camera w pos = creator w [
ctCamera #: FullViewCamera,
ctPosition #: pos
]

item pos shape mat = creator [
item w pos shape mat = creator w [
ctMaterial #: mat,
ctGeometry #: ShapeGeometry shape,
ctPosition #: pos,
ctScale #: unitVec3,
ctOrientation #: unitU
]

light pos = creator [
light w pos = creator w [
ctLight #: Light PointLight 1.0 1000.0 1.0,
ctPosition #: pos,
ctColour #: white
]

textOne = creator [
textOne w = creator w [
ctText #: "Billion\n"
, ctScreenRect #: Rectangle 10 10 120 25
]

textTwo = creator [
textTwo w = creator w [
ctText #: ""
, ctScreenRect #: Rectangle 10 50 200 500
]
Expand All @@ -66,12 +63,12 @@ showText e t = setC e ctText t

type Cube = [[[Entity]]]

itemCube shape offset mat = do
itemCube w shape offset mat = do
let r = [2.5, 5.0 .. 25.0]
cubes <-
mapM (\z ->
mapM (\y ->
mapM (\x -> item ((Vec3 x y z) &+ offset) shape mat) r
mapM (\x -> item w ((Vec3 x y z) &+ offset) shape mat) r
) r
) r
return cubes
Expand Down Expand Up @@ -113,7 +110,7 @@ fUX = Vec3 0.05 0.0 0.0
fUY = Vec3 0.0 0.05 0.0
fUZ = Vec3 0.0 0.0 0.05

commandInterpreter cam t2 refCubes refSel cmd = do
commandInterpreter w cam t2 refCubes refSel cmd = do
case cmd of
MoveCamera listOfMoves deltaTime -> do
let oneMove (s, d) = do
Expand Down Expand Up @@ -146,7 +143,7 @@ commandInterpreter cam t2 refCubes refSel cmd = do

Cubes shape off mat -> do
cubes <- readVar refCubes
newCube <- itemCube shape off mat
newCube <- itemCube w shape off mat
writeVar refCubes (cubes ++ [newCube])
writeVar refSel newCube
return ()
Expand Down Expand Up @@ -219,16 +216,16 @@ installText w ieh t2 = do
_ -> return ()
registerCallback w ieh ctKeyEvent (\key -> handleKeys key)

main = do
w <- startWorld
c <- camera (Vec3 0.0 0.0 0.0)
gameLogic w = do

c <- camera w (Vec3 0.0 0.0 0.0)

cubes <- itemCube Pyramid zeroVec3 matBlue
cubes <- itemCube w Pyramid zeroVec3 matBlue

l <- light (Vec3 10.0 10.0 0.0)
ieh <- creator [ctInputEventHandler #: DefaultEventHandler, ctKeyEvent #: NoKeyEvent]
t1 <- textOne
t2 <- textTwo
l <- light w (Vec3 10.0 10.0 0.0)
ieh <- creator w [ctInputEventHandler #: DefaultEventHandler, ctKeyEvent #: NoKeyEvent]
t1 <- textOne w
t2 <- textTwo w
refK <- makeVar []

installKeyPressed w ieh refK
Expand All @@ -238,8 +235,8 @@ main = do

refCubes <- makeVar [cubes]
refSel <- makeVar cubes
forkIO $ loopHG3D w (msecT 30) (return True)
mapM (\cmd -> commandInterpreter c t2 refCubes refSel cmd) (

mapM (\cmd -> commandInterpreter w c t2 refCubes refSel cmd) (
[

-- Intro
Expand Down Expand Up @@ -293,20 +290,19 @@ main = do

[

SetText ("imagine each cube is one year\nthere are 1000 green pyramids, 1000 years ...\n\nlet's add 4000 years"),
Cubes Pyramid (Vec3 (-30) 0.0 0.0) matAqua,
Cubes Pyramid (Vec3 (-60) 0.0 0.0) matTeal,
Cubes Pyramid (Vec3 (-90) 0.0 0.0) matBlue,
Cubes Pyramid (Vec3 (-120) 0.0 0.0) matNavy,

MoveCamera [(Fast, NegZ), (Fast, NegX)] (secT 60)
SetText ("to be continued ..."),
Wait (secT 30)

]
--

)

exitHG3D w
return ()
-- CH3-4e


main = do
runGame standardGraphics3DConfig gameLogic (msecT 20)
return ()

0 comments on commit 9757f02

Please sign in to comment.