azurazen

Members
  • Content Count

    2
  • Joined

  • Last visited

  1. Im trying to use socket.io with a game im working on and cant seem to get mongodb to play nice with it. This is most likely due to my never having used mongo before, though socket.io seems pretty straight forward... Currently im having issues with separating the two to make a more manageable codebase to work with, but seem to keep getting hung up on waiting for mongodb to retrieve the documents.. Is there anyway to retrieve info from mongodb without having to do the following var mongo = require('mongodb'); var url = "url";//url mongo.connect(url,function(err,db){ if (err) throw err; dbAladdin = db.db("Aladdin"); console.log("Database Opened!"); armsman = dbAladdin.collection("skills").findOne({}, function(err, result) { if (err) throw err; // Can only access result here }); // Cannot get result here? }); // Or Here
  2. azurazen

    bitmap HELP?!

    var roomHeight = 1600; var roomWidth = 2400; var game = new Phaser.Game(roomWidth, roomHeight, Phaser.AUTO, '', { preload: preload, create: create, update: update }); function preload() { game.load.image('card','assets/demo_card.png'); game.load.image('cardBack','assets/demo_card_back.png'); } var bmd; function create() { selectedCard = false; cardHeight = 130; cardWidth = 80; cardSpc = 20; cursors = game.input.keyboard.createCursorKeys(); cardSprite = game.make.sprite(0, 0, 'card'); // World Setup game.world.setBounds(0, 0, 6000, 6000); game.camera.x = game.world.centerX - (roomWidth/2); game.camera.y = game.world.centerY - (roomHeight/2); game.stage.backgroundColor = 0x595959; game.physics.startSystem(Phaser.Physics.ARCADE); // Object creation cards = game.add.physicsGroup(); createDeck(game.world.centerX + cardSpc,game.world.centerY - cardHeight * 2, cardWidth, cardHeight); grave = createGraveyard(game.world.centerX - cardWidth * 2, game.world.centerY - cardHeight*2,cardWidth,cardHeight); // Rect Highlights, graphics setup (need to change name) graphics = game.add.graphics(100, 100); graphics.lineStyle(4, 0xFF0000, 1); graphics.drawRect(cardWidth/2-cardWidth, cardHeight/2-cardHeight, cardWidth, cardHeight); graphics.x-=1000; // BitmapData for drawing card selection to bmd = game.make.bitmapData(800,600); game.add.image(0,0,bmd); } function update() { if (cursors.up.isDown) { game.camera.y -= 10; } else if (cursors.down.isDown) { game.camera.y += 10; } if (cursors.left.isDown) { game.camera.x -= 10; } else if (cursors.right.isDown) { game.camera.x += 10; } game.physics.arcade.collide(grave, cards, discardCard, null, this); graphics.x = -500; graphics.y = -500; cards.forEach(function(item){ if(item.input.pointerOver()){ //graphics.drawRect(cardWidth/2+item.x, cardHeight/2+item.y, cardWidth, cardHeight); graphics.x = item.x; graphics.y = item.y; graphics.angle = item.angle; bmd.draw(item, game.world.centerX, game.world.centerY); } }); } Ive been messing with this for awhile and cannot figure out why it errors with an Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D', this occurs on the bmd.draw(item, game.world.centerX, game.world.centerY); line.. Any suggestions on where I messed up?