The image is not moving I've looked though other queries but none of the answers work for me.
HTML: The image that I'm having problems with is "frisk".
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title id="title" style="font-family:WD">CONTINUE</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="code.js"></script>
</head>
<body>
<p id="myDIV" class="invert" style="font-family:WD"></p>
<!--<button onclick="myFunction()">Click Me</button>-->
<img id="frisk" src="sprite/frisk/frisk_up.png">
</body>
<iframe src="music/silence.mp3" allow="autoplay" id="audio" style="display: none"></iframe>
<audio id="player" loop>
<source src="muisc/mus_smile.mp3" type="audio/mp3">
</audio>
<audio id="1" >
<source src="voice/voice_smile/voice_gaster_1.mp3" type="audio/mp3">
</audio>
<audio id="2" >
<source src="voice/voice_smile/voice_gaster_2.mp3" type="audio/mp3">
</audio>
<audio id="3" >
<source src="voice/voice_smile/voice_gaster_3.mp3" type="audio/mp3">
</audio>
<audio id="4" >
<source src="voice/voice_smile/voice_gaster_4.mp3" type="audio/mp3">
</audio>
<audio id="5" >
<source src="voice/voice_smile/voice_gaster_5.mp3" type="audio/mp3">
</audio>
<audio id="6" >
<source src="voice/voice_smile/voice_gaster_6.mp3" type="audio/mp3">
</audio>
<audio id="7" >
<source src="voice/voice_smile/voice_gaster_7.mp3" type="audio/mp3">
</audio>
<audio id="redacted" loop>
<source src="music/mus_redacted.mp3" type="audio/mp3">
</audio>
<script>
var ex = document.getElementById("player")
ex.volume = 0.5;
ex.playbackRate = 1;
</script>
<button onclick=room(this)>continue?</button>
<style>
body {
background-image: url('room/room_mysteryman.png');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 0% 0%;
}
</style>
</html>
Javascript: I'm trying to move frisk 100px from the top and left.
text = 0
t = -3
next = true
wtext = "ENTRY NUMBER<br>SEVENTEEN"
add = 0
count = 0
friskX = screen.availWidth/2
friskY = screen.availHeight-100
document.getElementById("frisk").style.position = "absolute"
document.getElementById("frisk").style.left = 100 +"px"
document.getElementById("frisk").style.top = 100 + "px"
function room(x) {
x.style.display = 'none';
var redacted = document.getElementById("redacted")
redacted.play()
document.body.style.backgroundSize = "100% 100%"
document.onkeydown = checkKey
document.title = "ERROR [Ln 666, Col 66] object 'mysteryman.png' not found"
}
function checkKey(button) {
if (button.key == "ArrowLeft") {
friskX += -1
document.getElementById("frisk").src="sprite/frisk/frisk_left.png"
} else if (button.key == "ArrowRight") {
friskX += 1
document.getElementById("frisk").src = "sprite/frisk/frisk_right.png"
}
if (button.key == "ArrowUp") {
friskY += -1
document.getElementById("frisk").src = "sprite/frisk/frisk_up.png"
} else if (button.key == "ArrowDown") {
friskY += 1
document.getElementById("frisk").src = "sprite/frisk/frisk_down.png"
}
document.getElementById("frisk").style.left = friskX + "px"
document.getElementById("frisk").style.top = friskY + "px"
}
function ask() {
ticking = setInterval(ticked, 100)
document.title = "VOID"
ex.play()
}
function ticked() {
t += 1
var x = document.getElementById("myDIV");
if (t === 0) {
text += 1
if (text === 1) {
wtext = "ENTRY NUMBER<br>SEVENTEEN";
} else if (text === 2) {
wtext = "DARK<br>DARKER<br>YET DARKER";
} else if (text === 3) {
wtext = "THE DARKNESS<br>KEEPS GROWING";
} else if (text === 4) {
wtext = "THE SHADOWS<br>CUTTING DEEPER";
} else if (text === 5) {
wtext = "PHOTON<br>READINGS<br>NEGATIVE";
} else if (text === 6) {
wtext = "THIS NEXT<br>EXPERIMENT";
} else if (text === 7) {
wtext = "SEEMS";
} else if (text === 8) {
wtext = "VERY";
} else if (text === 9) {
wtext = "VERY";
} else if (text === 10) {
wtext = "INSTRESTING";
} else if (text === 11) {
wtext = "...";
} else if (text === 12) {
wtext = "WHAT DO YOU<br>TWO THINK";
} else if (text > 12) {
window.close()
}
}
if (wtext[t+add] === undefined) {
count += 1
if (count === 7) {
x.innerHTML = ""
add = 0
t = -1
count = 0
}
} else if (wtext[(t)+add] === "<") {
x.innerHTML = x.innerHTML+"<br>"
add += 3
} else {
x.innerHTML = x.innerHTML+wtext[(t)+add]
if (wtext[t+add] != " ") {
var smile = document.getElementById(Math.floor(Math.random() * 7) + 1)
smile.volume = 2;
smile.play()
}
}
}
CSS: Just in case something is being overridden.
@font-face { font-family: WD; src: url('font/pixelated-wingdings.otf'); }
@font-face { font-family: WD; font-weight: bold; src: url('font/pixelated-wingdings.otf');}
body {
background-color: black;
}
.invert{
filter: invert(100%);
/*text-align: center;*/
font-size: 500%;
}
#center {
text-align: center;
}
#help_me{
width: 1;
height: 1;
}
#frisk {
transform:scale(0.75);
}
Please tell me if I'm doing something wrong. Sorry for my bad code.
Resolved: I had to set the postition style in the CSS.