add new planets
This commit is contained in:
parent
7b3fdb07bf
commit
8d6c98e58d
4 changed files with 26 additions and 4 deletions
|
@ -15,9 +15,9 @@ The application is working but certain features are missing or unpolished:
|
||||||
✅ Interactive value change (drag'n'drop / scroll)
|
✅ Interactive value change (drag'n'drop / scroll)
|
||||||
✅ Objects can be removed
|
✅ Objects can be removed
|
||||||
✅ Last removed object (planet) can be restored
|
✅ Last removed object (planet) can be restored
|
||||||
❌ add new objects
|
✅ add new planets and satellites
|
||||||
❌ astroid belts
|
|
||||||
❌ randomly generate star system
|
❌ randomly generate star system
|
||||||
|
❌ astroid belts
|
||||||
❌ Export graphic via print or PDF
|
❌ Export graphic via print or PDF
|
||||||
❌ Export data
|
❌ Export data
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "starsy",
|
"name": "starsy",
|
||||||
"description": "Random Star System Generator",
|
"description": "Random Star System Generator",
|
||||||
"version": "0.4.5",
|
"version": "0.4.6",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
|
|
22
src/App.vue
22
src/App.vue
|
@ -29,7 +29,7 @@
|
||||||
<li><strong>ONLY THE LAST</strong> removed planet can be restored.</li>
|
<li><strong>ONLY THE LAST</strong> removed planet can be restored.</li>
|
||||||
</Tips>
|
</Tips>
|
||||||
<SystemSettings v-model:designation="star.designation" v-model:radius="star.radius" />
|
<SystemSettings v-model:designation="star.designation" v-model:radius="star.radius" />
|
||||||
<ObjectList v-bind="{ objects, deletedObject, editObject, deleteObject, restoreDeleted }" />
|
<ObjectList v-bind="{ objects, deletedObject, addObject, editObject, deleteObject, restoreDeleted }" />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
@ -43,6 +43,7 @@ import Tips from './components/Tips.vue'
|
||||||
import SystemSettings from './components/SystemSettings.vue'
|
import SystemSettings from './components/SystemSettings.vue'
|
||||||
import ObjectList from './components/ObjectList.vue'
|
import ObjectList from './components/ObjectList.vue'
|
||||||
import ObjectSettings from './components/ObjectSettings.vue'
|
import ObjectSettings from './components/ObjectSettings.vue'
|
||||||
|
import { MAX_DISTANCE_PLANET } from './constants'
|
||||||
|
|
||||||
const star = reactive({
|
const star = reactive({
|
||||||
designation: 'Sol',
|
designation: 'Sol',
|
||||||
|
@ -56,6 +57,25 @@ const themes = ['default', 'retro', 'inverse', 'paper']
|
||||||
const selectedObject = ref(null)
|
const selectedObject = ref(null)
|
||||||
const deletedObject = ref(null) // { index: Number, object: Object }
|
const deletedObject = ref(null) // { index: Number, object: Object }
|
||||||
|
|
||||||
|
function addObject() {
|
||||||
|
const amount = objects.length
|
||||||
|
let distance = 100
|
||||||
|
|
||||||
|
if (amount) {
|
||||||
|
const lastObject = objects[amount - 1]
|
||||||
|
distance = Math.min(MAX_DISTANCE_PLANET, lastObject.distance + 2*lastObject.radius + 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
objects.push({
|
||||||
|
type: 'planet',
|
||||||
|
name: `${star.designation}-${amount + 1}`,
|
||||||
|
radius: 1,
|
||||||
|
distance,
|
||||||
|
satellites: [],
|
||||||
|
rings: 0,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function editObject (object) {
|
function editObject (object) {
|
||||||
if (object) {
|
if (object) {
|
||||||
document.documentElement.scrollTop = 0
|
document.documentElement.scrollTop = 0
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
RESTORE DELETED OBJECT
|
RESTORE DELETED OBJECT
|
||||||
</button>
|
</button>
|
||||||
</tr>
|
</tr>
|
||||||
|
<button class="add" @click="addObject"> </button>
|
||||||
</table>
|
</table>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -29,6 +30,7 @@ import { computed } from 'vue'
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
objects: Array,
|
objects: Array,
|
||||||
deletedObject: [Object, null],
|
deletedObject: [Object, null],
|
||||||
|
addObject: Function,
|
||||||
editObject: Function,
|
editObject: Function,
|
||||||
deleteObject: Function,
|
deleteObject: Function,
|
||||||
restoreDeleted: Function,
|
restoreDeleted: Function,
|
||||||
|
|
Loading…
Reference in a new issue