Jump to content

FalseProphet

Members
  • Posts

    49
  • Joined

  • Last visited

    Never

Everything posted by FalseProphet

  1. Still seeking an answer for this. Any javascript gurus happen to have experience with this kind of thing?
  2. I'm not sure what you mean by structure. I'm trying to send keypresses to a canvas element. My html document looks like this: <!DOCTYPE HTML> <HTML> <HEAD> <script type="text/javascript" src="scripts/glib.js"></script> <script type="text/javascript" src="scripts/glib_common.js"></script> </HEAD> <BODY> <!--onload="init()" onkeydown="evtKeyboard.KeyDown(event)" onkeyup="evtKeyboard.KeyUp(event)" onclick="evtMouse.GetMouseState(event)"> --> <canvas id="scene" style="border:1px solid #ff0000; width:500px; height:500px;"> Your browser does not support a Canvas element! </canvas> <div id="debug" style="position: relative; width:500px;height:200px; border:1px solid #0010ff"></div> <script>init();</script> </BODY> </HTML>
  3. wat..? I currently have: <div id="scene_input" onkeydown='evtKeyboard.KeyDown(event)' onkeyup="evtKeyboard.KeyUp(event)" onclick='evtMouse.GetMouseState(event)' style="width:100px; height:100px; border:1px solid #ff0000"></div> None of the onkey events work. However, onclick does... In body, onkey events work just fine. However placing them inside of body is not a possibility for my current project. I don't get what you mean by your post.. Using addEventListener() inside of a javascript script works for exactly what I described in my first post. However it it seems to pause setTimeout and setInterval for some reason.
  4. As the title states, I want to detect when a keypress occurs but I don't want to use something like <body onkeydown="dothis(event)"></body> Is it possible? If so, how?
  5. Hi, I am pretty new to Javascript and would like to play with the Canvas and I have a couple questions. First off, how do I record frame rate or operations per second properly? In my current code I only get around 170 FPS with nothing on the canvas and the canvas being default size: // GetElapsedMilliseconds = Function() { var time = new Date(); return time.getMilliseconds(); } if (GetElapsedMilliseconds() - oldTime >=1000) { OPS = count; count = 0; oldTime = GetElapsedMilliseconds(); } ++count; loop = setTimeout('Main()', 1); Another thing, am I doing Javascript's OOP implementation correctly? myscene = new _Context("thecanvas"); function _Context(id) { /* description: Retrieve the canvas context by id, if it can't throw an error and reason. */ if (document.getElementById(id)) { this.canvas = document.getElementById(id).getContext("2d"); } else { alert("Error\nUnable to find element ID: " + id); return null; } this.DrawText = function(x, y, string, size, font, color) { // draw some text inside of the canvas /* description: Draw text to the canvas. */ this.canvas.font = size + "px " + font; this.canvas.fillStyle = color; this.canvas.fillText(string, x, y); } }
  6. I want to query my home server but my webserver does not allow PHP sockets. So, I am wondering if there are any Javascript libraries out there that would do the trick. I don't want to set up a server using javascript, I just simply want to use it as a client.
  7. Okay well then just change the CSS for that particular div, because it happens in all browsers it shouldn't require any extra style sheet changes.
  8. I have a socket that queries my custom server app which sends a structure of 4 bytes back to the php script to receive. When the script receives it, it comes out as gibberish, like "¶ɅȒȂ██□♥♦▼○╫╬╬╪". Normally this isn't a problem as I would just peek at received buffer, but to my knowledge php does not have a memory read function of any sort? So how can I read the received information?
  9. Either way it's not a lot of code. Take a look at cookies(for login/register users) and fwrite/file_put_contents and/or uploading files. You should probably strip out any illegal characters / code in the new page before publishing it on the net. I don't know if drupal / joomla does this as I've never used any third party scripts for my stuff. But you should really look into the above, it's not hard at all! You'll find it fun too.
  10. That's an issue with the CSS. Check if it happens in Internet Explorer and/or FireFox and Chrome. If it only does this on firefox and chrome then you can use a conditional if and edit the CSS.
  11. The language you use does not really matter. It's the platform you intend to develop for that does. For example, it's perfectly fine to develop a computer game in Visual Basic using one of the graphic libraries(Ogre, Irrlitch, DirectX), but the problem is your game will only run on a Windows system that has the dependencies. So it won't run on a Mac or iPhone. Most commercial games you see on the PC/Windows are developed in C/C++. C/C++ languages have a LOT of libraries built for them, which help and speed up the game development process. In reality, it's a good idea to know more than one language.
  12. I have been reading the Programming in Lua online book, but it doesn't really seem to give any idea on how to do this other than with Tables. Here is my current code. I don't know what I am doing wrong, can anyone help me with this? location = { -- X, Y, Z locations x, y, z } someArray = {5} for i=0, 5 do someArray[i] = location end someArray[0].x = 1 someArray[4].x = 5 someArray[0].y = 10 someArray[0].z = 2 function assignLocation(x, y, z) print("Location of X: "..x) -- should be 1..? print("Location of Y: "..y) print("Location of Z: "..z) end assignLocation(someArray[0].x, someArray[0].y, someArray[0].z)
  13. You should learn VB6 just enough to convert it to another language. VB6 is old, buggy, bloaty and deprecated. C# is a good option for converting it to, as C# makes it easy to design forms and work with them.
  14. I'm not really sure of the terminology here. I am extremely new to OOP. I think the code will speak for itself here. How can I get public $socket contents over to an extended class method? <?PHP class objSocket { public $socket; function Server($host, $port) { //echo "created a socket: $host:$port<br>"; $socket = fsockopen("udp://" . $host, $port); return $socket; } } class objTemp extends objSocket { function sendMsg($string) { //echo "sending: $string"; fwrite($socket, $string); } } $tClient = new objTemp; $tClient->Server("127.0.0.1", 23000); $tClient->sendMsg("Hello World"); ?>
  15. Here is an example: http://templatetester.webs.com/index.htm The only issue I have with this code is whenever the browser isn't wide enough the images are placed on their own lines. I want to keep them on the same line regardless of browser width. My div container has a width of 100% as to keep the image stretched properly. This is just one big ugly hack haha!
  16. I seem to have fixed my original problem by making each image position relative and giving the div a width. How can I make the code prettier? I don't like having each image next to one another, I would like to have each image on their own line within the source for aesthetic reasons(habit of programming) without the image showing gabs between each image. Also, how can I keep the images from being broken up and placed below one another when the browser width is very small, can I just make it overflow while keeping the images on the same line? <div id="selector" style="position:absolute;top:10px;left:25px;width:100%;"> <img src="images/left.png" alt="test" style="position:relative;"/><img src="images/bar.png" style="position:relative;width:90%;height:63px;" alt="Test"/><img src="images/right.png" alt="test" style="position:relative;"/> </div>
  17. I already said it was just used to keep the image aligned. It's old code that is no longer being used... sheesh.
  18. The image I use has a circular gradient, which is why I didn't use a horizontal repeat. I'm using <pre> because for some reason, right.png was placed on a new line.
  19. I set up a freewebs just to display it. In the page, the edges of the images are colored to display where one position ends and the other begins. I am trying to make an image (bar.png) scale width with the browsers width and I am trying to keep an image (right.png) position relative to the scaled images width. The problem I seem to be having is the right.png image will move far on width screen monitors, making it appear that there is a gap between bar.png and right.png. http://templatetester.webs.com/index.htm
  20. Can anyone help me out with this? If a client browses with an extremely wide monitor, there is a gap between bar.png and right.png. How can I keep right relative to the width of bar.png? Here is my style thus far. <div id="selector" style="position:absolute;top:10;left:10;"> <pre><img src="images/left.png" alt="test"/><img src="images/bar.png" alt="Test" style="position:fixed;width:90%;height:63px;"/><img src="images/right.png" alt="test" style="position:fixed;left:92%;"/></pre> </div>
  21. Hello everyone! Are there any Javascript network functions for sending and receiving data through UDP? If so, where can I find information on them?
  22. Still searching for a solution. I can't seem to find any information about whether or not my routine is safe or if their is an alternative to include(). Bump
  23. Still searching for a solution. I can't seem to find any information about whether or not my routine is safe or if their is an alternative to include().
  24. The thing is, I won't know all of the pages. I wrote some functions to create a dynamic page and include it into a content div. I took cssfreakies' advise and included basename() into my routine. Is this safe to use and would there be any possible repercussion to using include? Basically, I want to include into a content div a page that uses PHP, HTML and CSS as if the user navigated to a whole knew page without actually leaving index.php. Are there any alternatives to Include() that can do this? BTW, here is the new routine I am using: <?PHP $pageID = $_GET['id']; function ParsePages($pageID) { $charIllegal = array(); $charIllegal[0] = "/\.\.\//"; $charIllegal[1] = "/\//"; $charIllegal[2] = "/\%/"; if ($pageID != "") { $pageID = preg_replace($charIllegal,"",$pageID); $fileExt = substr(strrchr($pageID, '.'), 1); if ($fileExt == "php") { if (file_exists("system/scripts/" . basename($pageID)) == TRUE) { include("system/scripts/" . basename($pageID)); } else { include("pages/home.txt"); } } else { if (file_exists("pages/" . basename($pageID)) == TRUE) { include("pages/" . basename($pageID)); } else { include("pages/home.txt"); } } } else { include("pages/home.txt"); } } ?> How secure is this? What possible attacks could occur on this?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.