• 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.

SelethD

Members
  • Content count

    573
  • Joined

  • Last visited

Community Reputation

456 Neutral

About SelethD

  • Rank
    Advanced Member
  1. Not sure if it will be needed by anyone, but after experimenting I did find a solution.   --first i set up some vectors local g_up = Vector3.new(0,1,0)  --global up local v_forward = target.lookVector local v_right = -g_up:Cross(v_forward) local v_up = -v_forward:Cross(v_right) local p = target.position   --get a new position, based off of moving down the vectors (also the 'loc' variable is what was returned by the function in the above post) p = (v_forward*(-loc.Z))+p p = (v_right*loc.X)+p p = (v_up*loc.Y)+p   local cam = Camera cam.position = p cam.lookAt = p+(target.lookVector * -2))    I dont know if its the best way to do this, but it works, so... unless it gives me issues, ill use this   Thanks
  2. Ok... I am quite the novice when it comes to game related math, especially in the 3D realm.  So I shall try to convey my problem as clearly as possible, since I do not know much of the terminology.   I have a Camera in 3D space, this camera can be located at any x,y,z and it can face any direction valid for a FPS view. I have a target, the target can be at any location in 3D space along the x,y,z however the target will be STATIC and non movable.   I would like to be able to have my camera position itself in front of the target so that the target will appear a certain size and location on the 2D render screen.   I found online a function, when when supplied with variables of x,y (location of target to be displayed on 2D screen) and height (the height the target should display on the 2D screen) the function will return a Vector3 stating where the target should be placed in 3D space, so that it will render at the x,y at desired height on the 2D render screen.   The problem I am having is converting that Vector3 into something that I can use to position my Camera (since my target is stable) in the correct position to get the same result.   This is what I am doing so far... the code is in Lua   -- This line is calling the function I found online, I am requesting a Vector3 position so the target will be shown on the 2D render at position screenW/2, screenH/2 (so that should be in center of screen) and I want the object to appear to be .5 the size of my screen's height so thats the second screenH/2.  The last argument is the unit size of the object (2 units high)   local pos = ScreenSpace.ScreenToWorldByHeight(screenW/2,screenH/2,screenH/2, 2)   Now the result is ... pos = (0,0,-2)   -- Meaning i need to have the target positioned -2 away from my camera on the Z axis to display as needed.   This is the same result no matter which way my camera is facing, so I know the result is based off of my camera's .. facing vector?   So I tried this to get my new camera position...   newCamPos = TargetPosition - pos   This however, causes my camera to be positioned at the targets location offset by +2 on the Z axis, when in reality, I need it to be +2 on the Z axis in relation to how the Target is facing, the targets facing vector.   So I am lost... is there an easier way to do this?  What terms should I search for?  Or if you have any tips or tricks to share that would be great.   Thanks      
  3. I am sure this is something that has been answered a million times over, but for the life of me, I cant seem to figure it out, nor can I find any helpful info.   I have a mesh (quad) and meshrenderer created in c#.  I would like to give the meshrenderer a material that already exists in my resources folder....   Assets/Resources/JmaMaterial   I load the material with...  Material mat = Resources.Load<Material>("JmaMaterial");   If I assign it to my meshrenderer like this....       Material BodyMat = new Material(mat); mMeshRenderer.material = BodyMat;   This works, no problem... however, if I want to add 2 materials to my quad (one for character body, another for chatacter hair)   It doesnt seem to work, this is how im doing it...           mMeshRenderer.materials = new Material[2];         Material mat = Resources.Load<Material>("JmaMaterial");         if (mat != null)         {             mBodyMat = new Material(mat);             mHairMat = new Material(mat);             mMeshRenderer.material[0] = mBodyMat;             mMeshRenderer.materials[1] = mHairMat;         }         else Debug.Log("failed to find material");     So... obviously im doing something wrong, I try to Google about assigning multiple materials to a mesh, but all the results either have no solution, or they explain how to do it in the editor, not in code.   Is this even the correct way to do an image with multiple parts?  (body + hair) Instead of having one quad with 2 materials, should I instead go with 2 mesh quads and each have 1 material?   Thanks for any help 
  4. Its too bad there is no apparent 'native support' for 8bit images in opengl anymore.  However, I did not know it was getting a copy of the entire palette on each call, I tried to suggestion of making one copy to an array, and using the array, and the results were 100% faster.   I cant even tell how long its taking to load, as it zips through the files.   Thanks so much.
  5. It is definately the 'looping' through the indexes that is causing the slow operation.   I have been searching and searching online for a solution, and came across something interesting...   I've seen  GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bitmap.Width, bitmap.Height, 0, PixelFormat.ColorIndex, PixelType.UnsignedByte, data); now, the PixelFormat is ColorIndex.... this is what I need... however, when I use this, I get pure black images, no transparency... So, I think I must be missing the 'color palette' somewhere... I'm trying to discover, how to let opengl know the data of the colorpalette tha the ColorIndex will look at.   I also read this... "Similarly, to offset the color indices of a bitmap to the palette entries you have defined for it, use glPixelTransferi(GL_INDEX_OFFSET, bitmap_entry);"   it says 'the palette entries you have defined', and im assuming this is 'bitmap_entry', but nothing shows 'HOW' to define the palette entries     So... I'm feeling more lost than ever, surely surely someone has used indexed graphics, and knows how to do this, but the lack of information on the web is troubling, i'm thinking, is it even possible anymore?     Thanks for any help
  6. Thanks so much for your input.   Well, the case with Palette.Entries[0], is that it's alpha value is non 0, and I really don't care what color the pixels are for index 0, as long as it is transparent.  I cant edit the original images, unless there is some magical opengl, trick to mass convert data or something, I'm afraid I'll have to check and set to alpha 0 each time I hit an index 0 byte.   I see what you mean, as far as writing 1x4 bytes, not sure if this would be a speed increase, but its something I will try, just to see if I get different results.   It is a time critical piece of code, and I do have it in a 'title/loading' screen, its just.... slow loading.   Now you mention, am I sure its 'super slow'... yeah, it kinda is... and actually that is a bit surprising, even for an 800x800 image... I would think it would be faster on a modern computer.  So, I'm wondering if the part that is taking up so much time, might be the part of the code where I am reading in the Bitmap, with LockBits, and copying its data.   I plan to keep trying and experimenting   If anyone has any other input or have used 8bit indexed bitmaps.... please share some secrets, thanks.
  7. I am working on a project, that uses some legacy graphics, that are in an 8bit indexed bitmaps.  These are the ones with a 1 byte pixel, pointing to an array of 256 colors.   So far, this is how I have been doing things.... (note, I'm using C#, with OpenTK, although a solution in C++ can be easily converted) Bitmap bitmap = new Bitmap(path); System.Drawing.Imaging.BitmapData textureData = bitmap.LockBits( new Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); int srcmax = textureData.Height * textureData.Stride; byte[] origBytes = new Byte[srcmax]; Marshal.Copy(textureData.Scan0, origBytes, 0, srcmax); bitmap.UnlockBits(textureData); this gives me the bitmap pixel data (the 1 byte index numbers) in textureData. So now, I very slowly and very painfully, go through the data, as such.... //loop through all the pixels byte[] data = new byte[(bitmap.Width * bitmap.Height) * 4]; int srcloc = 0; int dstloc = 0; byte index; Color color; for (int y = 0; y < textureData.Height; y++) { srcloc = y * textureData.Stride; for (int x = 0; x < textureData.Width; x++) { index = origBytes[srcloc]; if (index == 0) { data[dstloc] = 0; data[dstloc + 1] = 0; data[dstloc + 2] = 0; data[dstloc + 3] = 0; } else { color = bitmap.Palette.Entries[index]; data[dstloc] = color.R; data[dstloc + 1] = color.G; data[dstloc + 2] = color.B; data[dstloc + 3] = color.A; } dstloc += 4; srcloc++; } } as you can see, I am looking at the color, pointed to, by each pixel index... and manually reversing the red, and blue values, and also, setting alpha to 0, when the index number is 0.  This converted data is then used to create an opengl texture, as follows... GL.Enable(EnableCap.Texture2D); uint textureID = 0; GL.GenTextures(1, out textureID); GL.BindTexture(TextureTarget.Texture2D, ret.ID); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (float)TextureWrapMode.Clamp); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (float)TextureWrapMode.Clamp); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (float)TextureMinFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (float)TextureMagFilter.Nearest); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, width, height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, pixelData); GL.Disable(EnableCap.Texture2D); Now... this totally works, I end up with a rgba opengl texture2d, with transparency that can be used to texture a quad  and it looks perfect.... only problem is the super slow speed of going through each pixel, as some of these images are > 800x800   So... If anyone knows of a better solution, something faster, or if you know of anything I seem to be doing wrong (opengl wise, as I am an opengl noob) please let me know.   Thanks
  8. Thanks for the replies, I wouldn't even begin to know how to batch my sprites, as each of the 100 sprites would contain different textures.  No duplicating textures.   I see what you mean now about not needing to call 'end' on the shader.     I think I understand about the 'setvariable' once, ,then just bind different textures.  I will give this a try XD    Thanks again.
  9. Sorry if I am unsure of the proper terms to use,  this is all fairly new to me.   I am working on a game, that uses 8bit indexed graphics (for palette shifting/swapping effects).   After about a month of searching tutorials, forums, etc... I am at the point, where I am doing this.....   Each 'character' has a reference to a sprite (object containing a Texture2D) which holds my character image (using the red value of rgb to be an index to the color palette per pixel)   And each 'character' has a local Texture2D for holding that 'character's unique color palette (since different players might color their character's skin, hair, eyes , etc... a different color)   So, each character has to pass its 'image' and 'palette' to the shader.... this is how I am doing it.   Every time I draw a 'character' I call this member function public void RenderAt(float posx, float posy, DuShader shader) { GL.ActiveTexture(TextureUnit.Texture0); mCurrentFrame.Bind(); shader.SetVariable("texture", (int)0); GL.ActiveTexture(TextureUnit.Texture1); mPalette.Bind(); shader.SetVariable("colorTable", (int)1); GL.ActiveTexture(TextureUnit.Texture0); shader.Begin(); mCurrentFrame.RenderNoBindAt(posx, posy); shader.End(); } My issue with this is that I am having to call shader.Begin, and shader.End per draw.  I am no expert at openGL, but it just screams at me as 'bad code'   My original thought , was to have the shader.Begin located at the beginning of the draw loop, then have all my Render calls happen, then at the end call shader.End   This however, did not work,  for some reason, I cannot execute the code....   GL.ActiveTexture(TextureUnit.Texture0); mCurrentFrame.Bind(); shader.SetVariable("texture", (int)0);   from between the shader.Begin and shader.End calls, it only works when the code is executed 'before' the shader.Begin   I have no idea why this is the case.   My understanding of shaders and howto use them is from examining about 30+ articles and tutorials over a period of about 4 weeks :P   So... finally my question... what is the 'best' meaning most correct or efficient way to have multiple draw calls to a shader, where the two textures (image and palette) are never the same, and not have to begin and end my shader for each one.   Here is my shader.begin and shader.end code... public void Begin() { GL.UseProgram(mProgram); } public void End() { GL.UseProgram(0); } And the actual GLSL fragment shader... uniform sampler2D texture; uniform sampler2D colorTable; void main() { vec2 pos = gl_TexCoord[0].xy; vec4 color = texture2D(texture, pos); vec2 palPos = vec2(color.r,0); vec4 newColor = texture2D(colorTable, palPos); newColor.a = color.a; gl_FragColor = newColor; } The output i get is correct, meaning it 'works' Ijust need to know if im using it correctly or a better way of doing this.   Thanks in advance, I know its a long winded question, and I tend to ramble :P  
  10. Just my 2 cents, but I would think, unless it really affects gameplay, I wouldnt worry about each screen being a little different than the other. Not sure exactly what type of game you are making, but I have seen many games where the screens do not match up, but was not necessary for accurate gameplay.
  11. Whenever I see a topic that you have replied to, or initiated, it always gets my interest.  Great job.
  12. I have to agree with wicked357, I think the most logical reason to be careful with sharing your source would be to help prevent cheating... Granted, I have done my fair share of that, in my day, and I know from experience, that not having the source made hacks, and bots extreamly difficult to create.   Also, if your source is server code, it could have database information that could compromise the security of user accounts or other important things on your system.   But for small games, single players, or just a stripped down framework, there is no reason to worry about sharing. 
  13. I tried it out, using IE (I know most people use other browsers, but you should always try to be a cross browser compatible as possible)   There are only a few little things that I noticed   1) When loading the resources, after pressing the 'Play' button, it sort of just 'hangs' , at first I thought my window locked up, but then the game started, so, maybe  a 'loading' screen or progress bar would help to show that it didnt just lock   2) The screen will scroll smooth most of the time with the player, but on occasion the screen will shake, almost like there is an earthquake happening.  Not sure if you are doing that on purpose?!?!  If you are... cool, but if not, might want to check out your screen movement (camera movement) code.   I really think you have a cool idea, and I see lots of potential here.  Good job XD
  14. Wow, you guys have given a LOT of useful information.  I cant express how grateful I am.  This will give me enough options to research and experiment with to last me a while.    Thanks again.
  15.   If this is not the correct forum, my apologies.  I thought, since I am a beginner to web or mobile games, this would be the best place to ask the quesiton.     I have been programming 'forever' in C++ and recently in C# with a sprinkle of Java thrown in for flavor.  However, all my games or apps are the standard .exe, run this in windows, variety.     Recently though, I have been trying to learn what language or languages I need to know to make games on a mobile device or that can be played from a web site.     I know the Apple market is fairly proprietary, and thus not owning a Mac, I dont think I have any possibility for developing anything for the IOS market.     The Android market, has so many different devices I'm confused of which one I should target (or if I even need to target anything specific) and definately what is the best Game Creation language to program it in.     I would love for my little games to not only be played on a mobile device, but also be playable from a web browser.  So I'm not sure if I could use the same language, or if the mobile device, and the web based, would need different languages for the program to be in.     My apologies if this is an 'over asked' question.  I promise you I have googled myself silly over the last few weeks trying to find answers.  I seriously just have lousy luck searching for answers.   BTW, I am only able to code from a windows platform.   Thanks in advance for any advice, or links you can provide to help me make the transition into the web / mobile device gaming arena.