'How to make text or anything move when program starts

I am currently developing a game for a class and I need my obstacles to move when the program starts so that the player doesn't have to activate the obstacles manually. I'm using jQuery 3.4.1 and I'm quite new to programming so I don't know if I can even do this I would appreciate some help on this topic I will link the fiddle I am using to create this game and give you the code for my game.

fiddle here: https://jsfiddle.net/Gamebit/96mLcfxw/20/

jQuery:

`document.addEventListener('keydown', function(moveKey) {
  if(moveKey.key === 'w') {
   $("#rightLeg").animate({top: "5px"})
    $("#leftLeg").animate({top: "5px"})
    $("#bidenHead").animate({top: "-150px"});
    $("#body").animate({top: "-150px"});
    $("#leftArm").animate({top: "-150px"});
    $("#rightArm").animate({top: "-150px"});
    $("#rightLeg").animate({top: "-150px"},200, function(){});
    $("#leftLeg").animate({top: "-150px"},200, function(){});
    }
    
   if(moveKey.key === 's'){
      $("#bidenHead").animate({top: "150px"});
    $("#body").animate({top: "150px"});
    $("#leftArm").animate({top: "150px"});
    $("#rightArm").animate({top: "150px"});
    $("#rightLeg").animate({top: "150px"});
    $("#leftLeg").animate({top: "150px"}); 
    }
  
    if(moveKey.key === 'a'){
    $("#bidenHead").animate({right: "790px"}, 500, function(){}); 
    $("#body").animate({right: "835px"}, 565, function(){});
    $("#leftArm").animate({right: "862px"}, 645, function(){});
    $("#rightArm").animate({right: "808px"}, 450, function(){});
    $("#rightLeg").animate({right: "800px"}, 625, function(){});
    $("#leftLeg").animate({right: "870px"}, 450, function(){}); 
     }

  if(moveKey.key === 'd') {
    $("#bidenHead").animate({right: "250px"}, 500, function(){});
    $("#body").animate({right: "295px"}, 565, function(){});
    $("#leftArm").animate({right: "322px"}, 645, function(){});
    $("#rightArm").animate({right: "267px"}, 450, function(){});
    $("#rightLeg").animate({right: "260px"}, 625, function(){});
    $("#leftLeg").animate({right: "330px"}, 450, function(){}); 
     }
  })

and the CSS:

img {
  position: absolute;
  border-radius: 100px;
  height: 100px;
  width: 100px;
  margin-left: 510px;
  margin-top: 200px;
}

.stickBody {
  position: absolute;
  background-color: black;
  width: 5px;
  height: 100px;
  margin-left: 556px;
  margin-top: 300px;
}

.stickArmLeft {
  position: absolute;
  transform: rotate(45deg);
  background-color: black;
  width: 5px;
  height: 80px;
  margin-left: 528px;
  margin-top: 300px;

}

.stickArmRight {
  position: absolute;
  transform: rotate(135deg);
  background-color: black;
  width: 5px;
  height: 80px;
  margin-left: 585px;
  margin-top: 300px;
}

.stickLegLeft {
  position: absolute;
  transform: rotate(45deg);
  background-color: black;
  width: 5px;
  height: 100px;
  margin-left: 522px;
  margin-top: 385px;
}

.stickLegRight {
  position: absolute;
  transform: rotate(135deg);
  background-color: black;
  width: 5px;
  height: 100px;
  margin-left: 590px;
  margin-top: 385px;
}

p1 {
  position: absolute;
  top: 100px;
}

p2 {
  position: absolute;
  top: 70px;
}

p3 {
  position: absolute;
  top: 400px;
  left: 1056px;
}

p4 {
  position: absolute;
  top: 370px;
  left: 1045px;
}

    
    `

I will give you the HTML if anybody needs it but I felt like this was getting kinda long so just request it if you need it and I will supply it.



Solution 1:[1]

After a few investigations and many examples of code that used CDLL I found a way to call srand function.

Solution:

from ctypes import CDLL
import time

libc = CDLL("libc.so.6")
libc.srand(int(time.time()))
print(libc.rand())

The libc.so.6 library must be in the same directory. I think it's a problem with relative and full path for CDLL but this configuration worked. I tried also with python2 and the error was the same. I think it's a bug with CDLL.

Solution 2:[2]

The problem is in default load library search path. It is defined in /etc/ld.so.conf. For example, on my machine:

cat /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf
cat /etc/ld.so.conf.d/*.conf
/usr/lib/x86_64-linux-gnu/libfakeroot
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [automount]
# ldconfig = false
/usr/lib/wsl/lib# libc default configuration
/usr/local/lib
# Multiarch support
/usr/local/lib/x86_64-linux-gnu
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
ls -lL /lib/x86_64-linux-gnu/libc.so.6
-rwxr-xr-x 1 root root 2029224 Dec 16  2020 /lib/x86_64-linux-gnu/libc.so.6

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mocanu Gabriel
Solution 2 Dmitry Messerman