• 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.
Sign in to follow this  
Followers 0
Inuyashakagome16

Basic movement (with shapes)

7 posts in this topic

I'm having an issue with moving a shape around the screen using the keyboard. 

 

http://pastebin.com/GLCj5Q5w < that is all I have thus far. It's a bit of a mess because I'm attempting to figure out what I'm doing wrong.

 

I understand how shapes are displayed on the screen but I don't understand how to move them.

Do I move the coordinates around? Or does the camera have to move around? 


I apologize for not displaying much code here except for what's in the pastebin. I just can't seem to find much info regarding this / I don't know where to look and it's frustrating to an extent. smile.png

 

EDIT: A few minutes of http://simplynoise.com/ seemed to help. -.-

 

Still can't figure it out but what I had been trying is updating the camera. (Or what parts of it I had implemented) 

I thought (and still do) that because I'm moving something IN the game that really its not moving but rather the camera is. 

 

Main Goal: Move Shape, then put in textures and collision and have shape move along textures. (you can see where this is going) 

Very simple goal, but i'm stuck here. 

Edited by Inuyashakagome16
0

Share this post


Link to post
Share on other sites
You can do either one. But what you are probably failing to understand is that all the drawing occurs with a single matrix. In your code you'll probably find somewhere that multiplies three matrices together:

World * view * projection

All three get multiplied together producing a single matrix that every vert is multiplied by.

Typically you will use this terminology, and three separate matrices, because its pretty standard and helps you mentally keep separate the object position, camera position, and projection. But it doesn't really matter if you change the world or view matrix to draw an object in a different place on the screen. Because what matters is the final matrix the vert gets multiplied with. There is always a way to modify either the world or view matrix to produce the same result.

But usually if you are wanting to move an object, then you store a position ( a single 3d vector) for it, and move that position around. When it comes to drawing the object you then setup the world matrix to translate the objects position.

If you are wanting to move a camera around, then you normally store a camera position and move it around. When it comes time to drawing you setup the view matrix to translate the camera position.

That is the basic idea. There is a ton of little details and honestly you can do it any way you want, as long as that final matrix you multiply every vert by gets those verts into the position you want.

I would recommend Fletcher Dunn's 3D game math book if you are confused about the matrices and verts and how those end up deciding what gets on the screen.
0

Share this post


Link to post
Share on other sites
void UpdateScene(double time)
{
        World = XMMatrixIdentity();
 
        Scale = XMMatrixScaling(500.0, 10.0f, 500.0f);
 
        Translation = XMMatrixTranslation(0.0f, 10.0f, 0.0f);
       
        World = Scale * Translation;
}

void DrawScene()
{
        D3DXCOLOR bgColor(0.0f, 0.0f, 1.0f, 0.0f);
 
        d3d11DevCon->ClearRenderTargetView(renderTargetView, bgColor);
 
        World = XMMatrixIdentity();
 
        WVP = World * camView * camProjection;
 
        cbPerObj.WVP = XMMatrixTranspose(WVP);
 
        d3d11DevCon->UpdateSubresource(cbPerObjectBuffer, 0, NULL, &cbPerObj, 0, 0);
 
        d3d11DevCon->VSSetConstantBuffers(0, 1, &cbPerObjectBuffer);
 
        d3d11DevCon->Draw(3,0);
 
        SwapChain->Present(0,0);
}

 

Like that pretty much. 

 

I understand where they all need to be multiplied for you to have the correct output. I guess I was just missing where I needed to use the stored value. (I'm really not sure why I don't completely understand this) 

 

        Vertex v[] =
        {
                Vertex(0.0f, 0.5f, 0.5f),
                Vertex(0.5f, -0.5f, 0.5f),
                Vertex(-1.0f, -0.5f, 0.5f),
        };

 

Is where I had the values for what was to be displayed. Are you talking about the v[] ? Because it is stored there. 

 

And then there is the Update. >_> 

 


void Update()
{
        XMMATRIX anew;
        anew = XMMatrixIdentity();
 
        camTarget = XMVector3Normalize(camTarget);
       
        camUp = XMVector3TransformCoord(camUp, anew);
        camForward = XMVector3TransformCoord(DefaultForward, anew);
 
 
        camPosition += moveUpDown*camForward;
        moveUpDown = 0.0f;
 
        camTarget = camPosition + camTarget;
 
        camView = XMMatrixLookAtLH(camPosition, camTarget, camUp);
}

 

 

Which is where I just started trying different things without stopping to think about what I'm trying to do. 

 

i'm probably going to have to look that book up as well. I have a decent understanding its just somethings here are a bit tough (at first.) 

 

The overall goal here was just to display something, move it around, setup collision (as stated before) and have the camera follow me. At that point i thought well i have to just move around the object instead. I'm guessing I just have to reread a few chapters because i must have missed something.

0

Share this post


Link to post
Share on other sites

In the UpdateScene the Translation matrix is going to change your objects posiiton.

 

In this case your three verts:

(0.0f, 0.5f, 0.5f)

(0.5f, -0.5f, 0.5f)

(-1.0f, -0.5f, 0.5f)

 

get translated by (0, 10, 0) and become

(0.0f, 10.5, 0.5)

(0.5f, 9.5f, 0.5f)

(-1.0f, 9.5f, 0.5f)

 

So if you want to move your object around just store a Vertex for its position:

 

Vertex currentPosition;

 

Then in UpdateScene use your variable:

 

Translation = XMMatrixTranslation(currentPosition.x, currentPosition.y, currentPosition.z);

 

And now you control where those verts get drawn by changing the variable 'currentPosition'.

Edited by HAM
0

Share this post


Link to post
Share on other sites

This sounds more like a basic misunderstanding how this works. You don't draw stuff and then move it around. Every frame you draw everything from scratch with the position it is supposed to be at.

 

Don't expect this work like a GUI, where you can just place and move objects around.

0

Share this post


Link to post
Share on other sites
This sounds more like a basic misunderstanding how this works. You don't draw stuff and then move it around. Every frame you draw everything from scratch with the position it is supposed to be at.

 

Don't expect this work like a GUI, where you can just place and move objects around.

i'm aware it doesn't work like a GUI. I have the concept where each "frame" or iteration you can change a value and more around an object. However I couldn't figure out how to do it at first.

0

Share this post


Link to post
Share on other sites

If what I said didn't make sense, let me know and I'll try to be more clear.   Otherwise, good luck.  I bet you've got it by now.

1

Share this post


Link to post
Share on other sites

It does it just took a second. :) I do thank you for your help. It seems that when learning the "World, View Projection and Transformations" I forgot to read a few paragraphs so I knew the syntax just not the theory. :) So i'm going back over it now and it's starting to click. When I do figure it out i'll post and explain what I think it is, just for the record.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0