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

Archived

This topic is now archived and is closed to further replies.

Nobles

Scrolling Question

5 posts in this topic

I would actually create a system in where you center the view around a certain coordinate (most likely the character or a camera).

So if you are working in 800x600, then:

camera_x = 1024; // whatever;
camera_y = 1240; // whatever;

view_x = camera_x - 400; // half of 800
view_y = camera_y - 300; // half of 600
blit(view_x, view_y, 800, 600);

The reason it might be slow is you are only scrolling by one pixel at a time. You can actually go up to 1-32 pixels at a time and still make it 'smooth' enough.


Jim Adams

0

Share this post


Link to post
Share on other sites
Ahh, ok I didn't even think of increasing the amount of pixels scrolling. That helped quite a bit, thanks!
I'm interested in what you were saying about setting the view scrolling around a camera or the character but I'm not sure if I understand how to implement it. I want the player to be able to move around the map w/ out having to move the character (Like Command & Conquer or Baldur's Gate) so I guess I would have to move a "camera." But I also need for the player to be able to move the mouse pointer freely in viewable area w/ out the screen moving... that is until he/she moves the cursor to the edge of the viewable area, then the map would move. Would I still be able to use the "camera" method you described?
I really want to use the cleanest method possible for this. So I'm game for any suggestions.
Thanks again!
-Nobles-
0

Share this post


Link to post
Share on other sites
For the camera idea, you want to keep the location of the camera, and when the user bumps the side of the screen increment or decrement the location of the camera accordingly. Then blit your background in relation to the camera. i.e. if your camera is at 400, 300 blit the surface between 400,300 and 1200, 900.

Just as an aside, on x86 platforms assigning more than 2 variables to be register variables doesn't help, as there are only 4 general purpose registers and you need at least two of them for your arithmetic and store/load operations. It's arguable with the more recent (Pentium and newer) processors using more than one register variable is appropriate.

0

Share this post


Link to post
Share on other sites
You can either have the camera represent a section of the map (ie 0,0 to 799,599), or as a single coordinate that you center on when rendering the view - it's up to you, but I would go with the single coordinate idea - tends to port better if you are going to change resolutions at any time.

So, you have a camera that you track the coordinates on. Keep track of the mouse coordinates on screen, and you can add the camera coordinates to it to get world coordinates if they are needed.

Use a timer so that when the mouse reaches the edges of the screen, after 1/2 second (or so many frames), the camera moves in that direction.

Let's say the camera coordinates are:
camerax = 1024; // whatever
cameray = 1234; // whatever

the mouse screen coordinates are:
screenmousex = 535; // whatever
screenmousey = 202; // whatever

Then, since the screen is 800x600, you would render the map with the following coordinates:

topx = camerax - 400; // screenwidth / 2
topy = cameray - 300; // screenheight / 2

And you would get the mouse world coordinates like:

worldmousex = screenmousex + topx;
worldmousey = screenmousey + topy;


Now, you check the mouse screen coordinates against the edges (an 8 pixel edge for example):

if(screenmousex < 8)
left_edge_count++;
else left_edge_count=0;

if(screenmousex > 791)
right_edge_count++;
else right_edge_count=0;

if(screenmousey < 8)
top_edge_count++;
else top_edge_count=0;

if(screenmousey > 591)
bottom_edge_count++;
else bottom_edge_count=0;

Check for scrolling - say if the mouse stays in spot for 15 frames (1/2sec at 30fps):

if(top_edge_count >= 15)
cameray -= camera_scrollspeed;
if(bottom_edge_count >= 15)
cameray += camera_scrollspeed;
if(left_edge_count >= 15)
camerax -= camera_scrollspeed;
if(right_edge_count >= 15)
camerax += camera_scrollspeed;


Make sure to get the mouse world coordinates after scrolling the field to ensure the camera coordinates haven't changing during that last part.


Jim Adams

0

Share this post


Link to post
Share on other sites
Hello,
I've just started programming in 'C' recently using DJGPP w/ Allegro. I need some advice with scrolling a large map i.e. Baldur's Gate.
From what I've read everyone seems to prefer tiles. But for this project this is the method agreed on by the artist and I.
I've kinda' got it working but the scrolling is SO slow... and the horizontal scrolling is choppy. I've read something about this but am uncertain on what to do about it. I'm sure the way I'm going about the scrolling is probably misguided... so any suggestions on a better method would be greatly appreciated! Also would a Window's compiler offer any speed advantages over DJGPP?
The map is 1600x1200 w/ an 800x600 viewable area. Here is what I've been doing:

register int xl = 799;
register int xs = 1;
register int yl = 599;
register int ys = 1;

...blah-blah-code...

do {
x = mouse_x - 0;
y = mouse_y - 0;

if (x > xl){
++xl;
++xs;
}
else if (x < xs){
--xl;
--xs;
}
if (y > yl){
++yl;
++ys;
}
else if (y < ys){
--yl;
--ys;
}
request_scroll(xs, ys);

blit(background, screen, 0, 0, 0, 0, w, h);

} while (!keypressed());

0

Share this post


Link to post
Share on other sites
Just to beat a dead horse...

The method i use is quite simple, and makes use of the POINT and RECT structs.

for those not familiar with POINT or RECT, POINT has two ints: x,y; and RECT has four ints: left,top,right,bottom.

any position can be represented by a POINT, any rectangular area can be represented by a RECT.

so, your world may be 1600x1600 pixels, and your resolution of choice is 800x600. (for the sake of discussion, i am assuming that the ENTIRE display is used)

your main character (or camera, or whatever) is represented by a POINT structure that describes a location in worldspace (described by the RECT l=0,t=0,r=1600,b=1600) (This is called an anchor point)

and of course, you want the camera to look at the center of the screen(400,300).

so, a RECT describing the extent of the camera is l=-400,t=-300,r=400,b=300

so, adding x to left and right, and y to top and bottom, you have the RECT in worldspace that describes what is seen in screen space.

but, we dont want our RECT to be outside of worldspace, so we clip our anchor to a RECT that ensures that the RECT will not contain any points not in worldspace.

we take the anchor extent RECT (-400,-300,400,300) and subtract it from the coordinates of worldspace (0,0,1600,1600), to get anchorspace (400,300,1200,1300). now, as long as the anchor is within anchorspace, we can plot whatever is in worldspace into screenspace without fear.

how does this relate to scrolling?

well, when scrolling, all you need to do is move the anchor, and clip it to anchorspace.

[This message has been edited by TANSTAAFL (edited December 16, 1999).]

0

Share this post


Link to post
Share on other sites