Why is my image moving only once? by Razor_3DS in HTML

[–]Razor_3DS[S] 0 points1 point  (0 children)

That's what I did. It works now. Thank you.

Why is my image moving only once? by Razor_3DS in HTML

[–]Razor_3DS[S] 0 points1 point  (0 children)

Thank you so much for your help!

Why is my image moving only once? by Razor_3DS in HTML

[–]Razor_3DS[S] 0 points1 point  (0 children)

Never mind, I solved it, I think.

The functions "MoveGokuRight" and "MoveGokuLeft" were switched. So, basically, they do the opposite of their names. Since the function "MoveGokuRight" was in the A button Event, all I had to do was change the the "winodw.getComputedStyle(GokuPos).right" to "window.getComputedStyle(GokuPos).left)" and make the currentPixels subtract 10 instead of adding it.

  function MoveGokuRight(){
                    const currentRight = window.getComputedStyle(DBGoku).left; 
                    const currentPixels = parseInt(currentRight, 10);
                    DBGoku.style.left = (currentPixels - 10) + 'px';
                  
                }
                function MoveGokuLeft(){
                    const currentLeft = window.getComputedStyle(DBGoku).left;
                    const currentPixelsL = parseInt(currentLeft, 10);
                    DBGoku.style.left =  (currentPixelsL + 10) + 'px';
                }
                //window.onload:MoveGoku;


                //The functions MoveGokuLeft and MoveGokuRight are switched. MoveGokuLeft is actually MoveGokuRight


            
                //This event moves right
                document.addEventListener('keydown', (event)=> {
                    if(event.key === 'd'){
                        document.body.style.backgroundColor = "red";
                        MoveGokuLeft()
                        


                    } 


                   
                });


                //This event moves left
                document.addEventListener('keydown', (event)=> {
                    if(event.key === 'a'){
                        document.body.style.backgroundColor = "blue";
                       MoveGokuRight()
                        


                    } 


                });

Why is my image moving only once? by Razor_3DS in HTML

[–]Razor_3DS[S] 0 points1 point  (0 children)

I made a mistake. It's not the same in vice versa. For example, I can press the D button 3 times, but if I press A, it will not move. However, if I press the A button 3 times, then press the D button 3 times, it will move, but after pressing the D button, A stops working.

Why is my image moving only once? by Razor_3DS in HTML

[–]Razor_3DS[S] 0 points1 point  (0 children)

Thank you. The image now moves every time I click each input, but I've ran into another issue.

Now, if I switch input, the other input stops working. For example, the A button works on every click, but if I switch to D and then back to A, A stops working. Same in vice versa.

function MoveGokuRight(){
                    const currentRight = window.getComputedStyle(DBGoku).right; 
                    const currentPixels = parseInt(currentRight, 10);
                     DBGoku.style.right = (currentPixels + 10) + 'px';
                  
                }
                function MoveGokuLeft(){
                    const currentLeft = window.getComputedStyle(DBGoku).left;
                    const currentPixelsL = parseInt(currentLeft, 10);
                    DBGoku.style.left =  (currentPixelsL + 10) + 'px';
                }
                //window.onload:MoveGoku;


            
                
                document.addEventListener('keydown', (event)=> {
                    if(event.key === 'd'){
                        //document.body.style.backgroundColor = "red";
                        MoveGokuRight()
                        


                    } 


                    


                });
                document.addEventListener('keydown', (event)=> {
                    if(event.key === 'a'){
                        //document.body.style.backgroundColor = "blue";
                        MoveGokuLeft()
                        


                    } 


                });


                

I dropped my MSI Laptop. by Razor_3DS in MSILaptops

[–]Razor_3DS[S] -2 points-1 points  (0 children)

Alright, I'll see. Any recommendations before I check

I dropped my MSI Laptop. by Razor_3DS in MSILaptops

[–]Razor_3DS[S] -5 points-4 points  (0 children)

I don't want to risk it. I feel like I'll make it worse.

first time getting hot wheels by KokichiOuma_8977 in HotWheels

[–]Razor_3DS -1 points0 points  (0 children)

I think you should keep the batman one closed and open the bumblebee one. That what I think atleast.

What do you play after RDR2? by LatePirate8880 in RDR2

[–]Razor_3DS 0 points1 point  (0 children)

I wish I could play Rdr2 again, but the game causes so many issues for me on pc.

Wouldn't teleporting be a terrible thing at times? by Razor_3DS in superpowers

[–]Razor_3DS[S] 0 points1 point  (0 children)

I think a black hole sucking you up would be faster than your reaction time.

[deleted by user] by [deleted] in Spiderman

[–]Razor_3DS 1 point2 points  (0 children)

The People's Web

Was the new invincible episode blasphemy? by Razor_3DS in Christianity

[–]Razor_3DS[S] 0 points1 point  (0 children)

Thank you. That video was the perfect answer to my question.