Skip to content

Commit

Permalink
Merge pull request #52 from aggregate1166877/aggregate1166877-dev
Browse files Browse the repository at this point in the history
#45 #48 #51 Menu system progress, user profile implemented, build scripts implemented.
  • Loading branch information
aggregate1166877 committed Aug 17, 2021
2 parents e801bfa + cf9511f commit 6d8248a
Show file tree
Hide file tree
Showing 49 changed files with 2,634 additions and 33,909 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ dist
.idea

# Specific to this project
build/bundle.js
build/bundle.css
build/game.js
build/worker.js

# The final product is excluded to prevent this repo blowing up into
Expand Down
65 changes: 58 additions & 7 deletions BUILD_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
## Compatibility
This game has been tested on Windows 10 build 1903. It has not been tested on
Linux yet (because rip graphics drivers), but any problems encountered would be
trivial to fix. This is because this project uses a standard nw.js / webpack
setup.
This game has been tested on Windows 10 build 1903 and Ubuntu Linux 18.04.
Other operating systems might actually work with minimal fidgeting because this
project uses a standard nw.js / webpack setup.

If you do encounter problems on Linux and would like to contribute a fix, feel
free to raise a PR.
If you encounter problems with unofficial operating systems and would like to
contribute a fix, feel free to raise a PR.

