Jump to content

TheCrock

Members
  • Content Count

    12
  • Joined

  • Last visited

About TheCrock

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I have this slice of code which works but is throwing an error in the console. Uncaught type error. Cannot read property of x at undefined. I am using the game loop to move a sprite on its x and y axis. The code works but i get an error and I would be interested to know why. Also when i try to introduce, let state = play; so i can change the call that requests the play(); function to state(); my code stops working. I would like to be able to change the value of state so i can change which function I call by changing the value of state variable. Does any wise member k
  2. //<script src="pixi/spriteFromTextureAtlas.js"></script> I have this in my html file. Somehow these // were added at the start. I think i tried to comment out html like javascript, silly me. now when I remove them the console throws this error. spriteFromTextureAtlas.js:15 Uncaught TypeError: Cannot read property 'appendChild' of null. When i put the // back the script loads fine. Im wondering what is causing this behaviour. Thanks in advance Keith
  3. Thank you Ivan for all of your help and interest. I don't care about writing my own engine, I just need to start producing something. I want to mainly create a 2d platform game to begin with. I already know how to do all of this in plain javascript but I want to be able to put some more professional touches to the work and using a game engine or libraries seems to be the way to get things done quickly.Like animating a walk cycle. I have a simple collision library called bump by kittycat attack.He is also the author of the pixi.js.book I am studying. It is for use with pixi. It is
  4. Ok thank you very much. So i will use pixi.js to build my sprites without 2d.arrays. . I will do it with texture atlas and json file. I already know how to do this. What about collision detection? If I have monsters pushed into an array can I use a for loop to check for collision with a player character like this maybe: for(var i = 0; i < hedgehogs.length; i++) { var hedgehog = hedgehogs; if(hedgehog.visible && hitTestCircle(cat, hedgehog) && hedgehog.state === hedgehog.NORMAL) { if(cat.vy > 0) {
  5. Hi and thank you for your reply. I don't understand what you mean here . I apologise I don't mean to sound rude. Do you mean I cannot take a beginner book and apply the tile based approach to pixi.js? Do you think I should build my game using different methods? I spent a lot of time learning how to create platforms and mazes from 2d arrays.All of the logic I learned relies on moving around the columns and rows of the 2d array. It is used for pathfinding, enemy ai, everything. Have I wasted my time? I need to move and get something made now. Is using 2d arrays an
  6. I am a real newbie. I just finished the excellent book Foundation Game Design with HTML5 and Javascript by Rex Van Der Spuy. The book has taught me a lot about making game maps from 2d arrays, collision detection, enemy AI for platform and maze games based on arrays.All of the AI is based on positions generated from 2d arrays. I can keep track of everything by the positions of sprites in rows and columns of a 2d array.This makes enemy AI easy. I have a scripts for collisions for rectangles, circles, boxes, that give me collision sides and objects can bounce from them. Also
  7. I am very confused and I hope below makes sense. The first time I ran these two functions - the first called globalScope, returned 'window'in the console and the second called localScope, returned 'undefined' in the conole. let globalScope = () => console.log(this); globalScope(); let localScope = function(){ console.log(this); }; localScope(); I played a little with the second function and created a var called scope. var scope = this; then used console.log(scope); and it returned 'window'. Nice, So i cleared all of this and tried the two
  8. Hi again b10b. I just when back to the page, opened dev tools and sure enough it is showing there for me now. Thanks for the reply.
  9. Hi everone, another newbie HTML5 and Javascript question. I was checking the source code in chrome for this walking character: http://atomicrobotdesign.com/blog_media/sprite_movement/index.html Looking at the index.html file i see it calls a script called movement.js and a script called requestAnimationFrame.js. I can only find the movement.js script in the navigator window not the requestAnimationFrame.js script. Can any wise member tell me what I am missing here?
  10. Now I understand b10b Thank you for the reply and explanation with link.Most kind. Very early in the book there was indeed a paragraph on scope which I had forgotten. I ran a search for scope through the pdf and found it. Thanks again.
  11. I am following the excellent book Foundation Game Design with HTML5 and Javascript. I have a piece of code, which works but i'm not sure why. function destroyAlien(alien) { //Change the alien's state and update the object alien.state = alien.EXPLODED; alien.update(); //Remove the alien after 1 second setTimeout(removeAlien, 1000); function removeAlien() { removeObject(alien, aliens); removeObject(alien, sprites); } As you can see it is a function which uses setTimout to call another function. It only calls removeAlien function when it is inside the main function. If
  12. Hi all, I am new to coding. I am currently working my way through Game Design with HTML5 and Javascript by Rex Van Der Spuy. I have a real newbie question. Can I mix the vanilla java script techniques I am learning with something like pixijs. What I mean is can I write my code in vanilla and then mix in pixijs for animating a sprite walk cycle or must I write the whole game in pixijs? I hope that makes sense. EDIT: Anybody here can moderate my first post?
×
×
  • Create New...