Merge branch 'master' of git://factorcode.org/git/factor
commit
7c1f4e8839
|
@ -11,7 +11,10 @@ SINGLETON: gvim
|
|||
HOOK: gvim-path io-backend ( -- path )
|
||||
|
||||
M: gvim vim-command ( file line -- string )
|
||||
[ gvim-path , "+" swap number>string append , , ] { } make ;
|
||||
[
|
||||
gvim-path ,
|
||||
number>string "+" prepend , ,
|
||||
] { } make ;
|
||||
|
||||
gvim vim-editor set-global
|
||||
|
||||
|
|
|
@ -3,11 +3,9 @@ namespaces prettyprint editors make ;
|
|||
|
||||
IN: editors.macvim
|
||||
|
||||
: macvim-location ( file line -- )
|
||||
: macvim ( file line -- )
|
||||
drop
|
||||
[ "open" , "-a" , "MacVim", , ] { } make
|
||||
try-process ;
|
||||
|
||||
[ macvim-location ] edit-hook set-global
|
||||
|
||||
run-detached drop ;
|
||||
|
||||
[ macvim ] edit-hook set-global
|
||||
|
|
|
@ -25,7 +25,7 @@ IN: editors.scite
|
|||
number>string "-goto:" prepend ,
|
||||
] { } make ;
|
||||
|
||||
: scite-location ( file line -- )
|
||||
: scite ( file line -- )
|
||||
scite-command run-detached drop ;
|
||||
|
||||
[ scite-location ] edit-hook set-global
|
||||
[ scite ] edit-hook set-global
|
||||
|
|
|
@ -2,9 +2,9 @@ USING: definitions io.launcher kernel math math.parser parser
|
|||
namespaces prettyprint editors make ;
|
||||
IN: editors.textedit
|
||||
|
||||
: textedit-location ( file line -- )
|
||||
: textedit ( file line -- )
|
||||
drop
|
||||
[ "open" , "-a" , "TextEdit", , ] { } make
|
||||
try-process ;
|
||||
run-detached drop ;
|
||||
|
||||
[ textedit-location ] edit-hook set-global
|
||||
[ textedit ] edit-hook set-global
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
USING: definitions io.launcher kernel math math.parser parser
|
||||
namespaces prettyprint editors make ;
|
||||
|
||||
IN: editors.textmate
|
||||
|
||||
: textmate-location ( file line -- )
|
||||
: textmate ( file line -- )
|
||||
[ "mate" , "-a" , "-l" , number>string , , ] { } make
|
||||
try-process ;
|
||||
run-detached drop ;
|
||||
|
||||
[ textmate-location ] edit-hook set-global
|
||||
[ textmate ] edit-hook set-global
|
||||
|
|
|
@ -3,7 +3,7 @@ USING: definitions editors help help.markup help.syntax io io.files
|
|||
IN: editors.vim
|
||||
|
||||
ARTICLE: { "vim" "vim" } "Vim support"
|
||||
"This module makes the " { $link edit } " word work with Vim by setting the " { $link edit-hook } " global variable to call " { $link vim-location } ". The " { $link vim-path } " variable contains the name of the vim executable. The default " { $link vim-path } " is " { $snippet "\"gvim\"" } "."
|
||||
"This module makes the " { $link edit } " word work with Vim by setting the " { $link edit-hook } " global variable to call " { $link vim } ". The " { $link vim-path } " variable contains the name of the vim executable. The default " { $link vim-path } " is " { $snippet "\"gvim\"" } "."
|
||||
$nl
|
||||
"If you intend to use this module regularly, it helps to have it load during stage 2 bootstrap. On Windows, place the following example " { $snippet ".factor-boot-rc" } " in the directory returned by " { $link home } ":"
|
||||
{ $code
|
||||
|
|
|
@ -4,7 +4,6 @@ make ;
|
|||
IN: editors.vim
|
||||
|
||||
SYMBOL: vim-path
|
||||
|
||||
SYMBOL: vim-editor
|
||||
HOOK: vim-command vim-editor ( file line -- array )
|
||||
|
||||
|
@ -12,12 +11,13 @@ SINGLETON: vim
|
|||
|
||||
M: vim vim-command
|
||||
[
|
||||
vim-path get , swap , "+" swap number>string append ,
|
||||
vim-path get ,
|
||||
[ , ] [ number>string "+" prepend , ] bi*
|
||||
] { } make ;
|
||||
|
||||
: vim-location ( file line -- )
|
||||
vim-command try-process ;
|
||||
: vim ( file line -- )
|
||||
vim-command run-detached drop ;
|
||||
|
||||
"vim" vim-path set-global
|
||||
[ vim-location ] edit-hook set-global
|
||||
vim vim-editor set-global
|
||||
[ vim ] edit-hook set-global
|
||||
\ vim vim-editor set-global
|
||||
|
|
|
@ -12,10 +12,11 @@ SYMBOLS: +hid-manager+ +keyboard-state+ +mouse-state+ +controller-states+ ;
|
|||
|
||||
iokit-game-input-backend game-input-backend set-global
|
||||
|
||||
: hid-manager-matching ( matching-seq -- alien )
|
||||
f 0 IOHIDManagerCreate
|
||||
[ swap >plist IOHIDManagerSetDeviceMatchingMultiple ]
|
||||
keep ;
|
||||
: make-hid-manager ( -- alien )
|
||||
f 0 IOHIDManagerCreate ;
|
||||
|
||||
: set-hid-manager-matching ( alien matching-seq -- )
|
||||
>plist IOHIDManagerSetDeviceMatchingMultiple ;
|
||||
|
||||
: devices-from-hid-manager ( manager -- vector )
|
||||
[
|
||||
|
@ -85,9 +86,6 @@ CONSTANT: hat-switch-matching-hash
|
|||
: ?hat-switch ( device -- ? )
|
||||
hat-switch-matching-hash ?axis ;
|
||||
|
||||
: hid-manager-matching-game-devices ( -- alien )
|
||||
game-devices-matching-seq hid-manager-matching ;
|
||||
|
||||
: device-property ( device key -- value )
|
||||
<NSString> IOHIDDeviceGetProperty [ plist> ] [ f ] if* ;
|
||||
: element-property ( element key -- value )
|
||||
|
@ -288,12 +286,13 @@ M: iokit-game-input-backend reset-mouse
|
|||
256 <bit-array> +keyboard-state+ set-global ;
|
||||
|
||||
M: iokit-game-input-backend (open-game-input)
|
||||
hid-manager-matching-game-devices {
|
||||
make-hid-manager {
|
||||
[ initialize-variables ]
|
||||
[ device-matched-callback f IOHIDManagerRegisterDeviceMatchingCallback ]
|
||||
[ device-removed-callback f IOHIDManagerRegisterDeviceRemovalCallback ]
|
||||
[ device-input-callback f IOHIDManagerRegisterInputValueCallback ]
|
||||
[ 0 IOHIDManagerOpen mach-error ]
|
||||
[ game-devices-matching-seq set-hid-manager-matching ]
|
||||
[
|
||||
CFRunLoopGetMain CFRunLoopDefaultMode
|
||||
IOHIDManagerScheduleWithRunLoop
|
||||
|
|
|
@ -6,13 +6,15 @@ opengl.shaders opengl.textures opengl.textures.private
|
|||
sequences sequences.product specialized-arrays.float
|
||||
terrain.generation terrain.shaders ui ui.gadgets
|
||||
ui.gadgets.worlds ui.pixel-formats game-worlds method-chains
|
||||
math.affine-transforms noise ui.gestures ;
|
||||
math.affine-transforms noise ui.gestures combinators.short-circuit ;
|
||||
IN: terrain
|
||||
|
||||
CONSTANT: FOV $[ 2.0 sqrt 1+ ]
|
||||
CONSTANT: NEAR-PLANE $[ 1.0 1024.0 / ]
|
||||
CONSTANT: FAR-PLANE 2.0
|
||||
CONSTANT: PLAYER-START-LOCATION { 0.5 0.51 0.5 }
|
||||
CONSTANT: VELOCITY-MODIFIER-NORMAL { 1.0 1.0 1.0 }
|
||||
CONSTANT: VELOCITY-MODIFIER-FAST { 2.0 1.0 2.0 }
|
||||
CONSTANT: PLAYER-HEIGHT $[ 1.0 256.0 / ]
|
||||
CONSTANT: GRAVITY $[ 1.0 4096.0 / ]
|
||||
CONSTANT: JUMP $[ 1.0 1024.0 / ]
|
||||
|
@ -28,13 +30,23 @@ CONSTANT: terrain-vertex-distance { $[ 1.0 512.0 / ] $[ 1.0 512.0 / ] }
|
|||
CONSTANT: terrain-vertex-row-length $[ 512 1 + 2 * ]
|
||||
|
||||
TUPLE: player
|
||||
location yaw pitch velocity velocity-modifier ;
|
||||
location yaw pitch velocity velocity-modifier
|
||||
reverse-time ;
|
||||
|
||||
TUPLE: terrain-world < game-world
|
||||
player
|
||||
sky-image sky-texture sky-program
|
||||
terrain terrain-segment terrain-texture terrain-program
|
||||
terrain-vertex-buffer ;
|
||||
terrain-vertex-buffer
|
||||
history ;
|
||||
|
||||
: <player> ( -- player )
|
||||
player new
|
||||
PLAYER-START-LOCATION >>location
|
||||
0.0 >>yaw
|
||||
0.0 >>pitch
|
||||
{ 0.0 0.0 0.0 } >>velocity
|
||||
VELOCITY-MODIFIER-NORMAL >>velocity-modifier ;
|
||||
|
||||
M: terrain-world tick-length
|
||||
drop 1000 30 /i ;
|
||||
|
@ -140,12 +152,17 @@ terrain-world H{
|
|||
:: handle-input ( world -- )
|
||||
world player>> :> player
|
||||
read-keyboard keys>> :> keys
|
||||
key-left-shift keys nth [
|
||||
{ 2.0 1.0 2.0 } player (>>velocity-modifier)
|
||||
] when
|
||||
key-left-shift keys nth [
|
||||
{ 1.0 1.0 1.0 } player (>>velocity-modifier)
|
||||
] unless
|
||||
|
||||
key-left-shift keys nth
|
||||
VELOCITY-MODIFIER-FAST VELOCITY-MODIFIER-NORMAL ? player (>>velocity-modifier)
|
||||
|
||||
{
|
||||
[ key-1 keys nth 1 f ? ]
|
||||
[ key-2 keys nth 2 f ? ]
|
||||
[ key-3 keys nth 3 f ? ]
|
||||
[ key-4 keys nth 4 f ? ]
|
||||
[ key-5 keys nth 10000 f ? ]
|
||||
} 0|| player (>>reverse-time)
|
||||
|
||||
key-w keys nth [ player walk-forward ] when
|
||||
key-s keys nth [ player walk-backward ] when
|
||||
|
@ -199,11 +216,30 @@ terrain-world H{
|
|||
: scaled-velocity ( player -- velocity )
|
||||
[ velocity>> ] [ velocity-modifier>> ] bi v* ;
|
||||
|
||||
: tick-player ( world player -- )
|
||||
: save-history ( world player -- )
|
||||
clone swap history>> push ;
|
||||
|
||||
:: tick-player-reverse ( world player -- )
|
||||
player reverse-time>> :> reverse-time
|
||||
world history>> :> history
|
||||
history length 0 > [
|
||||
history length reverse-time 1 - - 1 max history set-length
|
||||
history pop world (>>player)
|
||||
] when ;
|
||||
|
||||
: tick-player-forward ( world player -- )
|
||||
2dup save-history
|
||||
[ apply-friction apply-gravity ] change-velocity
|
||||
dup scaled-velocity [ v+ [ terrain-segment>> ] dip collide ] curry with change-location
|
||||
drop ;
|
||||
|
||||
: tick-player ( world player -- )
|
||||
dup reverse-time>> [
|
||||
tick-player-reverse
|
||||
] [
|
||||
tick-player-forward
|
||||
] if ;
|
||||
|
||||
M: terrain-world tick*
|
||||
[ dup focused?>> [ handle-input ] [ drop ] if ]
|
||||
[ dup player>> tick-player ] bi ;
|
||||
|
@ -226,7 +262,8 @@ BEFORE: terrain-world begin-world
|
|||
GL_DEPTH_TEST glEnable
|
||||
GL_TEXTURE_2D glEnable
|
||||
GL_VERTEX_ARRAY glEnableClientState
|
||||
PLAYER-START-LOCATION 0.0 0.0 { 0.0 0.0 0.0 } { 1.0 1.0 1.0 } player boa >>player
|
||||
<player> >>player
|
||||
V{ } clone >>history
|
||||
<perlin-noise-table> 0.01 0.01 <scale> { 512 512 } perlin-noise-image
|
||||
[ >>sky-image ] keep
|
||||
make-texture [ set-texture-parameters ] keep >>sky-texture
|
||||
|
|
Loading…
Reference in New Issue