mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:13:05 +02:00
removing old game sample from script-archive
This commit is contained in:
parent
b3798553ed
commit
d0a0120dfe
11 changed files with 0 additions and 30976 deletions
|
@ -1 +0,0 @@
|
||||||
/node_modules
|
|
|
@ -1 +0,0 @@
|
||||||
web: node app.js
|
|
|
@ -1,5 +0,0 @@
|
||||||
This gameserver sets up a server with websockets that listen for messages from interface regarding when users shoot rats, and updates a real-time game board with that information. This is just a first pass, and the plan is to abstract this to work with any kind of game content creators wish to make with High Fidelity.
|
|
||||||
|
|
||||||
To enter the game: Run pistol.js and shoot at rats.
|
|
||||||
For every rat you kill, you get a point.
|
|
||||||
You're score will be displayed at https://desolate-bastion-1742.herokuapp.com/
|
|
|
@ -1,76 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Module dependencies.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var express = require('express');
|
|
||||||
var http = require('http');
|
|
||||||
var _ = require('underscore');
|
|
||||||
var shortid = require('shortid');
|
|
||||||
|
|
||||||
|
|
||||||
var app = express();
|
|
||||||
var server = http.createServer(app);
|
|
||||||
|
|
||||||
var WebSocketServer = require('websocket').server;
|
|
||||||
var wsServer = new WebSocketServer({
|
|
||||||
httpServer: server
|
|
||||||
});
|
|
||||||
|
|
||||||
var users = [];
|
|
||||||
var connections = [];
|
|
||||||
wsServer.on('request', function(request) {
|
|
||||||
console.log("SOMEONE JOINED");
|
|
||||||
var connection = request.accept(null, request.origin);
|
|
||||||
connections.push(connection);
|
|
||||||
connection.on('message', function(data) {
|
|
||||||
var userData = JSON.parse(data.utf8Data);
|
|
||||||
var user = _.find(users, function(user) {
|
|
||||||
return user.username === userData.username;
|
|
||||||
});
|
|
||||||
if (user) {
|
|
||||||
// This user already exists, so just update score
|
|
||||||
users[users.indexOf(user)].score = userData.score;
|
|
||||||
} else {
|
|
||||||
users.push({
|
|
||||||
id: shortid.generate(),
|
|
||||||
username: userData.username,
|
|
||||||
score: userData.score
|
|
||||||
});
|
|
||||||
}
|
|
||||||
connections.forEach(function(aConnection) {
|
|
||||||
aConnection.sendUTF(JSON.stringify({
|
|
||||||
users: users
|
|
||||||
}));
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get('/users', function(req, res) {
|
|
||||||
res.send({
|
|
||||||
users: users
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Configuration */
|
|
||||||
app.set('views', __dirname + '/views');
|
|
||||||
app.use(express.static(__dirname + '/public'));
|
|
||||||
app.set('port', (process.env.PORT || 5000));
|
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'development') {
|
|
||||||
app.use(express.errorHandler({
|
|
||||||
dumpExceptions: true,
|
|
||||||
showStack: true
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Start server */
|
|
||||||
server.listen(app.get('port'), function() {
|
|
||||||
console.log('Express server listening on port %d in %s mode', app.get('port'), app.get('env'));
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = app;
|
|
|
@ -1,87 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var React = require('react');
|
|
||||||
var _ = require('underscore')
|
|
||||||
var $ = require('jquery');
|
|
||||||
|
|
||||||
var UserList = React.createClass({
|
|
||||||
render: function(){
|
|
||||||
var sortedUsers = _.sortBy(this.props.data.users, function(users){
|
|
||||||
//Show higher scorers at top of board
|
|
||||||
return 1 - users.score;
|
|
||||||
});
|
|
||||||
var users = sortedUsers.map(function(user) {
|
|
||||||
|
|
||||||
return (
|
|
||||||
<User username = {user.username} score = {user.score} key = {user.id}></User>
|
|
||||||
)
|
|
||||||
});
|
|
||||||
return (
|
|
||||||
<div>{users}</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var GameBoard = React.createClass({
|
|
||||||
loadDataFromServer: function(data) {
|
|
||||||
$.ajax({
|
|
||||||
url: this.props.url,
|
|
||||||
dataType: 'json',
|
|
||||||
cache: false,
|
|
||||||
success: function(data) {
|
|
||||||
this.setState({data: data});
|
|
||||||
}.bind(this),
|
|
||||||
error: function(xhr, status, err) {
|
|
||||||
console.error(this.props.url, status, err.toString());
|
|
||||||
}.bind(this)
|
|
||||||
});
|
|
||||||
},
|
|
||||||
getInitialState: function() {
|
|
||||||
return {data: {users: []}};
|
|
||||||
},
|
|
||||||
componentDidMount: function() {
|
|
||||||
this.loadDataFromServer();
|
|
||||||
//set up web socket
|
|
||||||
var path = window.location.hostname + ":" + window.location.port;
|
|
||||||
console.log("LOCATION ", path)
|
|
||||||
var socketClient = new WebSocket("wss://" + path);
|
|
||||||
var self = this;
|
|
||||||
socketClient.onopen = function() {
|
|
||||||
console.log("CONNECTED");
|
|
||||||
socketClient.onmessage = function(data) {
|
|
||||||
console.log("ON MESSAGE");
|
|
||||||
self.setState({data: JSON.parse(data.data)});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
},
|
|
||||||
render: function() {
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<div className = "gameTitle">Kill All The Rats!</div>
|
|
||||||
<div className = "boardHeader">
|
|
||||||
<div className="username">PLAYER</div>
|
|
||||||
<div className="score" > SCORE </div>
|
|
||||||
</div>
|
|
||||||
<UserList data ={this.state.data}/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var User = React.createClass({
|
|
||||||
render: function() {
|
|
||||||
return (
|
|
||||||
<div className = "entry">
|
|
||||||
<div className="username"> {this.props.username} </div>
|
|
||||||
<div className="score" > {this.props.score} </div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
React.render(
|
|
||||||
<GameBoard url = "/users" />,
|
|
||||||
document.getElementById('app')
|
|
||||||
);
|
|
|
@ -1,15 +0,0 @@
|
||||||
var gulp = require('gulp');
|
|
||||||
var exec = require('child_process').exec;
|
|
||||||
|
|
||||||
gulp.task('build', function() {
|
|
||||||
exec('npm run build', function(msg){
|
|
||||||
console.log(msg);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('watch', function() {
|
|
||||||
gulp.watch('client/*.jsx', ['build']);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
gulp.task('default', ['build', 'watch'])
|
|
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
"name": "KillAllTheRats",
|
|
||||||
"version": "0.6.9",
|
|
||||||
"scripts": {
|
|
||||||
"build": "browserify ./client/app.jsx -t babelify --outfile ./public/js/app.js",
|
|
||||||
"start": "node app.js"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"express": "^4.13.1",
|
|
||||||
"gulp": "^3.9.0",
|
|
||||||
"jquery": "^2.1.4",
|
|
||||||
"react": "^0.13.3",
|
|
||||||
"shortid": "^2.2.4",
|
|
||||||
"underscore": "^1.8.3",
|
|
||||||
"websocket": "^1.0.22"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"babelify": "^6.1.3",
|
|
||||||
"browserify": "^10.2.6"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
body {
|
|
||||||
font-family: Impact;
|
|
||||||
background-color: #009DC0 ;
|
|
||||||
font-size: 60px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gameTitle {
|
|
||||||
color: #D61010;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entry{
|
|
||||||
width:100%;
|
|
||||||
height:50px;
|
|
||||||
border:1px solid #A9D1E1;
|
|
||||||
color: white;
|
|
||||||
margin-right:10px;
|
|
||||||
padding: 10px;
|
|
||||||
float:left;
|
|
||||||
font-size: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.boardHeader{
|
|
||||||
width:100%;
|
|
||||||
height:50px;
|
|
||||||
border:5px solid #A9D1E1;
|
|
||||||
color: white;
|
|
||||||
margin-right:10px;
|
|
||||||
padding: 10px;
|
|
||||||
float:left;
|
|
||||||
font-size: 40px;
|
|
||||||
}
|
|
||||||
.username{
|
|
||||||
font-weight: bold;
|
|
||||||
float: left;
|
|
||||||
margin-right: 50%;
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
||||||
<link rel="stylesheet" href="css/style.css">
|
|
||||||
<title>Kill The Rats!</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="app"></div>
|
|
||||||
<script src="js/app.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,31 +0,0 @@
|
||||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation())));
|
|
||||||
var scriptURL = Script.resolvePath("pistolScriptSpawner.js");
|
|
||||||
var modelURL = "http://s3.amazonaws.com/hifi-public/cozza13/gun/m1911-handgun+1.fbx";
|
|
||||||
var pistolSpawnerEntity = Entities.addEntity({
|
|
||||||
type: 'Box',
|
|
||||||
position: center,
|
|
||||||
dimensions: {x: 0.38, y: 1.9, z: 3.02},
|
|
||||||
script: scriptURL,
|
|
||||||
visible: false,
|
|
||||||
collisionless: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var pistol = Entities.addEntity({
|
|
||||||
type: 'Model',
|
|
||||||
modelURL: modelURL,
|
|
||||||
position: center,
|
|
||||||
dimensions: {x: 0.38, y: 1.9, z: 3.02},
|
|
||||||
script: scriptURL,
|
|
||||||
color: {red: 200, green: 0, blue: 20},
|
|
||||||
collisionless: true
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function cleanup() {
|
|
||||||
Entities.deleteEntity(pistolSpawnerEntity);
|
|
||||||
Entities.deleteEntity(pistol);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Script.update.connect(update);
|
|
||||||
Script.scriptEnding.connect(cleanup);
|
|
Loading…
Reference in a new issue