Hallo!
Ich habe heute mit Javascript angefangen, ich versuche ein kleines Männchen zu programmieren, welches rumlaufen kann.
Nun habe ich ein Problem dass ich den Code schon fast fertig habe, nur ein kleines Problem habe, auf die Lösung komme ich nicht, da ich wahrscheinlich zu dumm bin
Kann mir Jemand helfen?
var cover = new THREE.MeshNormalMaterial();
var body = new THREE.SphereGeometry(100);
var avatar = new THREE.Mesh(body, cover);
scene.add(avatar);
var hand = new THREE.SphereGeometry(50);
var right_hand = new THREE.Mesh(hand, cover);
right_hand.position.set(-150, 0, 0);
avatar.add(right_hand);
var left_hand = new THREE.Mesh(hand, cover);
left_hand.position.set(150, 0, 0);
avatar.add(left_hand);
var foot = new THREE.SphereGeometry(50);
var right_foot = new THREE.Mesh(foot, cover);
right_foot.position.set(-75, -125, 0);
avatar.add(right_foot);
var left_foot = new THREE.Mesh(foot, cover)
left_foot.position.set(75, -125, 0)
avatar.add(left_foot)
// Now, show what the camera sees on the screen:
var is_cartwheeling = false
function animate() {
requestAnimationFrame(animate);
if (is_cartwheeling) {
avatar.rotation.z = avatar.rotation.z + 0.05;
}
renderer.render(scene, camera);
}
animate();
// Auf Tastendruckereignisse lauschen
document.addEventListener("keydown", function(event) {
var code = event.keyCode;
if (code == 37) avatar.position.x = avatar.position.x-5; // Nach Links
if (code == 38) avatar position.z = avatar.position.z-5; // Hoch
if (code == 39) avatar position.x = avatar.position.x+5; // Nach Rechts
if (code == 40) avatar position.z = avatar position.z+5; // Runter
});
</script>
In den Letzten 5 geschriebenen Zeilen komm immer die Fehlermeldung "Expected an assigment or funktion call and instead saw an expression. Missing ; before statement"
Und ja ich bin schlecht im programmieren
Ich habe heute mit Javascript angefangen, ich versuche ein kleines Männchen zu programmieren, welches rumlaufen kann.
Nun habe ich ein Problem dass ich den Code schon fast fertig habe, nur ein kleines Problem habe, auf die Lösung komme ich nicht, da ich wahrscheinlich zu dumm bin
Kann mir Jemand helfen?
var cover = new THREE.MeshNormalMaterial();
var body = new THREE.SphereGeometry(100);
var avatar = new THREE.Mesh(body, cover);
scene.add(avatar);
var hand = new THREE.SphereGeometry(50);
var right_hand = new THREE.Mesh(hand, cover);
right_hand.position.set(-150, 0, 0);
avatar.add(right_hand);
var left_hand = new THREE.Mesh(hand, cover);
left_hand.position.set(150, 0, 0);
avatar.add(left_hand);
var foot = new THREE.SphereGeometry(50);
var right_foot = new THREE.Mesh(foot, cover);
right_foot.position.set(-75, -125, 0);
avatar.add(right_foot);
var left_foot = new THREE.Mesh(foot, cover)
left_foot.position.set(75, -125, 0)
avatar.add(left_foot)
// Now, show what the camera sees on the screen:
var is_cartwheeling = false
function animate() {
requestAnimationFrame(animate);
if (is_cartwheeling) {
avatar.rotation.z = avatar.rotation.z + 0.05;
}
renderer.render(scene, camera);
}
animate();
// Auf Tastendruckereignisse lauschen
document.addEventListener("keydown", function(event) {
var code = event.keyCode;
if (code == 37) avatar.position.x = avatar.position.x-5; // Nach Links
if (code == 38) avatar position.z = avatar.position.z-5; // Hoch
if (code == 39) avatar position.x = avatar.position.x+5; // Nach Rechts
if (code == 40) avatar position.z = avatar position.z+5; // Runter
});
</script>
In den Letzten 5 geschriebenen Zeilen komm immer die Fehlermeldung "Expected an assigment or funktion call and instead saw an expression. Missing ; before statement"
Und ja ich bin schlecht im programmieren