Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'From Cuis 5.0 [latest update: #4024] on 19 March 2020 at 10:53:57 pm'!
- 'Description '!
- !provides: 'Game-Raylib' 1 4!
- !requires: 'FFI' 1 33 nil!
- SystemOrganization addCategory: #'Game-Raylib'!
- !classDefinition: #RaylibColor category: #'Game-Raylib'!
- ExternalStructure subclass: #RaylibColor
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'Game-Raylib'!
- !classDefinition: 'RaylibColor class' category: #'Game-Raylib'!
- RaylibColor class
- instanceVariableNames: ''!
- !classDefinition: #RaylibRectangle category: #'Game-Raylib'!
- ExternalStructure subclass: #RaylibRectangle
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'Game-Raylib'!
- !classDefinition: 'RaylibRectangle class' category: #'Game-Raylib'!
- RaylibRectangle class
- instanceVariableNames: ''!
- !classDefinition: #RaylibVector2 category: #'Game-Raylib'!
- ExternalStructure subclass: #RaylibVector2
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'Game-Raylib'!
- !classDefinition: 'RaylibVector2 class' category: #'Game-Raylib'!
- RaylibVector2 class
- instanceVariableNames: ''!
- !classDefinition: #Raylib category: #'Game-Raylib'!
- Object subclass: #Raylib
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'Game-Raylib'!
- !classDefinition: 'Raylib class' category: #'Game-Raylib'!
- Raylib class
- instanceVariableNames: ''!
- !classDefinition: #RaylibExamples category: #'Game-Raylib'!
- Object subclass: #RaylibExamples
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'Game-Raylib'!
- !classDefinition: 'RaylibExamples class' category: #'Game-Raylib'!
- RaylibExamples class
- instanceVariableNames: ''!
- !classDefinition: #RaylibKeyboardKey category: #'Game-Raylib'!
- Object subclass: #RaylibKeyboardKey
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'Game-Raylib'!
- !classDefinition: 'RaylibKeyboardKey class' category: #'Game-Raylib'!
- RaylibKeyboardKey class
- instanceVariableNames: ''!
- !classDefinition: #RaylibMouseButton category: #'Game-Raylib'!
- Object subclass: #RaylibMouseButton
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'Game-Raylib'!
- !classDefinition: 'RaylibMouseButton class' category: #'Game-Raylib'!
- RaylibMouseButton class
- instanceVariableNames: ''!
- !RaylibColor methodsFor: 'accessing'!
- a
- "This method was automatically generated. See RaylibColor class>>fields."
- <generated>
- ^handle unsignedCharAt: 4! !
- !RaylibColor methodsFor: 'accessing'!
- a: anObject
- "This method was automatically generated. See RaylibColor class>>fields."
- <generated>
- handle unsignedCharAt: 4 put: anObject! !
- !RaylibColor methodsFor: 'accessing'!
- b
- "This method was automatically generated. See RaylibColor class>>fields."
- <generated>
- ^handle unsignedCharAt: 3! !
- !RaylibColor methodsFor: 'accessing'!
- b: anObject
- "This method was automatically generated. See RaylibColor class>>fields."
- <generated>
- handle unsignedCharAt: 3 put: anObject! !
- !RaylibColor methodsFor: 'accessing'!
- g
- "This method was automatically generated. See RaylibColor class>>fields."
- <generated>
- ^handle unsignedCharAt: 2! !
- !RaylibColor methodsFor: 'accessing'!
- g: anObject
- "This method was automatically generated. See RaylibColor class>>fields."
- <generated>
- handle unsignedCharAt: 2 put: anObject! !
- !RaylibColor methodsFor: 'accessing'!
- r
- "This method was automatically generated. See RaylibColor class>>fields."
- <generated>
- ^handle unsignedCharAt: 1! !
- !RaylibColor methodsFor: 'accessing'!
- r: anObject
- "This method was automatically generated. See RaylibColor class>>fields."
- <generated>
- handle unsignedCharAt: 1 put: anObject! !
- !RaylibColor class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 12:07:03'!
- darkblue
- ^ self fromHandle: #[0 82 172 255]! !
- !RaylibColor class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 10:47:30'!
- darkgray
- ^ self fromHandle: #[80 80 80 255].! !
- !RaylibColor class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 14:32:39'!
- gray
- ^ self fromHandle: #[130 130 130 255]! !
- !RaylibColor class methodsFor: 'instance creation' stamp: 'smotti 3/18/2020 23:22:31'!
- lightgray
- ^ self fromHandle: #[200 200 200 255].! !
- !RaylibColor class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 12:17:29'!
- lime
- ^ self fromHandle: #[0 158 47 255]! !
- !RaylibColor class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 11:14:10'!
- maroon
- ^ self fromHandle: #[190 33 55 255]! !
- !RaylibColor class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 11:40:20'!
- r: red g: green b: blue a: alpha
- | color |
- color := self new .
- color r: red .
- color g: green .
- color b: blue .
- color a: alpha.
- ^ color! !
- !RaylibColor class methodsFor: 'instance creation' stamp: 'smotti 3/18/2020 23:22:26'!
- raywhite
- ^ self fromHandle: #[240 240 240 255]! !
- !RaylibColor class methodsFor: 'compiling' stamp: 'smotti 3/18/2020 22:54:32'!
- fields
- ^ #( (r 'char') (g 'char') (b 'char') (a 'char') )! !
- !RaylibRectangle methodsFor: 'accessing'!
- height
- "This method was automatically generated. See RaylibRectangle class>>fields."
- <generated>
- ^handle floatAt: 13! !
- !RaylibRectangle methodsFor: 'accessing'!
- height: anObject
- "This method was automatically generated. See RaylibRectangle class>>fields."
- <generated>
- handle floatAt: 13 put: anObject! !
- !RaylibRectangle methodsFor: 'accessing'!
- width
- "This method was automatically generated. See RaylibRectangle class>>fields."
- <generated>
- ^handle floatAt: 9! !
- !RaylibRectangle methodsFor: 'accessing'!
- width: anObject
- "This method was automatically generated. See RaylibRectangle class>>fields."
- <generated>
- handle floatAt: 9 put: anObject! !
- !RaylibRectangle methodsFor: 'accessing'!
- x
- "This method was automatically generated. See RaylibRectangle class>>fields."
- <generated>
- ^handle floatAt: 1! !
- !RaylibRectangle methodsFor: 'accessing'!
- x: anObject
- "This method was automatically generated. See RaylibRectangle class>>fields."
- <generated>
- handle floatAt: 1 put: anObject! !
- !RaylibRectangle methodsFor: 'accessing'!
- y
- "This method was automatically generated. See RaylibRectangle class>>fields."
- <generated>
- ^handle floatAt: 5! !
- !RaylibRectangle methodsFor: 'accessing'!
- y: anObject
- "This method was automatically generated. See RaylibRectangle class>>fields."
- <generated>
- handle floatAt: 5 put: anObject! !
- !RaylibRectangle class methodsFor: 'compiling' stamp: 'smotti 3/19/2020 14:56:05'!
- fields
- ^ #( (x 'float') (y 'float') (width 'float') (height 'float') )! !
- !RaylibRectangle class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 16:26:10'!
- x: x y: y width: width height: height
- | rectangle |
- rectangle := self fromHandle: (ExternalAddress gcallocate: 16) .
- rectangle x: x .
- rectangle y: y.
- rectangle width: width .
- rectangle height: height .
- ^ rectangle! !
- !RaylibVector2 methodsFor: 'accessing'!
- x
- "This method was automatically generated. See RaylibVector2 class>>fields."
- <generated>
- ^handle floatAt: 1! !
- !RaylibVector2 methodsFor: 'accessing'!
- x: anObject
- "This method was automatically generated. See RaylibVector2 class>>fields."
- <generated>
- handle floatAt: 1 put: anObject! !
- !RaylibVector2 methodsFor: 'accessing'!
- y
- "This method was automatically generated. See RaylibVector2 class>>fields."
- <generated>
- ^handle floatAt: 5! !
- !RaylibVector2 methodsFor: 'accessing'!
- y: anObject
- "This method was automatically generated. See RaylibVector2 class>>fields."
- <generated>
- handle floatAt: 5 put: anObject! !
- !RaylibVector2 class methodsFor: 'compiling' stamp: 'smotti 3/19/2020 22:51:40'!
- fields
- "self defineFields"
- ^ #( (x 'float') (y 'float') )! !
- !RaylibVector2 class methodsFor: 'class initialization' stamp: 'smotti 3/19/2020 22:34:01'!
- initialize
- self compileFields ! !
- !RaylibVector2 class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 22:43:53'!
- x: x y: y
- | vector |
- "vector := self fromHandle: (ExternalAddress allocate: 8) ."
- vector := self new .
- vector x: x .
- vector y: y .
- ^ vector! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/18/2020 22:40:19'!
- apiBeginDrawing
- <apicall: void 'BeginDrawing' () module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/18/2020 23:07:07'!
- apiClearBackground: aColor
- <apicall: void 'ClearBackground' (RaylibColor) module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/18/2020 21:50:03'!
- apiCloseWindow
- <apicall: void 'CloseWindow' () module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/19/2020 11:30:33'!
- apiDrawCircleAtX: x y: y radius: radius color: color
- <apicall: void 'DrawCircle' (ulong ulong float RaylibColor) module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/19/2020 22:52:44'!
- apiDrawCircleVatPosition: center radius: radius color: color
- "TODO: Figure out why it doesn't work with the vector. It works for color structs."
- "Meaning the apicall to DrawCircleV doesn't work. It doesn't error, it just doesn't draw anything."
- "Though DrawCircle works, which actually calls DrawCircleV in raylib. That's why we call it here."
- self apiDrawCircleAtX: center x y: center y radius: radius color: color .
- "<cdecl: void 'DrawCircleV' (RaylibVector2 float RaylibColor) module: 'libraylib'>
- ^ self externalCallFailed"! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/19/2020 14:31:17'!
- apiDrawRectangleAtX: x y: y width: width height: height color: color
- <apicall: void 'DrawRectangle' (ulong ulong ulong ulong RaylibColor) module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/19/2020 16:57:00'!
- apiDrawRectangleRec: aRectangle color: aColor
- "<apicall: void 'DrawRectangleRec' (RaylibRectangle RaylibColor) module: 'libraylib'>
- ^ self externalCallFailed "
- self apiDrawRectangleAtX: aRectangle x y: aRectangle y width: aRectangle width height: aRectangle height color: aColor .! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/18/2020 22:54:41'!
- apiDrawText: text posX: posX posY: posY fontSize: fontSize color: color
- <apicall: void 'DrawText' (char* ulong ulong ulong RaylibColor) module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/18/2020 22:40:46'!
- apiEndDrawing
- <apicall: void 'EndDrawing' () module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/18/2020 22:58:12'!
- apiGetColor: anInteger
- <apicall: RaylibColor 'GetColor' (ulong) module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/19/2020 12:08:52'!
- apiGetMousePosition
- <apicall: RaylibVector2 'GetMousePosition' () module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/19/2020 14:29:48'!
- apiGetMouseWheelMove
- <apicall: ulong 'GetMouseWheelMove' () module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/18/2020 21:48:34'!
- apiInitWindowWidth: width height: height title: title
- <apicall: void 'InitWindow' (ulong ulong char*) module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/19/2020 10:24:34'!
- apiIsKeyDown: aKey
- <apicall: bool 'IsKeyDown' (ulong) module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/19/2020 12:14:23'!
- apiIsMouseButtonPressed: aButton
- <apicall: bool 'IsMouseButtonPressed' (ulong) module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/19/2020 09:50:07'!
- apiSetTargetFPS: anInteger
- <apicall: void 'SetTargetFPS' (ulong) module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/18/2020 22:37:02'!
- apiSetTargetFps: anInteger
- <apicall: void 'SetTargetFps' (ulong) module: 'libraylib'>
- ^ self externalCallFailed ! !
- !Raylib class methodsFor: 'as yet unclassified' stamp: 'smotti 3/18/2020 22:37:49'!
- apiWindowShouldClose
- <apicall: bool 'WindowShouldClose' () module: 'libraylib'>
- ^ self externalCallFailed ! !
- !RaylibExamples class methodsFor: 'core' stamp: 'smotti 3/19/2020 16:01:39'!
- basicWindow
- | lightgray raywhite |
- lightgray := RaylibColor lightgray.
- raywhite := RaylibColor raywhite.
- Raylib apiInitWindowWidth: 800 height: 450 title: 'raylib [core] example - basic window'.
- Raylib apiSetTargetFPS: 60.
- [Raylib apiWindowShouldClose] whileFalse: [
- Raylib apiBeginDrawing.
- Raylib apiClearBackground: raywhite.
- Raylib apiDrawText: 'Congrats!! You created your first window!!' posX: 190 posY: 200 fontSize: 20 color: lightgray.
- Raylib apiEndDrawing.
- ].
- Raylib apiCloseWindow.! !
- !RaylibExamples class methodsFor: 'core' stamp: 'smotti 3/19/2020 14:54:54'!
- camera2d
- | maxBuildings screenWidth screenHeight player buildings buildColors |
- maxBuildings := 100 .
- screenWidth := 800 .
- screenHeight := 450 .
- Raylib apiInitWindowWidth: screenWidth height: screenHeight title: 'raylib [core] example - 2d camera' .
- player := RaylibRectangle x: 400 y: 280 width: 40 height: 40.
- ! !
- !RaylibExamples class methodsFor: 'core' stamp: 'smotti 3/19/2020 16:29:08'!
- inputKeys
- | width height ballPosition |
- width := 800 .
- height := 450 .
- ballPosition := RaylibVector2 x: (width / 2) asFloat y: (height / 2) asFloat .
- Raylib apiInitWindowWidth: width height: height title: 'raylib [core] example - keyboard input' .
- Raylib apiSetTargetFPS: 60.
- [ Raylib apiWindowShouldClose ] whileFalse: [
- (Raylib apiIsKeyDown: RaylibKeyboardKey right) ifTrue: [ (ballPosition x: ballPosition x + (2 asFloat)) ] .
- (Raylib apiIsKeyDown: RaylibKeyboardKey left) ifTrue: [ (ballPosition x: ballPosition x - (2 asFloat)) ] .
- (Raylib apiIsKeyDown: RaylibKeyboardKey up) ifTrue: [ (ballPosition y: ballPosition y - (2 asFloat)) ] .
- (Raylib apiIsKeyDown: RaylibKeyboardKey down) ifTrue: [ (ballPosition y: ballPosition y + (2 asFloat)) ] .
- Raylib apiBeginDrawing .
- Raylib apiClearBackground: RaylibColor raywhite .
- Raylib apiDrawText: 'move the ball with arrow keys' posX: 10 posY: 10 fontSize: 20 color: RaylibColor lightgray .
- Raylib apiDrawCircleVatPosition: ballPosition radius: 50 asFloat color: RaylibColor maroon .
- "Raylib apiDrawCircleAtX: ballPosition x y: ballPosition y radius: 50 asFloat color: RaylibColor maroon. "
- Raylib apiEndDrawing .
- ].
- Raylib apiCloseWindow .! !
- !RaylibExamples class methodsFor: 'core' stamp: 'smotti 3/19/2020 16:29:13'!
- inputMouse
- | width height ballPosition ballColor |
- width := 800 .
- height := 450 .
- Raylib apiInitWindowWidth: width height: height title: 'raylib [core] example - mouse input' .
- ballPosition := RaylibVector2 x: -100.0 y: 100.0 .
- ballColor := RaylibColor darkblue .
- Raylib apiSetTargetFPS: 60.
- [ Raylib apiWindowShouldClose ] whileFalse: [
- ballPosition := Raylib apiGetMousePosition .
- (Raylib apiIsMouseButtonPressed: RaylibMouseButton leftButton) ifTrue: [ ballColor := RaylibColor maroon ] ifFalse: [
- (Raylib apiIsMouseButtonPressed: RaylibMouseButton rightButton) ifTrue: [ ballColor := RaylibColor darkblue ] ifFalse: [
- (Raylib apiIsMouseButtonPressed: RaylibMouseButton middleButton) ifTrue: [ ballColor := RaylibColor lime ]
- ]
- ] .
- Raylib apiBeginDrawing .
- Raylib apiClearBackground: RaylibColor raywhite .
- Raylib apiDrawCircleVatPosition: ballPosition radius: 40 color: ballColor .
- Raylib apiDrawText: 'move ball with mouse and click mouse button to change color' posX: 10 posY: 10 fontSize: 20 color: RaylibColor darkgray .
- Raylib apiEndDrawing .
- ] .
- Raylib apiCloseWindow .! !
- !RaylibExamples class methodsFor: 'core' stamp: 'smotti 3/19/2020 14:43:27'!
- inputMouseWheel
- | width height boxPositionY scrollSpeed |
- width := 800 .
- height := 450 .
- Raylib apiInitWindowWidth: width height: height title: 'raylib [core] example - input mouse wheel' .
- boxPositionY := (height / 2) - 40 .
- scrollSpeed := 4 .
- Raylib apiSetTargetFPS: 60.
- [ Raylib apiWindowShouldClose ] whileFalse: [
- boxPositionY := boxPositionY - (Raylib apiGetMouseWheelMove * scrollSpeed) .
- Raylib apiBeginDrawing .
- Raylib apiClearBackground: RaylibColor raywhite .
- Raylib apiDrawRectangleAtX: (width / 2) - 40 y: boxPositionY width: 80 height: 80 color: RaylibColor maroon .
- Raylib apiDrawText: 'Use mouse wheel to move the cube up and down!!' posX: 10 posY: 10 fontSize: 20 color: RaylibColor gray .
- Raylib apiDrawText: 'Box position Y: ' , boxPositionY asString posX: 10 posY: 40 fontSize: 20 color: RaylibColor lightgray .
- Raylib apiEndDrawing .
- ] .
- Raylib apiCloseWindow .! !
- !RaylibKeyboardKey class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 10:42:54'!
- down
- ^ 264! !
- !RaylibKeyboardKey class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 10:43:10'!
- left
- ^ 263! !
- !RaylibKeyboardKey class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 10:43:19'!
- right
- ^ 262! !
- !RaylibKeyboardKey class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 10:42:41'!
- up
- ^ 265! !
- !RaylibMouseButton class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 12:15:30'!
- leftButton
- ^ 0! !
- !RaylibMouseButton class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 12:15:50'!
- middleButton
- ^ 2! !
- !RaylibMouseButton class methodsFor: 'instance creation' stamp: 'smotti 3/19/2020 12:15:41'!
- rightButton
- ^ 1! !
- RaylibVector2 initialize!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement