Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. Did you test this on a server or just in your local filesystem? I've found IE8 and under having trouble with bootstrap if you try it on the local filesystem.
  2. Yes, that would be correct. Since there are no real rules a regular expression isn't needed, you're just trying to match a literal string here.
  3. The closest thing that comes to mind is a digital copy of a book.
  4. Are you sure you don't mean %20? That's the escape code for the space character in URLs. There's no need for a regular expression here. Use str_replace $new_url = str_replace('%20', ' ', $new_url); This would cause the program to replace any sequence of any length that contains 2, 0, and % with a space. It would match things like "2%02" and "%%%"
  5. I believe your invalid HTML is causing jQuery to not be loaded. Correct the validation errors and it should work. If you're using Firefox you can see invalid code marked in red by pressing Control+U.
  6. Videogames have what's called a "game loop" that runs periodically. For the game loop we can have a function that's being called by setInterval() or setTimeout() (or the more recent requestAnimationFrame()) There are many different "layers" in a videogame. For your example we just need two: The data and the graphics. On each game loop you first update the data, then the graphics layer goes through all the objects in the data layer and renders them. Because graphics are more intensive on the processor, sometimes the graphics layer is updated less frequently than the data layer is. For your example you'll have an object we can call "rectangle" with an X position, a Y position, an X velocity and a Y velocity. var rectangle = { x : 0, y : 0, vx : 0, vy : 0}; Since this game controller library is event driven, you're going to need a buffer for which buttons have been pressed and released. There are so many different possible ways to represent that with a data structure. To make it simple for you, just a plain object will work: var inputBuffer = { up : false, down : false, left : false, right : false, action : false}; When the virtual controller fires an event you set the values of this object to true or false based on whether the button was pressed or released. For the directions, remember that when up is true down has to be false and vice versa, same for left and right. On each game loop you will read the values in the input buffer and update the velocities and positions of the rectangle object based on their values. After that, you have a part of the game loop that reads the values in the rectangle object and draws the rectangle in a particular position. Game development is not easy. If you don't yet have the skills to do it on your own then you should do a lot more research or advance your career with additional formal education, because this is hardly even the tip of the iceberg.
  7. Having code on separate lines is more legible. It's a good practice to terminate all your lines with a semi-colon so that when you write a new line after it you don't forget it. If you want to get technical, Javascript will run just fine with no semi-colon on any of the lines.
  8. They're using Javascript to validate the form. Sometimes purely with Javascript, other times they'll use AJAX to ask for database information from PHP
  9. HTML 5 does not automatically do anything for you; as the developer everything is in your hands. You use CSS to style and position things.
  10. It can be done, but users are really going to hate it. It's just a bad idea altogether. There are better design choices which we could suggest if you explain why you want to resize the window.
  11. Please only make one thread for your questions. Here's the other thread you made: http://w3schools.invisionzone.com/index.php?showtopic=52114&view=getnewpost
  12. You can look up the concept of a lightbox. You have two images, a thumbnail which will load quickly, and a full image which is displayed in front of the page when the user clicks on the thumbnail.
  13. You make a hyperlink to another page where the full article is. In the hyperlink you put "Read more" as the text to display.
  14. If the query fails to be prepared $stmt is a boolean, not an object, so it can't have a property $stmt->error. That's why you look for $connection->error instead. Yes, I was referring to the ternary operator. I call it the conditional operator because that's actually what it does, if another ternary operator is invented the word "ternary" would be ambiguous.
  15. Sicne you're using an event attribute (not a good idea) you have to put return false inside the attribute itself. <form id="choice" onsubmit="decision(); return false">
  16. In the else statement, since $stmt does not exist you look for $connection->error. What you wrote for the statement should work. I don't like the use of the conditional operator for that kind of situation, it's better to use an if() to make the code more readable.
  17. Learn about form handling and sending mail with PHP.
  18. No, saveLatLng is probably an array with two values in it: one for latitude and one for longitude. In which case, you don't need to manipulate it. Open your browser's developer tools, then use console.log(saveLatLng) to see what it really is.
  19. First you prepare the statement, if that did not work then you catch the error in the else statement. After each execute() you can check the value of $stmt->errorno, if the value is 0 then don't do anything, if it's not zero, you can print the value of $stmt->error or store it into an error log file or whatever you usually do when you encounter an error.
  20. Have you tried passing your own game's canvas to the controller? Perhaps this library has a method that allows you to tell it when to render the objects so that they won't be under other objects you draw. If you can't do that, then consider using the controller's canvas for all your inputs. Keep a reference to it and draw on it. I'm not sure it will work because they might be erasing everything before redrawing.
  21. My guess is that they redirect any URL that doesn't link to an existing file or folder to the same PHP file (probably named index.php) In that PHP file they read the value of $_SERVER['REQUEST_URI'], break it into the pieces they need (with explode(), for example) and use the information to determine which files and database records to show. (using include or require to load files, and those files load data from the database) That's assuming they're using PHP. If it's not PHP then they'd have other ways to determine what's in the URL.
  22. To fix the first problem make your setKey() function global so that it's accessible from anywhere. Take it outside of the function wrapper. I haven't read all the documentation for this person's controller library. It might be a good exercise for you to read it and see what it says. It probably explains how it works. If creating a new canvas element solves the problem then that's probably what you should do.
  23. Which line does the error appear on? Are you certain that saveLatLng is a string and not something else?
  24. If you're using json_encode then don't use commas or asterisks. Just give the array as it is. PHP converts the array into a format that Javascript can read.
×
×
  • Create New...