## The lazy way
Head over to the releases page and download a pre-built copy. Done.
Head over to the [releases page](https://github.com/aggregate1166877/Cosmosis/releases)
and download a pre-built copy. Done.

## By way of developer madness
Please ensure you have the following installed:
Expand Down Expand Up @@ -64,3 +64,54 @@ and restart the game. The game will automatically load the better assets.
Note that some parts of the application (such as the planet loaders) do not yet
use the prod assets, so you will still see the low quality versions. This will
be fixed once development on planetary systems start.


## Creating a distributable game folder
Instructions below were written for Windows, but the same instructions will
work with Linux if you substitute obvious parts where appropriate. For example,
you may substitute `C:\\` with `/tmp`, `win32` with `linux`, `nw.exe` with
`nw`, etc. This project currently fully supports Windows and Linux, and build
scripts are maintained for both.

##### Requirements
Before starting, ensure you have all build requirements satisfied. This
includes a bash terminal with git available, and modern versions of node.js and
npm installed. See 'Development' above for more details.

##### Building the application
* Create a directory to work in, for example `C:\COSMOSIS_BUILDS` and open it.
* Open a bash terminal, and navigate to the builds directory you created above.
* Do a git clone of the repo, example `git clone https://github.com/aggregate1166877/Cosmosis.git`
* Download the Windows SDK version of NW.js matching the version written in
[package.json](package.json). At the time of writing, this is
[NW.js version 0.53.0](https://nwjs.io/blog/v0.53.0/).
* Extract the zip contents ([7-Zip](https://www.7-zip.org/download.html) recommended as Windows ZIP can corrupt files).
* Download the latest `Stand-Alone Production Assets` zip from the [releases page](https://github.com/aggregate1166877/Cosmosis/releases),
and extract it.
* Your builds directory should now have these files / directories:
* `Cosmosis`
* `nwjs-sdk-v0.53.0-win-x64`
* `Stand-Alone.Production.Assets`
* `nwjs-sdk-v0.53.0-win-x64.zip`
* `Stand-Alone.Production.Assets.zip`
* _Note: you may delete the zip files if no longer needed._
* Back in your terminal, run `ls -1`. You should see the same files as above.
* Still in the bash terminal, you may now build the project by running the
build script. It requires passing the NW.js download folder as its only argument.<br>
Example:
```bash
./Cosmosis/build_utils/create_windows_distributable.sh nwjs-sdk-v0.53.0-win-x64/nwjs-sdk-v0.53.0-win-x64
```
The build script will copy the NW.js and Cosmosis folders into a new folder
named `Cosmosis-win-x64`. It will then install the needed build tools, build
the game, and perform cleanup.

##### Tests
Once all the above is complete, please run tests to ensure correct functioning:
* Run `Cosmosis.exe`. Press F12 and make sure there are no errors in the
developer console.
* Still in the dev console, run: `powerOnSelfTest()`. This runs unit tests
(i.e. looks for obvious bugs and problems). You should have no errors.
* If all is good, zip up FILL_ME_IN, rename the zip to `Cosmosis-win-x64.zip`.
* Upload to the [releases](https://github.com/aggregate1166877/Cosmosis/releases)
page.
47 changes: 9 additions & 38 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ faster.

## Assets

#### Mesh file formats
### Mesh file formats
The rules on file formats are somewhat relaxed as some assets may be free
resources obtained online, and aren't always easily modifiable. However, if
making assets yourself, the following structure is recommended and compatible
Expand All @@ -29,7 +29,7 @@ The above allows easy community modding with little required technical
expertise. Having said that, any contributions are highly appreciated, so use
whatever you're comfortable with.

#### Common issues
### Common issues
##### GLTF export crash
* Blender can sometimes crash if you try to use GLTF compression with messed up
geometry (such as orphaned vertices and lines). The solution here is to find
Expand Down Expand Up @@ -60,7 +60,7 @@ scene in all its glory can be loaded into the scene with, hopefully, less than
a million verts. Note that slightly going over 1m isn't a problem in and of
itself, but rather something we should work hard to avoid.

#### Legal crap
### Legal crap

##### Using assets with different licenses
Please do not use anything that is incompatible with this project's license. BSD is an example of a
Expand Down Expand Up @@ -125,9 +125,9 @@ Anyone who can donate their voice probably should :). Submission details TBA.

## Programming

#### Development
### Development
* Please use [official Node.js sources](https://nodejs.org/en/download/) to
install Node 8 or higher, LTS. On Windows the installer should ask if you'd
install Node 10 or higher, LTS. On Windows the installer should ask if you'd
like to install Chocolatey and Python - say yes unless you have your own custom
setup.
* Install git. On Windows, it will ask you how you'd like to handle CR/LF. You
Expand All @@ -142,7 +142,7 @@ currently uses).
a strict requirement, but makes PRs to master easier for those who test the
proposed changes because some small issues will already have been caught.

#### Git branch workflow
### Git branch workflow

```
yourBranch-dev -\
Expand Down Expand Up @@ -172,14 +172,14 @@ stable.
If the current `master` branch is considered stable, it will be merged into
`stable`, at which point your changes will make it into the latest release.

#### Conventions
### Conventions
When creating an object that [] please try to define it somewhere with null
values. `core.js -> $game` and `[cam] -> ctrl` are examples of this.
This has 2 advantages:
* Any semi-decent IDE will produce full auto-completion and documentation.
* Other coders know what kind of structure to expect.

#### Gotchas and problems
### Gotchas and problems

##### Three.js imports
Be careful when using the drei library. It has the incredibly annoying habit
Expand All @@ -190,7 +190,7 @@ happen for things as fundamental as mesh loading. When making changes involving
drei, please always test offline with cache disabled (Dev tools [Ctrl+Shift+I] -> Network -> Disable cache)
to ensure your changes aren't online-only.

#### Setting up three.js auto-completion
### Setting up three.js auto-completion

A tutorial for VSCode is available here:
* http://shrekshao.github.io/2016/06/20/vscode-01/
Expand Down Expand Up @@ -230,32 +230,3 @@ Code dump:
place them in your project folder, or add as Javascript libraries
(File | Settings | Languages & Frameworks | JavaScript | Libraries, Add...)
```
## Creating a distributable exe
There are currently no automatic ways of doing this.
#### Windows
* Download the version of NW.js matching the version written in
[package.json](package.json). At the time of writing, this is
[nw.js version 0.50.2](https://nwjs.io/blog/v0.50.2/).
* Extract the zip contents.
* Open the extracted folder and rename `nwjs-sdk-v0.50.2-win-x64` to
`Cosmosis-win-x64`.
* Clone the Cosmosis repo, and copy its contents into `Cosmosis-win-x64`. The
end result should have `.git` and `nw.exe` in the same directory.
* Go to the [releases](https://github.com/aggregate1166877/Cosmosis/releases)
page and download the latest `Stand-Alone.Production.Assets.zip`. Extract
this and copy `prodHqAssets` into `Cosmosis-win-x64`.
* Run `npm install`.
* Run `npm run prepare-dev` (builds the main game js file; this needs to be
replaced with a prod version in future).
* Run `npm prune --production` (removes about 400MB of dev tools not used by
the distributable).
* Rename `nw.exe` to `Cosmosis.exe`.
* Run `Cosmosis.exe`. Press F12 and make sure there are no errors in the
developer console.
* Still in the dev console, run: `powerOnSelfTest()`. This runs unit tests
(i.e. looks for obvious bugs and problems). You should have no errors.
* If all is good, zip it up, rename the zip to `Cosmosis-win-x64.zip`.
* Upload to the [releases](https://github.com/aggregate1166877/Cosmosis/releases)
page.
33 changes: 25 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
# Cosmosis
**Note: this game is still pre-alpha. Expect a terrible experience.**
<h1 align="center">Cosmosis</h1>

See [BUILD_INSTRUCTIONS.md](BUILD_INSTRUCTIONS.md) for instructions on running
this application.

Demo:<br>
![Demo](demo.gif)
<div align="center">
<b>Downloads</b>
<br>
<a href="https://github.com/aggregate1166877/Cosmosis/releases/latest">
<img src="https://img.shields.io/static/v1?label=Latest%20stable&message=v0.72.0&color=blue&style=for-the-badge">
</a>
<a href="https://github.com/aggregate1166877/Cosmosis/releases">
<img src="https://img.shields.io/static/v1?label=Dev%20builds&message=all%20versions&color=red&style=for-the-badge">
</a>
<br><br>
<b>Note: this game is still pre-alpha. Expect a terrible experience.</b>
<br>
[ Development progress may be tracked via the <a href="">project page</a> ]
<br><br>
Cosmosis is an early work in progress for an open world space game, potentially with
planetary combat and procedural environments. The current priority is to create
a PvP space battle game with arenas next to beautifully rendered procedural
planets.
<br><br>
Demo:
<br>
<img src="demo.gif">
</div>

## What is Cosmosis?
Cosmosis plans to eventually be a high quality open world space exploration
Expand Down Expand Up @@ -77,7 +94,7 @@ has an FPS shooter class for those who do refuse to praise the sun
-->
Cosmosis is an early concept for an open world space game, potentially with
planetary combat and procedural environments. The current priority is to create
a pvp space battle game with arenas next to beautifully rendered procedural
a PvP space battle game with arenas next to beautifully rendered procedural
planets.

It hopes to one day emulate the Milky Way with acceptable precision. The real
Expand Down
37 changes: 6 additions & 31 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
* Create issue for controller support.
Consider renaming startupEmitter to startupChecklist.

Create issue for controller support.

Create issue for API structure that has everything nicely separated into namespaced.

Make ship movable with physics using keyboard controls.
Implement physics in a universally easy to use way.
Expand Down Expand Up @@ -41,7 +45,7 @@ Test switching between hyperdrive and regular.

Implement world position reset when switching to/form hyperdrive.

Implement a ramp based spedometer and make sure distances measured with m/s check out.
Implement a ramp based speedometer and make sure distances measured with m/s check out.

Fix bug where the game can sometimes grab the mouse pointer while the game is
inactive.
Expand Down Expand Up @@ -189,32 +193,3 @@ ammo.js was copied from node_modules to hackedlibs to fix a crash. See its
readme for more details.

--------------------------------------------------------------------

Misc
==============

Find a good way to limit frame rate
-----------------------------------

The application's frame rate is currently controlled by
`node_modules/react-three-fiber/web.js` -> renderLoop()

To limit the frame rate, this line:
`if (repeat !== 0) return requestAnimationFrame(renderLoop);else {`

can be replaced with this this block:
```js
if (repeat !== 0) {
// return requestAnimationFrame(renderLoop);
return setTimeout( function() {
requestAnimationFrame(renderLoop);
}, 1000 / 30 );
}
else {
```

which limits the frame rate to 30fps in this case. The game HAS TO BE frame
rate independent. This is not optional. The problem is that, testing on lower
frame rates, is really difficult when the functionality is hidden away in a
module. Find a way to make this as simple as changing a parameter. Submit a PR
on the issue maybe?
10 changes: 5 additions & 5 deletions app/emitters/CachedEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ CachedEmitter.prototype = {
'initialisation.\n' +
`Example: "new CachedEmitter({rememberPastEvents: ${b}})"`;
},
}
};

/**
* Returns next enum in powers of 2. Power of 2 are used for fast bitmask
Expand Down Expand Up @@ -78,7 +78,7 @@ CachedEmitter.prototype.nextEnum = function nextEnum() {
else {
return this._nextPlainEnum();
}
}
};

/**
* Notify requesters when a part of the application has loaded.
Expand All @@ -103,7 +103,7 @@ CachedEmitter.prototype.on = function CachedEmitterOn(action, callback) {
// Log request.
this._listeners.push({ action, callback });
}
}
};

/**
* Notifies all listener that part of the application has loaded.
Expand All @@ -126,7 +126,7 @@ CachedEmitter.prototype.emit = function CachedEmitterEmit(action) {
len--;
}
}
}
};

/**
* Removes a past action from the remembered cache. If this object does not use
Expand All @@ -145,6 +145,6 @@ CachedEmitter.prototype.forgetCachedAction = function forgetCachedAction(action)
}
// Remove the specified action.
this._pastEvents ^= action;
}
};

export default CachedEmitter;
4 changes: 3 additions & 1 deletion app/emitters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const startupEmitter = new CachedEmitter({ rememberPastEvents: true });
// Used to keep track of core load progress. Note that progress is
// asynchronous, and actions are not guaranteed to happen in any specific
// order. The exception to this is startupEvent.ready, which will always
// trigger last.
// trigger last. Note that all these triggers must be called for the game to
// recognise its state as 'loaded'. If one or more items are not triggered, the
// loading screen will not end.
// TODO: add on camControllerReady.
export const startupEvent = {
/* Game menu component has mounted. */
Expand Down

0 comments on commit 6d8248a

Please sign in to comment.