Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8988115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:56:56+00:00 2026-06-15T21:56:56+00:00

I am using .animate to try and create a tile based game. I am

  • 0

I am using .animate to try and create a tile based game. I am mixing jQuery with another ajax script to try and make this work. I keep clicking an arrow to move but get no result. Maybe someone else would understand why?

Buttons:

$data .= "<center><table><tr><td></td><td><button onclick=\"transition(\'up\')\">&uarr;</button></td> <td></td></tr><tr><td><button onclick=\"transition(\'left\')\">&larr;</button></td> <td></td> <td><button onclick=\"transition(\'right\')\">&rarr;</button></td></tr><tr><td></td> <td><button  onclick=\"transition(\'down\')\">&darr;</button></td> <td></td></tr></table></center>";

Map:

$data .= "<div style=\'width:480px;height:480px;background-color:#000000;background-image:url(".$map['background'].");padding:".$map['locationpadding'].";\' id=\'locationMap\'>";


$data .= "<div id=\'specialLocations\'></div>";


$data .= "<div style=\'position:absolute;left:".$charrel[0]."px;bottom:".$charrel[1]."px;width:32px;height:32px;background-image:url(".$char['charimage'].");\' id=\'charLocation\'></div>";


$data .= "</div>";

Finally, getting the animation. I have made sure the if statements are all working. So everything is working fine up to this point.

if($_POST['direction'] == "up"){

        print("$('#charLocation').animate({'bottom': '+=50px'}, 'slow');");

    }elseif($_POST['direction'] == "left"){

        print("$('#charLocation').animate({'left': '-=50px'}, 'slow');");

    }elseif($_POST['direction'] == "right"){

    print("$('#charLocation').animate({'left': '+=50px'}, 'slow');");

    }elseif($_POST['direction'] == "down"){

    print("$('#charLocation').animate({'bottom': '-=50px'}, 'slow');");

    }else{
        die('alert("Invalid movement.");');
    }

And the reasoning for printing the jQuery/JavaScript code through PHP is that everything is loaded via Ajax code so I am never printing.

Sorry for any confusion ahead of time and thanks for looking over this for me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:56:57+00:00Added an answer on June 15, 2026 at 9:56 pm

    I think the problem is your approach to making a game with these languages. If you want to move a character in a web based tile game you should control all game logic in the front end client side – in javascript in this case – and only use ajax to push critical game info to the server. Like, if you move a chess piece for example, you only post the new piece coordinates when the animation completes, not calling ajax and executing whatever comes back from the server.

    I don’t think an example can be provided in this case since it is an issue with the foundation of your approach.

    I could answer specific questions if you have them. To answer your current question – printing a line of javascript as an ajax request won’t automatically execute the response as javascript, nor should it. Don’t try to get it to work this way. Instead restructure your approach to not require this kind of behavior to operate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jquery animate() to pull values from svg markup, and create an animation.
I'm trying to make a sliding panel using .animate function because I want it
I have a few divs that I want to animate using jQuery. However, I
I am using jQuery to animate the background colors of 3 different divs, repeated
I am using the rather fantastic jQuery multiple select plugin, ASM select This plugin
I'm using the jQuery Background Position plugin and the jQuery Cycle plugin to try
I am using jquery script for my image rollovers and I am encountering a
I try to create a view without using xib file. Unfortunately, I have problems
I have a Javascript file that I am using to try to animate a
I am encountering a potential bug while using jQuery 1.7.1 to animate the height

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.