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

Help with tiled maps

3 posts in this topic

Hi guys i was experementing with tiled maps and wondered how to make the user stop when they hit a wall. also how to make directional bullet firing controlled by mouse. im a new programmer and need a little bit of a kickstart thanks for the help!
0

Share this post


Link to post
Share on other sites
Lets break down what you're asking for.[list]
[*]User must stop when they hit a wall
[/list]
For this, you need to learn about [b]Collision Detection[/b]. This literally means, "Detecting when an object collides with another" and usually involves some action which occurs when there is a collision (bouncing off, stopping, exploding, etc) There are many simple ways to do this, especially in Tile/Grid-based games. One of the simplest ways of doing this is what I used for collision in my PacMan clone.

When you first create games, your player will simply have an [b]X position[/b] and a [b]Y position[/b]. In a tile-based game, you can use this to detect the player's position in relation to the tiles and the grid on which they lie. Imagine that your player lies on a chess board, if the squares on the board are 64 pixels wide and long, then if your player was at (32,32) then he'd be considered to be in the top-left square. If he was at (500,500), he'd be in the bottom-right square.

Now, each tile in your game must be considered [b]passable[/b] or [b]not-passable[/b]. Grass would usually be passable, but Walls would not. This allows you to define which tiles players CAN and CANNOT walk on.

With this information together, you can work out which grid-space the player is attempting to enter and check if it is passable or not. If it is not passable, prevent the player from entering that space, but position them so they are immediately outside it.

That is the theory. Hopefully someone can provide you with useful articles to help you implement it yourself.

Secondly:[list]
[*]Directional bullet firing
[/list]
For this, you need to create objects that will move depending on a velocity. This is updated every frame and you can also do collision checks on the bullets to detect if they hit anything (like a wall or player).

These concepts are explained quite simply here:
[url="http://www.rodedev.com/tutorials/gamephysics/"]http://www.rodedev.c...ls/gamephysics/[/url]

Thirdly:[list]
[*]Mouse input
[/list]
Depending on which engine or API you are using; getting and using mouse-input can have a varied level of difficulty. What are you using?

p.s. Hopefully my explanations were easy to follow. Giving advice to others is quite a new thing for me.
0

Share this post


Link to post
Share on other sites
I'm not sure what your language, OS, or scripting interface is; so I'm going to answer as if you're in Windows C++.
It's been several years since I've made a tile-based game, so bear with me. These are the highlights that I remember.

Tile maps:
The key thing to realize is that tile maps can have multiple "layers".
Primary layer: where your character runs around.
Foreground layers: objects 'in front' of your character, usually scrolls faster than primary layer
Background layers: objects 'behind' your character (IE scenery), usually scrolls slower than primary layer
Collision layer: non-visible areas where the character will 'collide' with the world. May define several types of collision, such as slopes or different terrain (ice)
Trigger layer: Areas that cause an event when something enters them (player, enemy, etc)

Refer to TehOwn's post for more information about tile collision.



Mouse Input & bullet firing:
You really want your input to be hardware accelerated, but to get things going quickly you can use the windows function GetCursorPos(LPPOINT).
This returns a point in screen space, you need to convert it to client space.

[CODE]
PSEUDOCODE

void Player::UpdateGun()
{
// This buffers the input, so we aren't shooting a bullet
// every frame the left mouse button is held
static bool bMouseWasClicked = false;

// Check if the left mouse button is pressed
if( GetAsyncKeyState( VK_LBUTTON ) && !bMouseWasClicked )
{
POINT mousePos;
float bulletDirX, bulletDirY;
bMouseWasClicked = true;

// Get current position of mouse
GetCursorPos( &mousePos );
ScreenToClient( hWindow, &mousePos );

// Get a vector from the gun to the mouse
bulletDir.x = mousePos.x - m_Gun.x;
bulletDir.y = mousePos.y - m_Gun.y;

// Normalize the direction vector
float mag= sqrt( bulletDirX * bulletDirX + bulletDirY * bulletDirY );
if( mag == 0.0f ) mag = 1.0f;
bulletDirX /= mag;
bulletDirY /= mag;

// Tell the gun which way to fire
m_Gun.Fire( bulletDirX, bulletDirY );
}
else
{
bMouseWasClicked = false;
}
}

[/CODE]

This is completely untested code, but that's the general idea.
1

Share this post


Link to post
Share on other sites
Thank you guys so much for the help you really explained it well, i do know about collision detection and was just wondering how to implement it into tiled maps so that i could have walls and such and the code for the mouse directional shooting is very helpful thankyou!
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