• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

hdnine

Members
  • Content count

    13
  • Joined

  • Last visited

Community Reputation

136 Neutral

About hdnine

  • Rank
    Member
  1. I'm having problems seeing how to solve the particular issue of returning the tile size to the caller. I have my own namespace called "goon" where i've added different functions, for example [i]Tile[/i] below which i use to build my level. If i try: console.log(goon.Tile.size); // This returns undefined. console.log(goon.Tile.getTileSize()); // Throws the error: goon.Tile.getTileSize is not a function [source lang="jscript"]goon.Tile = function(type, col, row) { this.type = type; this.size = 30; this.top = row * this.size; this.left = col * this.size; this.bottom = row * this.size + this.size; this.right = col * this.size + this.size; this.getTileSize = function() { return this.size; }; }[/source] So i tried adding a prototype and removed the above but this till doesn't work so obviously i'm doing something wrong here. I just need to get the [i]size[/i] value from the function, is this even possible? [source lang="jscript"]goon.Tile = function(type, col, row) { this.type = type; this.size = 30; this.top = row * this.size; this.left = col * this.size; this.bottom = row * this.size + this.size; this.right = col * this.size + this.size; } goon.Tile.prototype.getTileSize = function() { return this.size; };[/source] Is the problem that i need to invoke or call the function first? Maybe you can't have a function within a function. Anyway, any help would be apprecieated.
  2. [quote name='Maxamor' timestamp='1351553139' post='4995192'] How is your rendering loop set up? Are you using setTimeout? setInterval? requestAnimationFrame? It should be possible to draw a reasonable number of things to <canvas> without poor performance. [/quote] What i use is requestAnimFrame: [source lang="jscript"] function render() { // Basically renders graphics, checks for collision and moves the player } window.requestAnimFrame = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function( callback ){ window.setTimeout(callback, 1000 / 60); }; })(); (function animloop(){ requestAnimFrame(animloop); render(); })() [/source] It might be that the lagging and jerking comes from the browser? I've noticed that Chrome seems to work best for Canvas while i personally like to develop in Firefox. Thanks also to Bad Unicorn for the input!
  3. Right now i can't say if my chosen approach will affect performance or not but it was one of those things that i realized just might do. But as you say, maybe i'm better off focusing on other things until it actually becomes a problem. One issue i have with detecting performance bottlenecks is that the canvas atm isn't optimized to such a point that it would run smoothly in all browsers. At times it lags, jerks and does other wierd stuff with only minimal animations on stage, so it's hard to tell if these are browser issues or if i have some poorly written code. Anyway, thanks!
  4. Hey everyone, As i was trying to implement my tile based level in the game i started thinking about performance. Right now the level is set up like this: [source lang="jscript"]map: [ [2,2,2,0,0,0,0,0,0,0,0,0,0,0,2,2,2,1,1,1,0,0,0,0,0,0,0,0,0,0,0,2,2,2], [2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2], [2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2], [0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0], [0,0,2,0,0,2,0,0,0,0,0,2,2,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0,2,2,0,0,0,0], [0,0,0,2,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,2,0,0,0,0], [2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2], [2,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,2,2,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,2], [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] ], [/source] The width of the screen is equal to 17 of the above 23 tiles in width. Right now, all of the above are pushed into a [i]current level array[/i] which the drawing routine later renders to screen. This basically means that all tiles that are not 0 have their own X-Y positions and as the player moves right, all of them are updated with new X positions. I was figuring if this was a bad approach since there are so many tiles to keep track of. Half of them are rendered off-screen but still... Would it be better to just render the first 17 columns and then have a routine that pushes the next column set into the [i]current level array[/i] and remove the "left most" ones as the player moves right and vice versa? Would this improve performance? The thing is that i would first have to find which column of tiles that are the next in line, pull them out, set their X-Y positions and then push them into the [i]current level array[/i] and lastly render them out. Seems equally taxing from a performance stand point so what do you guys think?
  5. Right, thanks... right now i'm not that worried about optimization, more that the collsion itself was faulty. But thanks anyway i will certainly take a look at it. ^^
  6. On other thing, and maybe this is the wrong way to go about it. The coll detect is checking in advance for any tiles that it might collide with each frame, thus, the added value "distance" to the check which has the formula: distance = Math.ceil(this.maxVel * delta); Delta is the number of pixels the player needs to move each frame in order to keep the movement smooth, at least, this is how i think it works and is another of those issues that i'm not entirely sure about. I chose this approach because without a coll detect ahead of time, the player has to collide first and then move backwards instead of checking if there is a collision next frame and make the player stop at the edge of the tile. The first option tend to gice a quick but subtle flicker effect which i'm not to fond of.
  7. To be honest, at the moment i'm really struggeling with the issue of having physics (gravity/friction/acceleration) work with collision detection. Since the project is primarely nothing more than trying to teach myself better game programming, the number of objects at the moment are few. The player, tiles and possibly some moving platforms as the next step. It's really discouraging to sit four hours everyday to try and solve one simple problem so that i can proceed on to the next steps of the development. I've tried a few approaches but never got any of them to work... probably due to faulty implemenation. I'm not sure why this is so hard for me and that's why i was hoping to get som input. Believe me when i say that i have read a lot on the subject but there are so many approaches and uses for collision detection so it's hard to find the one that will work for you. I have looked up quadtrees and will have to read more about it. Not sure if AABB is a collision detection teqhnique but i was looking at that too. Anyway, thanks!
  8. [i]The demo can be tested here (it also has a syntax highlighter)[/i] [url="http://www.wonderworks.se/gravity-and-friction/"]http://www.wonderwor...y-and-friction/[/url] Hey everyone, I've yet again started a small game project where immediately i got stuck on the same subject as before, collision detection. I know that i'm not that good at math so i went with the approach i assumed as being correct. That is testing the player object against all tile objects on screen to see if there is a collision: [b]The syntax highlighter went mad on me so i pasted the code as text instead[/b] (it can however be viewed at the link above) // If moving up for(var index in Level.currentLayout) { var obj = Level.currentLayout[index]; if(87 in Game.keys || Player.vel.y < 0 || Player.airborn) { if(((Player.right >= obj.left && Player.right <= obj.right) || (Player.left <= obj.right && Player.left >= obj.left)) && (Player.top - distance >= obj.top && Player.top - distance <= obj.bottom)) { Player.pos.y = obj.bottom + 1; Player.collision.top = true; break; } else { Player.collision.top = false; } } } // If moving left for(var index in Level.currentLayout) { var obj = Level.currentLayout[index]; if(65 in Game.keys || Player.vel.x < 0) { if((Player.left - distance <= obj.right && Player.left - distance >= obj.left) && ((Player.bottom >= obj.top && Player.bottom <= obj.bottom) || (Player.top >= obj.top && Player.top <= obj.bottom))) { Player.vel.x *= -1; Player.collision.left = true; break; } else { Player.collision.left = false; } } } // If moving down for(var index in Level.currentLayout) { var obj = Level.currentLayout[index]; if(((Player.right >= obj.left && Player.right <= obj.right) || (Player.left <= obj.right && Player.left >= obj.left)) && (Player.bottom + distance >= obj.top && Player.bottom + distance <= obj.bottom)) { Player.pos.y = obj.top - Player.height - 1; Player.collision.bottom = true; Player.airborn = false; break; } else { Player.collision.bottom = false; Player.airborn = true; } } // If moving right for(var index in Level.currentLayout) { var obj = Level.currentLayout[index]; if(68 in Game.keys || Player.vel.x > 0) { if((Player.right + distance >= obj.left && Player.right + distance <= obj.right) && ((Player.bottom >= obj.top && Player.bottom <= obj.bottom) || (Player.top >= obj.top && Player.top <= obj.bottom))) { Player.vel.x *= -1; Player.collision.right = true; break; } else { Player.collision.right = false; } } } It kinda works but i keep having this feeling that the code is just too complicated for a tile based 2D platform game, or, simply that it's badly written? Without physics it works really well but with it i get stuck on edges between tiles and on tiles. Alos, the gravity seems too slow but if i increase it, other things like the jumping starts to act up so i in turn have to increase that to compensate and all of a sudden everything gets messed up. I have some code that generates the level tiles and displays them on canvas which works nicely. The problem is somewhere with the collision detection and since my math really suck, i have been reading and reading about different approaches and i just don't understand most of them. I would really appreciate if someone could give me some input on a more correct way to handle this, preferably with example code or demo pages. Thanks a bunch! [i]Also: please add Javascript/Canvas to the Topic Prefix ^^[/i]
  9. Hey everyone! I have been working about a month on a PHP-based text adventure engine which at this point can parse two words like TAKE SUITCASE or EXAMINE SOFA. All verbs and objects are located in arrays which are fetched from a database at the start of the game. The problem i have is that i can't seem to find a good way to parse text if the input is more than two words. In PHP i use EXPLODE to seperate the words and then check each word against the different arrays that i have -- verbs, objects, prepositions, noise words and so on. These are marked with "v" if verb, "p" if preposition and so on to determine what kind of word the are right... So far i can write TAKE <object> and it will be picked up, or, EXAMINE <object> and a text explaining the object will be shown. So here is the problem which i really would like to find a more elegant solution for -- i use IF / ELSE and SWITCH / CASE conditional statements to handle the parsing and these are quickly getting larger as i try to move in to a third word. My plan is for the text parser to handle at least 5-7 words not counting the noise words like "the". Here is some example code: [code]// First word if(isset($input[0])) { $word1 = checkWord(0,$input); } // --------------- // WORD 1 - SYSTEM // --------------- if(isset($word1['type']) && $word1['type'] == 's') { // System commands can only be alone, any following words will be ignored eval($word1['word']['action']); } // ------------------ // WORD 1 - DIRECTION // ------------------ elseif(isset($word1['type']) && $word1['type'] == 'd') { // This will set the player to the destination she has chosen $array = $word1['word']['dest']; $_SESSION['player']->setPos($array); }[/code] So basically the only words that are allowed later on when parsing three or more words are the ones starting with a verb. So the code is similar to this: [code]// ------------- // WORD 1 - VERB // ------------- elseif(isset($word1['type']) && $word1['type']== 'v') { // The first word is... switch($word1['word']['name']) { // BACK case 'back': // If the verb is "back" then go to the last position the player was at eval($word1['word']['action']); break; // back // GO case 'exit': case 'enter': case 'crawl': case 'go': case 'move': case 'run': case 'walk': // -------------------- // WORD 2 - PREPOSITION // -------------------- if(isset($word2['type']) && $word2['type'] == 'p') { // The second word is... switch($word2['word']['name']) { case 'above': case 'over': break; case 'across': break; case 'after': break; case 'around': break; case 'behind': break; case 'below': case 'beneath': case 'under': break; case 'between': break; case 'beyond': break; case 'in': case 'inside': case 'into': break; case 'near': break; case 'on': case 'onto': break; case 'out': case 'outside': break; case 'through': break; case 'to': case 'towards': break; case 'until': break; } } // ------------------ // WORD 2 - DIRECTION // ------------------ elseif(isset($word2['type']) && $word2['type'] == 'd') { // This is like saying "go north" or "go kitchen" instead if just "north" or "kitchen" $array = $word2['word']['dest']; $_SESSION['player']->setPos($array); } else { goto showError; } [/code] I realized that at this stage there are a lot of repetitions to start off with and A LOT more code just to check every possible combination like VERB+OBJECT, VERB+PREPOSITION+OBJECT, VERB+OBJECT+PREP+OBJECT and so on. Please help me... there has to be a better way to handle this than thousands of lines of code to check all possible combos? I was thinking of having some sort of relational database table which would contain all verbs and which prepositions they can be followed by, not sure if this is a better solution. Another problem is that some verbs only work with specific prepositions or objects, for example WALK ACROSS BRIDGE works fine, TAKE ACROSS BRIDGE doesn't make sense. LOOK (verb) UNDER (preposition) TABLE (noun/object) will work fine, WEAR UNDER TABLE doesn't. Hopefully you see the problem since the combinations seems to be endless. Two words are easy, three gets complicated and more than that seems impossible. Thanks, Krister Nielsen Sweden
  10. Okey, Thanks guys! If you have any example code i can look at it would be great. :) I'll try the ones you mentioned.
  11. Hey everyone, Me and three others are planing on doing a very basic text adventure game in Visual C++ and the console window. It's for a school project and i was hoping that someone could help me with a specific menu system. We are all very new to C++ and have recently learned about for example classes and the STL. I was thinking of making a menu like this one: http://www.wonderworks.se/online/menu.gif ...where the user could choose by using the arrow keys and highlighting a choice, then pressing ENTER to continue. Is this at all possible in the console window or does it have to be made in Win32? Now Win32 is something that we haven't gone thru yet in class so we really want to stick to the more simpler console window. Also: Is it possible to make the menu so that the cursor "_" doesn't show on screen after the highlighted text "START the game_" as i have seen in some cases? One more thing: Can i change the background color to, for example grey with white text? Any help would be appreciated. Thanks! Krister Nielsen Karlshamn, Sweden