Jump to content
  • Advertisement

KillerkoUK

Member
  • Content Count

    18
  • Joined

  • Last visited

Community Reputation

199 Neutral

About KillerkoUK

  • Rank
    Member
  1. Thanks Servant, creating a DrawWorld.h and putting my struct there and then including this to my class and main cpp as in your post worked :)   btw what do you mean by the inclusion guards ( #ifdef BLAH_H / #pragma once)? I have no idea what those are/do but the code seems to be working fine without them..   also I'm aware that having a global variables is considered bad, thats why I have the struct in the first place and planing to move it somewhere inside my main later on... (hopefully it will not break my program completely)
  2. Hi everybody,   I have a global struct DrawWorld with some of my variables that I need to pass to one of my function in my map class..   I have tried to add this to my map class:     map.h:   void generateMap2(DrawWorld drawWorld);   map.cpp:    void map::generateMap2(DrawWorld drawWorld) { when I try to compile I get error: error C2061: syntax error : identifier 'DrawWorld'   my map class have no idea about the existence of my struct, normally I would just #include .h file but there is not .h file as this is my main .cpp file where the struct is defined and there is no .h file only .cpp is there any way how I can pass this struck to my class function?   thanks.
  3. Yes, Thank you C0lumbo!   Thats exactly what I needed.. I will never have a negative number so this is more than enough for me.
  4. I have input numbers:   1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13.... etc   I would like to get output for each of these nunbers to be:   1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2... etc   so for my input 12 i wanna get 4 and for 13 it would be 1 and so on   is there any simple way how I could get that?   for example 13 - ( int(13/4) * 4 )  is 1 that works for 14 or 15 too, but unfortunately not for 12 or 16 as i will get 0 which is wrong  
  5. Hi, I started the same way as you.. have a look on HGE as well.. I have been using it to create 2d tile based little games too.. its hardware accelerated, easy to work with and you can have a sprite moving on your screen very quickly without worring too much about the inner working of directx or opening a window etc. So you don't get stuck on the very overhelming things like those mentioned and can still progress in your learning.. It has been working well for me.
  6. KillerkoUK

    for loop skipping to the end after first loop

    Thank you Lactose, all this is very helpful indeed!   I've seen those step over and step into icons on the debugging toolbar in my visual studio but had no idea how to use them so I've never used them before.
  7. KillerkoUK

    for loop skipping to the end after first loop

    SeanMiddleditch: I'm pretty new to this and still learning mostly.. all I can do while debuging is to place these breakpoints and when the program stops I can examine my variables and they values.. then let the program continue and wait for another stop to examine values again. How do you use those data breakpoints? that sound like something that could be very useful. 
  8. KillerkoUK

    for loop skipping to the end after first loop

    yes thats it.. thanks phil_t! there is a mistake in the second part of the if statement.. "myMap[(y-1)" should be "myMap[(y-2)" and thats exactly why it turned false for 1-3 (-1,1)  ..   thanks! :)
  9.  Hi, I have strange problem with a standard for loop.. It should go from -2, to 2 (-2, -1, 0, 1, 2) but when I debug the program and place the red dot inside the loop and look at the "i" value it goes from -2 directly to 2 after first loop. (-2, 2) which is puzzling me why?    here is the loop: for(int i = -2; i < 3; i++) { if(myMap[(y-2) * myMapW + x+i].properties != 0 && myMap[(y-1) * myMapW + x+i].properties != 1) { tileTemp.sprite = 1;//if(getTileSprite(x+i, y-2) > 2) tileTemp.sprite = rand()%2 + 1; tileTemp.entity = this->getTileEntity(x+i, y-2); tileTemp.properties = 2; myMap[(y-2) * myMapW + x+i] = tileTemp; } } I tried to change the negative numbers so the loop should go from 0, 1, 2, 3 and 4 but it goes from 0 to 4 right after first loop... why?  for(int i = 0; i < 5; i++) {     if(myMap[(y-2) * myMapW + x+i-2].properties != 0 && myMap[(y-1) * myMapW + x+i-2].properties != 1)     {         tileTemp.sprite = 1;//if(getTileSprite(x+i-2, y-2) > 2) tileTemp.sprite = rand()%2 + 1;         tileTemp.entity = this->getTileEntity(x+i-2, y-2);         tileTemp.properties = 2;         myMap[(y-2) * myMapW + x+i-2] = tileTemp;     } } I use visual studio 2010 and for loop so far have worked as it should.. well, until now
  10. 2_Robert Bob and radioteeth: this is what I found about stencil buffer and hge: http://relishgames.com/forum/index.php?p=/discussion/3081/stencil-buffer-in-hge/p1 is there any other way how I could use it? any example how? I am quite new, still learning and it might be out of my skill...   2_HappyCoder: this sounds like something I have already tried to do.. I rendered my shadow sprite as opaque using 'render to texture'.. (lets say on with white background, since alpha is not working) then I slap this rendered texture on sprite and render it on screen with default blending and I got this:     now all I needed to do is to use like you said some kind of multiply blend mode that would get rid of the white colour and I could use alpha to get the desired transparency. sadly, hge does not have any multiply blend mode (or I have no idea how to use them).. I could only get rid of black from the pic above with using BLEND_ALPHAADD (or if I render my sprite at normal color on black background then the oposite effect):     I haven't been able to get the result I need with the hge blending modes available.   There is another idea that I got how to get rid of the white and thats colour-keying... of course hge does not support this, but I managed to find this code on their forum that should do it:  void SetMaskColor(HGE *hge , HTEXTURE tex , int w , int h , int r , int g , int b) { int x , y;     DWORD *color = hge->Texture_Lock(tex, false);     DWORD maskcolor = ARGB(255, r , g , b);     DWORD *pixel;       for (x = 0; x < w; ++x)     {         for (y = 0; y < h ; ++y)         {             pixel = &color[y*w+x];             if((*pixel) == maskcolor)                 (*pixel) = 0;         }     }     hge->Texture_Unlock(tex); } good news is that this works! I have tried it and it works, BUT it only works with HTEXTURE which are textures.. and I need it to work with HTARGET which is render target.. my 'rendered to texture' now I'm not very good at this but I try to do something like: HTEXTURE newTexture; ... newTexture = hge->Target_GetTexture(targetShadowMap); // I try to copy my HTARGET which contains my rendered texture into HTEXTURE ? ? ? ? ? ? ? unfortunately when I pass this newTexture with the function above the whole thing will crash... on the line: if((*pixel) == maskcolor) with the message: "Unhandled exception at 0x00d7c4f2 in Project2.exe: 0xC0000005: Access violation reading location 0x00000000." If I use the function with any other HTEXTURE which I initialized as "hge->Texture_Load("texture.png");" then it works fine.  
  11. Hi, everybody. I have a simple top down 2d game that have a bunch of characters and objects on screen with very simple shadows. Shadows are basically inverted sprites tinted black and rendered at about 80 alpha. It all looks ok until the shadows of multiple characters/objects start to overlap.. then it will create this effect: How could I make the shadows not to stack on each other?   I'm using HGE (haaf's game engine) and one idea I got was to render all shadows to texture at solid black and then render this texture at half alpha between my level and characters. This sounded initially like it could work but I hit the wall with HGE and render to texture that does not support alpha :/ or at least I had no idea how to render to texture with alpha working. I tried to play with blend modes, googled, but the best I could get is kind of white-ish shadow with BLEND_ALPHAADD which will get rid of all the black thus creates the desired "alpha" but leaves me with 'white' sprite that looks more like a reflection on water than shadow :/ any other ideas? or any solution how to get that alpha work with render to texture in HGE? I also googled and found a few posts on the original hge forum how to modify hge source to make alpha work but that failed too as I was unable to compile the hge (even without any changes..) as I got a bunch or errors..  
  12. thanks for the direction what to look for! this is now doing exactly what I needed... it returns true if the tile between the 2 points equals 1 or false if there isnt anything blocking the line. perfect! :-)   bool raytrace(int x0, int y0, int x1, int y1) {     int dx = abs(x1 - x0);     int dy = abs(y1 - y0);     int x = x0;     int y = y0;     int n = 1 + dx + dy;     int x_inc = (x1 > x0) ? 1 : -1;     int y_inc = (y1 > y0) ? 1 : -1;     int error = dx - dy;     dx *= 2;     dy *= 2;     for (; n > 0; --n)     { // here I can use x,y to do something with the tile, in my case I just need to check if my tile is 1         if(currentLevel.getTile(int((x+tileSize/2)/tileSize), int((y+tileSize/2)/tileSize)) == 1) return(true);         if (error > 0)         {             x += x_inc;             error -= dy;         }         else         {             y += y_inc;             error += dx;         }     } // nothing blocking the line     return(false); }
  13. yes that sounds like something I was thinking about but the problem is how do you get the tiles the line is crossing? all I can get is the tiles of the first point and the last point (since I know them). But how do you get the rest of the tiles thats are inbetween those 2 points?
  14. Hi, I have a tile map filled with 2 types of tiles walkable (0) and nonwalkable (1)... Now I have 2 points on my map, player and the exit and I need to know if they can see each other or if there is a nonwalkable tile in between them.     all I could manage to do is compute the distance between the points like this: distance = sqrt( (currentLevel.getExitX() - player.getX()) * (currentLevel.getExitX() - player.getX()) + (currentLevel.getExitY() - player.getY()) * (currentLevel.getExitY() - player.getY()) ); but from this point I am kind of clueless what to do next... how do I check all the tiles that this line is crossing if they are 1 or 0?   Ideally I would make a class which I could use like checkPoints(x1, y1, x2, y2) which will return either true or false based on if there is a non walkable tile between these 2 points... so I can use it like if( checkPoints(x1, x2, y1, y2) == true ) { do something } else { do something else }   any ideas how could I do this?    
  15. I use Haaf's Game Engine (HGE) http://hge.relishgames.com/ Its a hardware accelerated 2d engine. There are tutorials and docummentation on site as well as entire source code available on their website even tho the last version is from 2008 it is completely free even for commercial use (except the included BASS sound library, which is free only for noncommercial use)
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!