Kayl Posted December 13, 2011 Share Posted December 13, 2011 The title pretty much sums it up. I need to learn how to add 2d images to my game. It is a role playing game so I need to be able to add inventory, health etc displayed on the screen. Are there any tutorials on the subject? p.s. preferably in the lua scripting language. Quote Link to comment Share on other sites More sharing options...
Andr3wHur5t Posted December 13, 2011 Share Posted December 13, 2011 to add a 2D image to your game you just need to load a texture then draw it //load image texture = LoadTexture("abstract::texture.dds"); //call after each frame renderd { //set blend SetBlend(BLEND_ALPHA); //draw image at position 0,0 that has a width and height of 100 DrawImage(texture,0,0,100,100); //set blend SetBlend(BLEND_NONE); } Quote Tools: AC3D | 3D Canvas(pro) | Texture Maker(pro) | Genetica(basic) | 3D World Studio | Fragmotion |Leadwerks 2 | XNA 4 | Visual Studio 2010 Professional | XCode 5.x |UU3D Pro Programing & Scripting Languages: C |C++ | C# | Obj-C | LUA | Javascript | PHP | Ruby Link to comment Share on other sites More sharing options...
dennis Posted January 15, 2012 Share Posted January 15, 2012 to add a 2D image to your game you just need to load a texture then draw it //load image texture = LoadTexture("abstract::texture.dds"); //call after each frame renderd { //set blend SetBlend(BLEND_ALPHA); //draw image at position 0,0 that has a width and height of 100 DrawImage(texture,0,0,100,100); //set blend SetBlend(BLEND_NONE); } Then how would you set dynamic keys such as a health bar and damage? where to find those thing? Quote Link to comment Share on other sites More sharing options...
Pixel Perfect Posted January 15, 2012 Share Posted January 15, 2012 Then how would you set dynamic keys such as a health bar and damage? where to find those thing? Well, you could draw a series of images representing the different positions in a health bar and display the corresponding one each time using the same code giving it the appearance for being dynamic or actually fill the pixels directly. Leadwerks has a command for doing this Plot(int x, int y) but it's pretty slow, using OpenGL directly might be better for this. Or, use a third party GUI interface. Patte has released such a library recently but there are other examples of integrations about too. Just a few ideas! Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Josh Posted January 15, 2012 Share Posted January 15, 2012 First you need to define exactly what you want. Make a mockup in photoshop or something. Then it's easy to figure out. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
dennis Posted January 15, 2012 Share Posted January 15, 2012 First you need to define exactly what you want. Make a mockup in photoshop or something. Then it's easy to figure out. I want the life to appear in decimal count or in progress bar like. but the problem is, I don't know how to set hurt values or hurt zones Quote Link to comment Share on other sites More sharing options...
Josh Posted January 15, 2012 Share Posted January 15, 2012 First you need a character class with a "health" value, which by default would probably be 100. Then you need to decide what actions and events would cause the health value to decline. From there, it's easy to draw a rectangle with a width proportional to the health value. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
dennis Posted January 15, 2012 Share Posted January 15, 2012 such as: health = 100 dead = 0 ? then how could I set the hurt values such as fall height, drowning getting hit by physics (as in bullets, oild drums and boxes with a mass of 100 or something) Quote Link to comment Share on other sites More sharing options...
flachdrache Posted January 15, 2012 Share Posted January 15, 2012 You most likely need the prePlaning done first - the whole technical side grows from the game bounds you have to define first. Found this one years ago - its somewhat indie standard imho e.g. most people road at least parts of it. http://www.ics.uci.edu/~frost/GameDesign/ClawDesignDoc.pdf The more you know about how your game will "work", the easier youll find to "write down" the technical solutions to the design proplems. Healthbars and digi fonts displaying your ammo etc. became somewhat "oldschool" - its more common to "remove" the standard h.u.d. and to use indicators instead or to show the h.u.d. only in a fight situation (only if its actually needed). funFact : i use a heart and a brain decal "onscreen" texture which goes from red to black / blue to black ... if it gets grey the player knows he/she needs to do some healing. Quote AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3 zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5 Xxploration FPS in progress ... Link to comment Share on other sites More sharing options...
Josh Posted January 15, 2012 Share Posted January 15, 2012 such as: health = 100 dead = 0 ? then how could I set the hurt values such as fall height, drowning getting hit by physics (as in bullets, oild drums and boxes with a mass of 100 or something) In the collision function, if the collision speed exceeds a limit, make the collision cause damage to the player. Then it will work for every impact. If the player goes below the water height in the scene, record the time he went under. Once the time past that exceeds something like 30 seconds, start subtracting health each frame. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted January 16, 2012 Share Posted January 16, 2012 The DrawImage() command takes 5 inputs: - image path - xPos - YPos - XDims - YDims Now this is how you draw a healthbar that dynamically scales with health DrawImage("abstract:HP_Bar.dds", xPos, YPos, XDims*(HP/maxHP), YDims); ^^ so thats the code for a dynamically changing Health bar. Your player class will have to have the variables for HP and maxHP. Now for taking damage.. It really depends what type of game you are doing because there are a number of options. However, basically the concept is the same. Losing health is just a reaction to an event and as said in the above post that even could be colliding with another body at a velocity (eg. 5m/s to 10m/s does x damage.... or you could make it a function of the velocity eg) if(velocity>2) HP -= 2*velocity^2; (You would have to convert velocity to a scalar instead of a vector for this to work) Something like that. 1. So figure out what your event trigger is for causing damage. 2. Find a way to determine it that event has occurred, 3. Come up with a function or method for determining damage from that event and then, 4. Subtract the damage from the HP Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.