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

????? ?????

  • Content count

  • Joined

  • Last visited

Community Reputation

150 Neutral

About ????? ?????

  • Rank
  1. DrEvil, thanks, it's realy good idea. I've done it and I saw on the vector field, that there are eternal loops, but I can't handle it. On the attached igms I've isolated with black areas wrong vectors. Direction defines as from cell center to periphery.   Don't know how to correct that.
  2. Here is my screenshots.
  3. Hi! I have problems with implementing pathfinding using virtual potentional fields. I have square-tiled 2D world, where we can put start, finish and wall (not walkable) blocks. I've read about "potentional fields" method, but I couldn't find any example, how to realize it and decide to do it myself.   Here is my code: Point* currentPlayer = start; //current player position Point* currentBlock; //current blocked point XMFLOAT2 blockedForce; XMFLOAT2 lastsResultative = XMFLOAT2(0, 0); XMFLOAT2 finishForce; float squaredDist; int i = 0; while (*currentPlayer != *end) { finishForce = XMFLOAT2( end->getX() - currentPlayer->getX(), end->getY() - currentPlayer->getY() ); finishForce = Calculations::VecNormalize2D(finishForce); /*finishForce.x *= 10; finishForce.y *= 10;*/ i = 0; while (i < blockedPoints.size()) { currentBlock = blockedPoints[i]; squaredDist = pow( (currentPlayer->getX() - currentBlock->getX()),2 ) + pow( (currentPlayer->getY() - currentBlock->getY()),2 ); blockedForce = XMFLOAT2( (currentPlayer->getX() - currentBlock->getX()) / squaredDist, (currentPlayer->getY() - currentBlock->getY()) / squaredDist); lastsResultative = XMFLOAT2( lastsResultative.x + blockedForce.x, lastsResultative.y + blockedForce.y); i++; } lastsResultative = XMFLOAT2( lastsResultative.x + finishForce.x, lastsResultative.y + finishForce.y); lastsResultative = Calculations::VecNormalize2D(lastsResultative); // ++++++++++++++ Make decision to what cell we have to walk, ++++++++++++++ // ++++++++++++++ based on the resultant vector ++++++++++++++++++++++++++++ float factor, prevFactor = 1000; Point *cell = nullptr, *tempCell; for (int j=-1; j<2; j++) { for (int k=-1; k<2; k++) { tempCell = GetCell(XMUSHORT2((USHORT)(currentPlayer->getX() + j), (USHORT)(currentPlayer->getY() + k))); if ((j==0 && k==0) || tempCell==nullptr) continue; XMFLOAT2 cellVec = XMFLOAT2((tempCell->getX() - currentPlayer->getX()), (tempCell->getY() - currentPlayer->getY())); factor = abs(cellVec.x - lastsResultative.x) + abs(cellVec.y - lastsResultative.y); if (factor < prevFactor) { cell = tempCell; } else factor = prevFactor; prevFactor = factor; } } if (cell != nullptr) { currentPlayer = cell; path.push_back(currentPlayer); } // ---------------------------------------------------------------------------- } I've attached screens. In most cases, algorithm steps into eternal loop.   Help please with this issue.
  4. Thanks, I've fixed it.
  5. Hi! I've written my own simple function to detect collisions of rectangles and it works not accurate and not always. So here is my code: bool GameLogic::IsRectsCollide(float* rect1, float* rect2, float eps) { float r1_left = rect1[0]; float r1_top = rect1[1]; float r1_right = rect1[2]; float r1_bottom = rect1[3]; float r2_left = rect2[0]; float r2_top = rect2[1]; float r2_right = rect2[2]; float r2_bottom = rect2[3]; if (r2_right - r2_left < r1_right - r1_left) { swap(r1_left, r2_left); swap(r1_top, r2_top); swap(r1_right, r2_right); swap(r1_bottom, r2_bottom); } if ( ( r1_left >= r2_left && r1_left <= r2_right && r1_top >= r2_bottom && r1_top <= r2_top ) || ( r1_right >= r2_left && r1_right <= r2_right && r1_top >= r2_bottom && r1_top <= r2_top ) || ( r1_right >= r2_left && r1_right <= r2_right && r1_bottom >= r2_bottom && r1_bottom <= r2_top ) || ( r1_left >= r2_left && r1_left <= r2_right && r1_bottom >= r2_bottom && r1_bottom <= r2_top ) ) { return true; } return false; } Image shows typical fail... 
  6. Projects a 3D vector from screen space into object space. XMVECTOR XMVector3Unproject( [in] XMVECTOR V, [in] float ViewportX, [in] float ViewportY, [in] float ViewportWidth, [in] float ViewportHeight, [in] float ViewportMinZ, [in] float ViewportMaxZ, [in] XMMATRIX Projection, [in] XMMATRIX View, [in] XMMATRIX World ); Is this all you need?
  7. I've handled problem. The problem was in world matrix. The right variant (in my case) is World = scale * rotationZ * translation. And this line of code killed 2 days of my life    unbird, you are right about coefficients calculating and atan2, but it was another bug.   So the correct variant of setting GameObjects to draw lines: for (Line& line: SidesCoordList) { shared_ptr<GameObject> temp(new GameObject()); float length = sqrt( pow(line.point2.x - line.point1.x, 2) + pow(line.point2.y - line.point1.y, 2) ); float A = line.point1.y - line.point2.y; float B = line.point1.x - line.point2.x; float angle = atan2(A, B); XMFLOAT2 center = XMFLOAT2( (line.point2.x + line.point1.x) / 2.0f, (line.point2.y + line.point1.y) / 2.0f ); temp->SetPosition(center); temp->SetRotation(-(XM_PIDIV2 - angle)); temp->SetScale(XMFLOAT2( 5.0f, length )); sides.push_back(temp); } And here is function that defines if the object reach the line: bool BulletManager::IsIntersecting(Line line, XMFLOAT2 point, float eps) { if (!((point.x >= min(line.point1.x, line.point2.x) && point.x <= max(line.point1.x, line.point2.x)) || (point.y >= min(line.point1.y, line.point2.y) && point.y <= max(line.point1.y, line.point2.y))) ) return false; // Constructing canonical line equation float A = line.point1.y - line.point2.y; float B = line.point2.x - line.point1.x; float C = (-B * line.point2.y) - (A * line.point2.x); // Calculating distance from bullet to line float Dist = (abs((A * point.x) + (B * point.y) + C)) / sqrt(pow(A,2) + pow(B,2)); if (Dist <= eps) return true; return false; } Maybe it will be useful for someone. Who knows...
  8. unbird, with transposing all crashed: player is displayed wrong (must be quad, but now line), walls disappeared. See attached images. First - with transposing, second - without.   Here is my project: http://www.filedropper.com/bulletmanagerproject
  9. Hi 2 all! I have some problems with rectangle rotation. The sense of my test application: there are player in the center of screen, he can rotate around and shoot; bullets have to reflect from walls. All works fine except of walls rendering. The issues related to walls definition: struct Line { XMFLOAT2 point1; XMFLOAT2 point2; Line(XMFLOAT2 p1, XMFLOAT2 p2) : point1(p1), point2(p2) { }; }; vector<Line> SidesCoordList; vector<GameObject> sides; SidesCoordList.push_back(Line(XMFLOAT2(0.0f, 0.0f), XMFLOAT2(0.0f, 600.0f) )); SidesCoordList.push_back(Line(XMFLOAT2(0.0f, 600.0f), XMFLOAT2(800.0f, 600.0f) )); SidesCoordList.push_back(Line(XMFLOAT2(800.0f, 600.0f), XMFLOAT2(800.0f, 0.0f) )); SidesCoordList.push_back(Line(XMFLOAT2(800.0f, 0.0f), XMFLOAT2(0.0f, 0.0f) )); ... for (Line& line: SidesCoordList) { GameObject temp; ... temp.SetPosition(center); temp.SetRotation(XM_PIDIV2); temp.SetScale(XMFLOAT2( 20.0f, length )); sides.push_back(temp); } ... for (int i = 0; i<instanceCount; i++) { if (i >= sides->size()) break; XMMATRIX mat = sides->at(i).GetWorldMatrix(); instances[i].M1 = mat.m[0]; instances[i].M2 = mat.m[1]; instances[i].M3 = mat.m[2]; instances[i].M4 = mat.m[3]; } d3dContext_->UpdateSubresource(instanceBuffer, 0, 0, instances, 0, 0); ... d3dContext_->DrawInstanced(vertexCount, instanceCount, 0, 0 ); Code for matrices from GameObject class: XMMATRIX GameObject::GetWorldMatrix( ) { XMMATRIX translation = XMMatrixTranslation( position_.x, position_.y, 0.0f ); XMMATRIX rotationZ = XMMatrixRotationZ( rotation_ ); XMMATRIX scale = XMMatrixScaling( scale_.x, scale_.y, 1.0f ); return rotationZ * scale * translation; } void GameObject::SetPosition( XMFLOAT2& position ) { position_ = position; } void GameObject::SetRotation( float rotation ) { rotation_ = rotation; } void GameObject::SetScale( XMFLOAT2& scale ) { scale_ = scale; } HLSL code: cbuffer cbMatrices : register( b0 ) { matrix world; matrix proj; }; cbuffer cbParameters : register( b1 ) { bool isTextured; float4 color; }; Texture2D colorMap_ : register( t0 ); SamplerState colorSampler_ : register( s0 ); struct VS_Input { float4 position : POSITION; float2 tex : TEXCOORD0; float4 W0 : TEXCOORD1; float4 W1 : TEXCOORD2; float4 W2 : TEXCOORD3; float4 W3 : TEXCOORD4; }; struct PS_Input { float4 position : SV_POSITION; float2 tex : TEXCOORD0; }; PS_Input VS_Main(VS_Input input) { PS_Input vsOut = ( PS_Input )0; float4x4 world_ = float4x4(input.W0, input.W1, input.W2, input.W3); float4x4 WVP = mul(world_, proj); vsOut.position = mul(input.position, WVP); vsOut.tex = input.tex; return vsOut; } float4 PS_Main( PS_Input frag ) : SV_TARGET { if (isTextured) return colorMap_.Sample( colorSampler_, frag.tex ); else return float4(color.xyz, 1.0f); return (float4)(0); } Quit strangely that all the objects (player, bullets) are rendered correctly, except of walls. Walls don't want to rotate on Pi/2, another values of angles make distortions similar to incorrect setting of projection matrix. I've used VS Graphics debugger to track values in matrices and it seems correct. On the attached image the first one is matrix of player object, the second one - wall.   I try to understand what I made wrong and debug code during the whole day. Help please
  10. L. Spiro, thanks! Now reflection works fine. Interesting and useful story about shared_ptr  
  11. Yeah, I didn't point that. Thanks, I've corrected.   I store my bullet as smart pointer in vector: vector<shared_ptr<Bullet>>, and I use common get() function: http://www.cplusplus.com/reference/memory/shared_ptr/get/   I know, but I use Left-Handed coordinate system, where +y is up. By the way, if I replace my reflection code with function from xnamath.h XMVector2Reflect(vecBulDir, vecNormal) all works correctly. But my task is to write my own reflection 
  12. Hello everybody! I'm trying to solve test task: Sorry for my English, the text above is google-translated.   I've made it, all is good, except of reflextion: bullet reflects, but not always correctly. Here is my function: void BulletManager::Update(float time) { for (int n = 0; n < bullets.size();) { auto bul = bullets.begin() + n; XMFLOAT2* bulDir = &bul->get()->GetDir(); float x = bul->get()->GetInitPosition().x + (bulDir->x * (time - bul->get()->GetTime()) * bul->get()->GetSpeed()); float y = bul->get()->GetInitPosition().y + (bulDir->y * (time - bul->get()->GetTime()) * bul->get()->GetSpeed()); XMFLOAT2 point = XMFLOAT2(x, y); bul->get()->SetPosition(point); //Check bullet life time if (bul->get()->GetLifeTime() - (time - bul->get()->GetTime()) <= 0.0f) { bullets.erase(bul); n--; continue; } //Check, if bullet collides with sides for (int i=0; i<SidesCoordList.size(); i++) { if ( IsIntersecting(SidesCoordList[i], point, 1.0f) ) { //Calculating normal vector for current side float A = abs(SidesCoordList[i].point1.y - SidesCoordList[i].point2.y); float B = abs(SidesCoordList[i].point2.x - SidesCoordList[i].point1.x); XMFLOAT2 normal = XMFLOAT2(A, B); normal = XMFLOAT2(normal.x / Calculations::VecLength(normal), normal.y / Calculations::VecLength(normal)); //Calculating angles to get reflected directional vector float alpha = atan(A/B); float beta = acos(bulDir->x); float gamma = XM_PIDIV2 - (alpha - beta); float theta = beta + 2*gamma + XM_PI; //Setting new direction (after reflection) bul->get()->GetDir() = Calculations::RotateVector(bul->get()->GetDir(), theta); bul->get()->GetInitPosition() = bul->get()->GetPosition(); bul->get()->GetTime() = time; } } n++; } } What's wrong with my code?   Thanks.