This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
from pygame.locals import * | |
from OpenGL.GL import * | |
from OpenGL.GLU import * | |
from numpy import * | |
vertices = array([ | |
[-1, -1, -1], | |
[1, -1, -1], | |
[1, 1, -1], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
from pygame.locals import * | |
from OpenGL.GL import * | |
from OpenGL.GLU import * | |
import random | |
import numpy as np | |
# Define the cube vertices |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
from pygame.locals import * | |
from OpenGL.GL import * | |
from OpenGL.GLU import * | |
import numpy as np | |
import random | |
pygame.init() | |
clock = pygame.time.Clock() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local clock=os.clock | |
function sleep(n) | |
local t=clock() | |
while clock()-t<=n do end | |
end | |
function sleep_for(t) | |
local t = t or 0 | |
sleep(t) -- Sleep server connection for 1 entire second. | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while true do | |
local keyPress = io.read(1) | |
if keyPress == "w" or keyPress == "W" then | |
print("You just pressed W") | |
elseif keyPress == "a" or keyPress == "A" then | |
print("You just pressed A") | |
elseif keyPress == "s" or keyPress == "S" then | |
print("You just pressed S") | |
elseif keyPress == "d" or keyPress == "D" then | |
print("You just pressed D") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local socket = require("socket") | |
-- create a TCP server and bind it to port 12345 | |
local server = socket.tcp() | |
server:bind("*", 12345) | |
server:listen() | |
-- set the server to non-blocking mode | |
server:settimeout(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addbind("W") | |
addbind("A") | |
addbind("S") | |
addbind("D") | |
function onPlayerKeyPress(id,key,state) | |
if(key=="W" and state==1) then | |
msg("W is pressed!") | |
elseif(key=="A" and state==1) then | |
msg("A is pressed!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onPlayerKeyPress(id,key,state) | |
if(key=="W" and state==1) then | |
print("W is pressed!") | |
elseif(key=="A" and state==1) then | |
print("A is pressed!") | |
elseif(key=="S" and state==1) then | |
print("S is pressed!") | |
elseif(key=="D" and state==1) then | |
print("D is pressed!") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onPlayerKey(player, key, state) | |
if state == 1 then | |
if key == 87 then -- W key | |
-- do something when W is pressed | |
elseif key == 65 then -- A key | |
-- do something when A is pressed | |
elseif key == 83 then -- S key | |
-- do something when S is pressed | |
elseif key == 68 then -- D key | |
-- do something when D is pressed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function c_msg(p,r,g,b,m,c) | |
r,g,b,c=r or '0',g or '0',b or '0',c or '' | |
local k = string.format("%s%s%s%s", string.char(169), r, g, b) | |
-- k=string.sub(k,1,-1) | |
-- k=string.gsub(k,"%s+","") | |
msg2(p, k .. m .. c); | |
end | |
function onPlayerKeyPress(id,key,state) | |
if(state==1)then |