Dauid

Members
  • Content count

    22
  • Joined

  • Last visited

Community Reputation

110 Neutral

About Dauid

  • Rank
    Member
  1. Hello, I am making a game in HTML5 & Javascript and I'm having some issues in loading up external scripts. The way the game is built is the data of all the game levels is stored in seperate javascript files where a level object is created and level information is specified. So inside my game engine I want to load 'on the fly' one level file and use that data to start a level. I have tried using jQuery's getScript() but I only get a "Access to restricted URI denied"- exception. I have tried having an empty script tag then changing the src-attribute to the specified path, because I read somewhere that it will load automatically if the src-attribute is changed. One solution is to just load every level file in the HEAD-tag but there will be alot of levels and I like to compress my code as much as possible and also would very much like to learn how to do this. Grateful for replies David
  2. Greetings good people, I am in need of a few pointers regarding the code design of my current game project. I decided to try out javascript for the first time now that the wonderful canvas tag has been introduced. My problem is as follows: I'm creating type of 2D up- and sidescrolling spaceship game and the graphics of each level is a large image (PNG-format, varying dimensions but larger than the viewport). The images can get pretty large so I wonder if using javascript or/and [i]a[/i] canvas-tag I could split the image into smaller images and storing them in a two-dimensional array. Or if another solution is more optimal e.g just clipping the large image to fit the viewport. Even if clipping the image is a better solution, the "large image into array of small images"-solution would be prominent to the loading of my collision data. I have two seperate images with the same dimensions to each level, one with the graphics and one with color-coded collision data. At the moment my solution is a small C# program that reads the collision data image and saves it as a text-document which I in turn load with javascript as a string and read out the data. This is a bit inconvenient because I want to ease up the level-editing process. I also have a problem I can't quite understand: When I load the image to a level some of my math is using the dimensions of the image, code snippet: [code]function loadLevel(filename) { levelCollisionMap = new Image(); levelCollisionMap.src = filename+"CollisionMap.BMP"; levelCollisionMap.onLoad = collisionMapOnLoad(filename); } function collisionMapOnLoad(filename) { levelWidth = levelCollisionMap.width; levelHeight = levelCollisionMap.height; // .... doing other stuff }[/code] when the collisionMapOnLoad-function executes at browser-startup the width and height of levelCollisionMap is 0, but on a refresh it is loaded. Grateful for help David
  3. C# SDL.NET Surfaceblitting

    Solved this myself with this code: Surface imageMap = new Surface("imageMap.png"); Color[,] imageMapColors = imageMap.GetColors(new Rectangle(0,0,imageMap.Width,imageMap.Height)); Surface clipped = new Surface(width,height).Convert(imageMap,true,true); Color[,] newColors = new Color[width,height]; //Copy the portion (width,height) from imageMapColors to newColors clipped.SetPixels(new Point(), newColors); Voila
  4. I see alot of alphablitting problems while cruising online for the solution to my problem and I can't seem to find one. I have a, in my opinion pretty simple task to perform: I have a png-file that contains animationframes(with alpha per pixel). I load this png file into my system using the Surface constructor: Surface surface = new Surface("imageMap.png"); Now I want to split this surface into the number of frames in the png-file so I can display one frame at a time. Now when blitting the split surfaces to the screen the alphadata ha vanished and it shows nasty edges. But when blitting the original imageMap.png to the surface a smooth edge shows. My question is how can I in SDL.NET split a surface logically into several others and not lose the per pixel alphadata?
  5. http://support.microsoft.com/kb/214118
  6. Quote:Original post by bubu LV 6,1257422745431E-17 is the same as 6,1257422745431 * 10^(-17). And 10^(-17) = 0.00000000000000001. So basically it is zero. yes but basically zero doesnt return true on 6,1257422745431 * 10^(-17) == 0 statement. this problem has returned and this time I'm at a loss. The problem is probably in the trigonometric functions of the math library. ex. code: Console.WriteLine("{0:e}\n{0:e}\n{0:e}",x1,x2,x1+x2); Output: 1,000000e+000 -1,000000e+000 -2,22044604925031E-16 bleh
  7. I solved this by defining PI myself using the Atan2-function. And use my selfdefined PI instead of the predefined in the .NET Math-class
  8. Hi, I've encountered an error I can't explain. See for yourselves: Code::: using System; class Test{ public static void Main(){ double d = Math.Atan2(1,0); Console.WriteLine(d-Math.PI/2); Console.WriteLine(Math.Atan2(1,0)-Math.PI/2); } } Output::: 0 6,1257422745431E-17 It's some sort of precision error, though I can't explain why or how to correct it, any thougts?
  9. Winsock problem

    I see, so to solve my problem of the client getting the updated data from the server is to constrain the pace of sending the data and process it as fast as possible on the client. Ignoring any receptiondelays on the client. Thanks again and that article you posted seems really useful!
  10. Winsock problem

    Thanks alot for that answer Antheus! I almost understands how this works now ^^ I guess it doesn't matter that the server sends obsoletedata, what I don't understand is where this buffer is and how I can access it. I keep sending data using send(), how can I use recv() to only fetch the end of the buffer? And say if this buffer gets full, how can I empty it so that send can refill with fresh updated data?
  11. Winsock problem

    then how about this, the server is issuing a send to the connected socket, the client is waiting a few seconds to call recv which would block the sendcall from the server. When the client calls recv the send is no longer blocked and is sending its specified data. The thing now is that the client only calls the recv once but the server calls send until the buffer in the networksystem is filled. I want the send()-function to be blocked until the client calls recv(). I can't seem to find any documentation on this issue, but I must've missed something.
  12. Winsock problem

    Quote:Original post by Erik Rufelt so you can simply read one number from the back of the buffer, and disregard the earlier numbers. Wouldn't this be a downer to the performance of the app?.. receiving obsolete data.
  13. sup, I've been trying to get a socketserver/client app working and I got it working!, but not the way I want it to. This is my problem: On the server I'm having an increasing integer, increasing at a high rate. This integer is the data I'm sending to the client, what I want is that the client only will recieve the latest available update of the integer, even if the client is receiving at a slower pace. I'm using socket( AF_INET, SOCK_STREAM, 0 ) for configuration. code & output example, excluding all dataconversions. Server:: int i = 0; while(true){ i++; send(i); cout << i << ' '; Sleep(10); } Client:: int buf; while(true){ recv(buf); cout << buf << ' '; Sleep(100); //using higher sleep to describe my problem } Output over ~x seconds: Server: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ... Client: 0 1 2 3 What I want it to output is: Server: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ... Client: 0 5 11 14 I want the client to be as updated as the server, or at least as close as possible. I'm having a hard time understanding this networkprogramming so could anyone give some sample code? Thanks in advance
  14. In this thread we see how to invoke the WinMain-method manually. http://www.gamedev.net/community/forums/topic.asp?topic_id=375803 What I wonder is, what is major the diffrence between actually using the WinMain-method and creating a window from a simple main-method? Since it's working by passing NULL to all WinMain's parameters, aren't those parameters obsolete? Are there any functionality of concern that uses any of those parameters?
  15. Strange runtime error

    I see, but is there a way to.. say assign value to the point in the memory that worldp points to from the local scope other than using dynamic memory?.. or is that the method I should use?