lib/play.py)
30|
Realtime 2D/3D game runtime: pygame (window, input, audio) + ModernGL
(OpenGL, GLSL shaders, meshes, textures). Import with
use play;.
Not the same as built-in
game.ticBestMove (tic-tac-toe AI).
40| Install optional deps:
pip install 'someProgrammingLanguage[play]'
(pygame, moderngl, numpy, Pillow). Needs a desktop display. Check with
play.depsOk() (returns
1 / 0).
use play;
win <- play.window(640, 480, "My Game");
tex <- play.solidTexture(win, 1, 0.3, 0.5, 1);
test.while(test.isEqualNumber(win.isOpen(), 1)):
win.tick(60);
win.poll();
test.ifTrue(test.isEqualNumber(win.keyPressed("escape"), 1)):
win.close();
end;
win.clear(0.05, 0.05, 0.08, 1);
win.drawSprite(tex, 100, 80, 64, 64);
win.flip();
end;
play.window(w, h, title) — OpenGL window handleplay.shader(win, vertSrc, fragSrc) / play.shaderFile(win, vertPath, fragPath)play.defaultShader(win) — lit mesh; play.pulseShader(win) — demo fullscreen FXplay.texture(win, path) / play.solidTexture(win, r, g, b, a)play.mesh(win, positions, indices [, normals, uvs])play.quad(win) / play.box(win) / play.sphere(win, segments)play.camera() — eye/target/fov; viewMatrix() / projMatrix(aspect)mat4Identity, perspective, lookAt, translate, rotateX/Y/Z, scale, mulplay.loadSound(path) / play.playSound(snd, loops)isOpen, close, poll, tick(fps), time, dt, flip, titleclear(r,g,b[,a]), enableDepth(0|1)keyDown, keyPressed, mouseX, mouseY, mouseDowndrawSprite(tex, x, y, w, h [, angle, r,g,b,a]), drawQuad, drawFullscreen(shader)draw(mesh, shader, model [, view, proj] [, tex])setShaderUniform(shader, name, number|list) — conventions u_model, u_view, u_proj, u_tex, u_timeexamples/play/hello_sprite.splexamples/play/shader_pulse.splexamples/play/spin_cube.spl
Implementation:
lib/play.py +
someProgrammingLanguage/spl_play/