Jump to content

astralaaron

Members
  • Posts

    1,254
  • Joined

  • Last visited

Everything posted by astralaaron

  1. Yeah, I'm aware it is not valid. One other question, is there any other way besides the IE tester program to test in old versions of IE? Is it possible to install multiple versions?
  2. I know that you can display a message to people on older browsers which do not support <canvas> like this: <canvas>browser doesn't support canvas</canvas> I have a client who wants a <marquee> element (I know its not good to use a marquee). I threw together a canvas marquee which works well, BUT my client wants to support older browsers since many of the companies who use his site use older versions of IE. So my question is... is it valid to do something like this?: <canvas> <marquee>asdf fdsa asdf fdas</marquee></canvas> so that older browsers will fall back on the marquee element? I am asking because the IEtester program doesn't seem to support javascript very well....I am using javascript to create my canvas element and append to the document, and same with the marquee, creating, and appending to the canvas.
  3. ahh that's right, thanks for reminding me, pretty sure I know a fix, going to mess with it later.
  4. there's really no rhyme or reason to the doors. there is a correct path though, all of the other ones are just confusing
  5. which browser are you using? I haven't had that problem happen. edit: can you post a screenshot maybe?
  6. Just looking for a couple testers to see if any problems become apparent. thanks in advance click here to play p.s. I realize the game is pretty stupid edit: let me know if you find your way through it
  7. instead of document.write(d) try document.getElementById("time").innerHTML = d; make sure you have a <div id="time"></div> in your document
  8. it doesn't look like getMessage() is a method of your class. maybe try class MyPDOException extends Exception {private $err;public function __construct($msg, $code=NULL) {$this->err = $msg;if (isset($code)) {$this->err .= " Error code: " . $code;} public function getMessage() { return $this->err; }} edit: nevermind, I just now saw that you are extending the Exception class maybe this: class MyPDOException extends Exception {public function __construct($msg, $code=NULL) {parent::err = $msg;if (isset($code)) {parent::err .= " Error code: " . $code;} public function getMessage() { return parent::getMessage(); }}
  9. I believe the problem is document.write(), because it calls document.open() if the document has already finished loading, which clears the document. So the form no longer exists once you are trying to submit it. Maybe you should try using innerHTML to display your loading message, or have it already in an element which has display:none; in the style. When you submit, change it to display:block; to show the loading message.
  10. ahhhhhh! the nightmare is over.... parseInt saves the day... when I create each tile object I am using parseInt now to convert the string '03' to 3.... thanks for all your help dave and JSG
  11. the switch located in the worldCollision function
  12. so If you check it now... you will see that it is detecting a collision with the rightmost row. The problem seems to be with the switch which runs the stop function. it is hitting the default in the switch everytime. I have confirmed it is a type of string.....why in the world would it not be hitting the '03' case in the switch??? EDIT> watch the console log when you walk into the tiles
  13. well it has to search through to find out where the player is in relation to the map. each tile needs to be checked for it's x,y,w,h and compared against the player x,y,w,h
  14. here is the most recent work, it has a few console logs just confirming the tile numbers are correct and the type of the leftmost and rightmost columns. I also changed the map file / loading function to not include the number of rows and colums on the first line.
  15. I am not having any luck with the console.log() I have confirmed all of the tiles are being added to the arrays, and confirmed the rightmost tiles have the correct type. The loops seem correct in the worldCollision function. I am having a hard time with console.log() working with the collision functions because they are constantly getting called 60 times a second. the console log reaches its max really fast.
  16. Well I don't see how to check which tiles are around the player without looping through all of them. I guess you could possibly stop after the loop finds tiles the player is around, and not continue on to the rest of the map. That might be something I can think about to make it perform better in the future.
  17. I don't use the tiles to keep track of the player location. The player just has an x / y property. I am not sure how I would scan only the surrounding tiles. Will you please explain what you mean by jagged arrays? Does it mean, one row can be longer than the next? Good idea, I really need to get with the times and start using the consol to track things... I am still using alerts, which obviously is not ideal for checking every collision each frame. I am going to give this a try. But first I am going to modify the loading function and not use the first two numbers to define the width and height, as it just seems to make it more complicated than it needs to be. By the way, thanks both of you for the input
  18. I should probably get rid of the first two numbers in the map files (the amount of tiles in each row, and column) I was following the way I load the map when I write in C++. But I think I don't need that in Javascript,it's probably not helping anything, might be part of the problem.
  19. so the map files look something like this: 06 0601 02 01 02 01 0201 02 01 01 02 0101 02 01 01 02 0101 02 01 02 01 0201 02 01 01 02 0101 02 01 01 02 01 I use an ajax call to grab that text. then I use javascript split("n"); to separate each row into one array then I loop through that array and use split(" ") to get each tile number into an array. so I have a two dimensional array of numbers... Then I have a tile class that can be as basic as this: function Tile() {}Tile.prototype.init = function(box, type, id) { this.X = box.x; this.Y = box.y; this.W = box.w; this.H = box.h; this.type = type; this.id = id;}Tile.prototype.clean = function() { delete this; } so I loop through that array of numbers, and for each number I create a new Tile object which holds the x, y, width, and height. It also holds the tile type..which I use to draw the correct tile from the sprite sheet. I am just using the id to track which tile is a door, also something I didnt do yet, but I am going to give the sand (yellow tiles) an id, which when you collide with them it slows the player velocity.. then I add each tile object to a new array, so I have a two dimensional array of Tile objects. that loadMap() function looks like this: this.loadMap = function(filePath, spritePath) { engine.tileSheet.src = spritePath; var rand = Math.floor(Math.random() * 6) + 1; var url = filePath + '?r='+rand; var call_to = url; var call = new Com(call_to); var call_back = function() { var mapRows = call.response.split("n"); var map = new Array(); var row = null; for(var i=0; i < mapRows.length; i++) { row = mapRows[i].split(" "); map[i] = row; } var mapWidth = map[0][0]; var mapHeight = map[0][1]; // convert each tile to object engine.tiles = new Array(); var doorCount = 0; var tileId = 0; for(var i = 0; i <= mapHeight; i++) { var tRow = new Array(); for (var j = 0; j <= mapWidth; j++) { tileId = 0; var tile = map[i][j]; var box = { 'x': j * TILESIZE, 'y': (i-1) * TILESIZE, 'w':TILESIZE, 'h':TILESIZE }; if (tile == 6) { tileId = doorCount++; //alert('setting door id = '+ tileId); } var newTile = new Tile(); newTile.init(box, tile, tileId); tRow.push(newTile); } //alert(tRow.length); engine.tiles.push(tRow); } //alert(engine.tiles[0].length); } call.GET(call_back); } So that is basically it for loading the map...then there is a showMap() function which runs each frame before drawing the game objects: this.showMap = function() { for(var i=0; i < engine.tiles.length; i++) { for(var j=0; j<engine.tiles[0].length; j++) { if (engine.tiles[i][j].type==0) continue; var spriteOffset = { 'x': engine.tiles[i][j].W * (engine.tiles[i][j].type - 1), 'y': 0, 'w': engine.tiles[i][j].W, 'h': engine.tiles[i][j].H } if(((engine.tiles[i][j].X + 50) >= engine.getCamera().x) && ((engine.tiles[i][j].X - 50) <= (engine.getCamera().x + engine.getCamera().w)) && ((engine.tiles[i][j].Y + 50) >= engine.getCamera().y) && ((engine.tiles[i][j].Y - 50) <= (engine.getCamera().y + engine.getCamera().h))) { engine.getScreen().drawImage(engine.tileSheet, spriteOffset.x, spriteOffset.y, (spriteOffset.w -2), spriteOffset.h, engine.tiles[i][j].X - engine.getCamera().x, engine.tiles[i][j].Y - engine.getCamera().y, engine.tiles[i][j].W, engine.tiles[i][j].H); } } } } the sprite offset gets the right position of the spritesheet to draw. The if() condition is checking to see if the tile is within the camera box, if it is, it draws that tile. the world collision function looks like this, which loops through each tile and checks to see if the player is colliding with it, if so, it checks the tile ID (tiles 03 and 04 are walls, and run the stop() function, which counters the movement velocity, stopping the player object from moving) (06 tiles are doors, and change the gamestate and send you to the other level, at different positions based on the id of the tile) that function looks like this: LevelTwoState.prototype.worldCollision = function() { for(var i=0; i < this.game.tiles.length; i++) { for(var j=0; j < this.game.tiles[0].length; j++) { if (this.game.tiles[i][j].type==0) continue; if(this.game.collision(this.player.X, this.player.Y, this.player.frameWidth, this.player.frameHeight, this.game.tiles[i][j].X, this.game.tiles[i][j].Y, this.game.tiles[i][j].W, this.game.tiles[i][j].H)) { switch(this.game.tiles[i][j].type) { case '03': case '04': this.player.stop(); break; case '06': switch (this.game.tiles[i][j].id) { case 0: this.game.changeState(LEVELONE, 202); break; case 1: this.game.changeState(LEVELONE, 201); break; case 2: this.game.changeState(LEVELONE, 203); break; case 3: this.game.changeState(LEVELONE, 204); break; case 4: this.game.changeState(LEVELONE, 205); break; case 5: this.game.changeState(LEVELONE, 206); break; case 6: this.game.changeState(LEVELTWO, 207); break; case 7: this.game.changeState(LEVELONE, 208); break; case 8: this.game.changeState(LEVELONE, 209); break; case 9: this.game.changeState(LEVELONE, 210); break; default: this.game.changeState(TITLEMENU); break; } break; default:break; } } } }} Something is wrong, either in the loading, or worldCollision function, which is missing the final tile of each row (the rightmost tiles) Sorry I couldn't be more detailed with this explanation, I got home late from my son's birthday party and I am pretty tired, rushed through this because I need to get to sleep for work in the morning. I didn't get a chance to try fixing the error today either, hopefully tomorrow I will have time.
  20. The commented out collision is between game objects, I just wrote that up for in the future when I make some different games with more game objects than just the one player running around an empty map. its the worldCollision function that deals with the map tiles. I'm still at work, I can write an overview about how the map is defined later tonight.
  21. I think I know what you are asking.... to compare strings in Java, use equals() instead of if(event.getActionCommand() == "something") { } try if(event.getActionCommand().equals("something")) { }
  22. Yeah, I just can't seem to figure that out... I can't post the code right now because I am at work. I will post the code related to the tiles and world collision some time tonight, it's probably something very obvious that I am overlooking
  23. yeah it isn't meant to be centered at the moment, I was doing a test with the temporary canvas next to the gamescreen. I know what you mean by the page scrolling when you push the arrow, I just threw a big number into the div. it's not really a problem with the game though.
  24. no that is the link with the display problem. this link the most recent And I ran into another problem that is driving me insane....if you make your way over to the far right wall at the end of the map on both level 1 or level 2... you walk right through the wall. I can't for the life of me get the collision detection working with the rightmost tile. I've been messing with it for hours. Going to give it a rest and try again tomorrow after work... btw..First map is 30 tiles wide, second is 50 tiles wide.. (level two is through the black holes in the wall)
×
×
  • Create New...