playfield??????????

BlitzPlus Forums/BlitzPlus Programming/playfield??????????

B_Paulie(Posted 2006) [#1]
i want to know how to make a playfield so i can place planets and such in a field, then have a player move about the field.


WolRon(Posted 2006) [#2]
I want to know how you expect someone to answer such a vague question?

Ask SPECIFIC questions.

I don't even know what you mean by field. How do you place PLANETS in a FIELD?

Look at all of the different meanings it could have:
http://en.wikipedia.org/wiki/Field


Grey Alien(Posted 2006) [#3]
he did say playfield first as it area that the player can move around in.

But yes it is very vague, what do you need in the playfield, one big picture, tiled graphics? Is it to be bigger than the screen etc?


B_Paulie(Posted 2006) [#4]
bigger than the screen,(its in space), its a bunch of tiled images of stars and i want to know how to place things like planets,enemies, pickups and such on locations that the player would have to move around to get to. the player moves 360 degrees, and shoots in each direction, but i need to know how to make him move to places off screen, and still be able to see him.


CS_TBL(Posted 2006) [#5]
uh... *hmmmm*

I think he means:
- a typical 2d map with startiles, map is bigger than the screen, so the map needs to scroll its offsets according to the player-movement
- a list with pickup-items *OR* an overlaying maplayer with pickup-items


Grey Alien(Posted 2006) [#6]
someone must have a tutorial, it's jsut a lot to type and I've typed it lots before...


CS_TBL(Posted 2006) [#7]
B_Paulie: a mapbrowser is so easy to do, if you have to ask for one then I wonder if you're skilled enough to finish the rest of the gamecode anyway..
No offence, but you shouldn't rush things.. I could imagine that doing a game as a first-orso project is fun, but the reality is that a game isn't just drag 'n drop code..

Small steps at a time, eventually you'll get there.

(or am I fully wrong here? :P)

I could create a mapbrowser in less than 20 minutes I think, but I wonder if I would do any good to take this work out of your hands... as in: what would *you* gain from it, other than more drag 'n drop code..?

Feel free to slap me for this ^_^


B_Paulie(Posted 2006) [#8]
nah, youre right(i dont wanna slap you), but when i drag & drop code, i look at it and see how it works. i just need an answer to my question ^_^


CS_TBL(Posted 2006) [#9]
Explain me in words (english) how a 2d map works, what are its properties, what it should do, etc. I'll make you think of a solution yourself.


Grey Alien(Posted 2006) [#10]
yeah you just gotta work this stuff out and experiment. First make a non-scrolling playfield with sutff on it and then when that works, make it scroll.


B_Paulie(Posted 2006) [#11]
i just need to know how to make a player move about a field and have the camera follow him offscreen


CS_TBL(Posted 2006) [#12]
That's where it goes wrong: you have an abstract idea in your head but you need a concrete code-solution. Programming is not just copy/paste things from manuals or other persons, it's 'thinking' like a programmer: find concrete solutions for abstract problems.
If you don't want to be a programmer you obviously are only interested in the CreateGame() function. Which is a pity, since coding it yourself is so much more fun.., besides, no-one here is going to make you a CreateGame() function.

So again: a 2d-mapbrowser is really simple. And in your remark you even gave most of the elements to count with:
- player
- map (field)
- camera
I'll add another essential one:
- viewport/screen

These are exactly the 4 things to count with. Now again: try to describe me what kinda properties/functionality each element has. Just imagine them visually:
- what should the player be able to do
- what should the map do
- what should the camera do


B_Paulie(Posted 2006) [#13]
creategame()....... Im just trying to learn here cut me some slack!!!!! ive created games before, i just want to learn how to do this.
what the player should do- move around a map
map- player moves around in it
camera- follows the player with the player in center screen


CS_TBL(Posted 2006) [#14]
That's not what I mean, *sigh* .. that's abstract again. The *proper* (I'm spoiling it!) way would be:

Map, a 2d array, has:
- width
- height

Viewport has:
- width
- height

Camera has:
- X
- Y
- horizontal-move point, or points if left is different than right
- vertical movepoint, or points if up is different than down

Player has:
- X
- Y
- width
- height

When moving the player:
- update the playercoords in the map
- clip the player x,y coords so you won't run out (include the player's width/height)
- create x,y coords with the playercoord in the viewport
- check whether the just created x,y coords are 1 outside the camera's movepoints, if so, move the camera in that direction
- clip the camera x,y so it won't move anymore when you have the border of the map on the screen

That should do it I think.. didn't check.

In any case: just walk in the real map, just move the camera. An item-layer or object-layer could just be a 2nd layer on top of the first one..

But all this is really just reading out an array with a certain offset, how difficult can that be?


Buggy(Posted 2006) [#15]
If you want the player to move left, instead of him moving left, move everything else (the space background, the planets, the pickups) to the right, and keep the player in the center of the screen.

That's what these two guys should be telling a beginner like you, instead of beating around the bush and getting nowhere.


Grey Alien(Posted 2006) [#16]
or make an area in the middle of the screen that when the player moves around NO scrolling occurs and then when the player hits the edge of the area, start scrolling. This has a neat effect. See my Iron Fist (any many classic platformers) for an example.

We weren't beating around the bush, he was just asking too vague a question and one that, if answered properly, requires a long explanation. See CS_TBLs info is useful, if you understand the concepts, but what if B_Paulie doesn't? Also it does't explain how to draw the relevant part of a tilemap on the screen.

Buggy: He shouldn't be moving "everything" (it looks like that to the player though), he should only be moving the cameras all the other things coordinates should never change (unless they are moving objects) only the payers and the viewport ("camera") coords should change and the screen needs to be redrawn from the correct top left coords accordingly.


CS_TBL(Posted 2006) [#17]
That area in the middle of the screen is what these:
- horizontal-move point, or points if left is different than right
- vertical movepoint, or points if up is different than down
do ofcourse :P

Anyway, really: don't see it as beating around the bush. What I try to encourage is 'think like a programmer' instead of 'copy source'.

Since B_Paulie mentioned he 'created games before' one can assume he knows, or should know, the concept of 2d-arrays.

If you want food, I rather supply a lasso to catch a bull than a meatball. :P


LineOf7s(Posted 2006) [#18]
http://web.archive.org/web/20050319160022/www.blitzcoder.com/cgi-bin/articles/show_article.pl?f=gamekrylar01282001.html


Grey Alien(Posted 2006) [#19]
ah there we go I knew someone would have made a tutorial.


B_Paulie(Posted 2006) [#20]
its not like that, its a ship that rotates 360 degrees and i tiled an image of stars and the ship thrusts


LineOf7s(Posted 2006) [#21]
It's like that.

Think about it. Pretend you need to make a little effort.


WolRon(Posted 2006) [#22]
B_Paulie, it's almost exactly like that, except that you will have to modify your code a bit to accomodate for the fact that your ship can move in many different angles instead of just up/down/left/right.

Note in Krylars example of how he is checking the CORNERS of the sprite against the game field array? You have to do the same thing except that YOUR corners of your sprite won't actually be at the corners, it will be at the adjusted 'corners' depending on how much you've rotated the ship.

Crude Example: the "C"s represent the corners.
.............
.C---------C.
.|    A    |.
.|   / \   |.
.| / ( ) \ |.
.|AAAAAAAAA|.
.+---------+.
.............

..............
.     -----C .
.C----     | .
.|    A    | .
.|   /()\   |.
. | /  AAA\ |.
. |AAAA ----+.
. +-----     .
..............



Grey Alien(Posted 2006) [#23]
Nice ASCII Art there Wolron :-)