4
1
mirror of https://github.com/QuasarApp/Snake.git synced 2025-05-04 21:49:43 +00:00

simple fixes

This commit is contained in:
Andrei Yankovich 2021-08-02 23:31:20 +03:00
parent fbc6bd9a4c
commit 12857c2265
3 changed files with 64 additions and 49 deletions
src
Core
Crawl
CrawlModule/particles
CrawlTestLvl/private

@ -12,13 +12,14 @@ namespace CRAWL {
Fire::Fire(): ParticleEffect(AUTO_CLASS_NAME, "qrc:/CrawlModule/particles/Fire.qml") { Fire::Fire(): ParticleEffect(AUTO_CLASS_NAME, "qrc:/CrawlModule/particles/Fire.qml") {
useDirectionVelosity({0, 0 , 20}, {10, 10, 0}); useDirectionVelosity({0, 0 ,0}, {10, 10, 0});
setParticleScale(4); setParticleScale(4);
setParticleEndScale(12); setParticleEndScale(12);
setParticleScaleVariation(3); setParticleScaleVariation(3);
setLifeSpanVariation(500); setLifeSpanVariation(500);
setColor("#ffaf2c"); setColor("#ffaf2c");
setEnabled(true); setSize({1, 1, 1});
setposition({0,0,10});
setParticleDelegate("qrc:/CrawlModule/particles/FireParticel.qml"); setParticleDelegate("qrc:/CrawlModule/particles/FireParticel.qml");
@ -43,7 +44,7 @@ void Fire::setFireStrength(float newFireStrength) {
setLifeSpan(1000 + _fireStrength); setLifeSpan(1000 + _fireStrength);
auto vel = static_cast<VectorDirection*>(velocity()); auto vel = static_cast<VectorDirection*>(velocity());
vel->setVelosityDirection({0, 0 , _fireStrength}); vel->setVelosityDirection({0, 0 , _fireStrength});
vel->setVelosityDirectionValatility({10, 10, 0}); vel->setVelosityDirectionValatility({10, 10, 0});
emit fireStrengthChanged(); emit fireStrengthChanged();

@ -23,6 +23,7 @@ ParticleEmitter3D {
depthBias: (model)? model.depthBias: 0 depthBias: (model)? model.depthBias: 0
emitRate: (model)? model.emitRate: 0 emitRate: (model)? model.emitRate: 0
enabled: (model)? model.enabled: false enabled: (model)? model.enabled: false
lifeSpan: (model)? model.lifeSpan: 0 lifeSpan: (model)? model.lifeSpan: 0
lifeSpanVariation: (model)? model.lifeSpanVariation: 0 lifeSpanVariation: (model)? model.lifeSpanVariation: 0
@ -39,61 +40,74 @@ ParticleEmitter3D {
} }
} }
Connections { Item {
id: privateRoot id: privateRoot
target: model property var velosity: (model)? model.velocity: null
property string delegate: (model)? model.particleDelegate: ""
property string particleShape: (model)? model.particleShape: ""
property var view: null property var view: null
function onVelocityChanged() { onVelosityChanged: () => {
const objModel = model.velocity; if (!root.model)
return;
if (!objModel) { const objModel = root.model.velocity;
if (view) {
view.distory();
}
root.velocity = view = null; if (!objModel) {
return; if (view) {
} view.distory();
}
const viewTemplate = objModel.viewTemplate; root.velocity = view = null;
return;
}
if (view.path !== viewTemplate) { const viewTemplate = objModel.viewTemplate;
let temp = Qt.createComponent(viewTemplate)
if (temp.status === Component.Ready) {
let obj = temp.createObject()
obj.model = objModel;
if (view) { if (!view || (view.path !== viewTemplate)) {
view.distory(); let temp = Qt.createComponent(viewTemplate)
}
root.velocity = view = obj; if (!temp)
} else { return
console.log("wrong viewTemplate in model " + temp.errorString());
}
}
}
function onParticleDelegateChanged () { if (temp.status === Component.Ready) {
const viewTemplate = root.model.particleDelegate let obj = temp.createObject(root)
let temp = Qt.createComponent(viewTemplate) obj.model = objModel;
if (temp.status === Component.Ready) {
root.particle = temp.createObject();
} else {
console.log("wrong viewTemplate in model " + temp.errorString());
}
}
function onParticleShapeChanged() { if (view) {
const viewTemplate = root.model.particleShape view.distory();
let temp = Qt.createComponent(viewTemplate) }
if (temp.status === Component.Ready) {
root.shape = temp.createObject(); root.velocity = view = obj;
} else { } else {
console.log("wrong viewTemplate in model " + temp.errorString()); console.log("wrong viewTemplate in model " + temp.errorString());
} }
} }
}
onDelegateChanged: () => {
let temp = Qt.createComponent(privateRoot.delegate)
if (!temp)
return
if (temp.status === Component.Ready) {
root.particle = temp.createObject(root.parent);
} else {
console.log("wrong viewTemplate in model " + temp.errorString());
}
}
onParticleShapeChanged: () => {
let temp = Qt.createComponent(privateRoot.particleShape)
if (!temp)
return
if (temp.status === Component.Ready) {
root.shape = temp.createObject(root.parent);
} else {
console.log("wrong viewTemplate in model " + temp.errorString());
}
}
} }
} }

@ -30,7 +30,7 @@ CRAWL::WorldRule *World::initWorldRules() {
using Day = CRAWL::Day<CRAWL::Sun, CRAWL::Moon>; using Day = CRAWL::Day<CRAWL::Sun, CRAWL::Moon>;
return new CRAWL::WorldRule { return new CRAWL::WorldRule {
{0, {{registerObject<Box>(), 1000}, {0, {{registerObject<Box>(), 100},
{registerObject<CRAWL::Fire>(), 10}, {registerObject<CRAWL::Fire>(), 10},
{registerObject<Background>(), 1}, {registerObject<Background>(), 1},
{registerObject<Day>(), 1}}} {registerObject<Day>(), 1}}}