how can make screen moving on 2d game?

Posted By: MDI

how can make screen moving on 2d game? - 11/07/07 23:03

how can make screen moving on 2d game? That i need to my newest game - that is 2d strategy like much mobile games. And if map is bigger for 1024 and 768 how i can move my screen or need move panels when mouse get close to screen border.
Please help any.
Posted By: RruthH

Re: how can make screen moving on 2d game? - 11/08/07 01:04

Have a look at AUM 2: Stratego. The code's in there.
Posted By: MDI

how can make screen moving on 2d game? - 11/08/07 11:23

That isnt help in this type!
There is 3d world and camera moving isnt problem.
But im using panels for game world and for units.
All is great only i dont know how to move screen or panels if i wishes drive to another location in map.
Posted By: ISG

Re: how can make screen moving on 2d game? - 11/08/07 18:02

Maybe if I could understand the question better then I could help. Maybe some visual examples could be useful.
Posted By: flits

Re: how can make screen moving on 2d game? - 11/08/07 18:20

if i understand it right he wants to create a 2d world white a 3d calcution

somthing like habo(stupid game)
Posted By: MDI

how can make screen moving on 2d game? - 11/08/07 19:10

Here is picture:



all other terrains is behind screen = that is in + 768 or + 1024 pixels!
And i wishes with mouse driving to screen border pull them in screen - simply drive to another location in map.

And here isnt any needs after camera moving - no 3d worlds.
Posted By: D3D

Re: how can make screen moving on 2d game? - 11/08/07 20:38

Guess you must first write down the size of images and to be used screen resolution. Read a little about using mouse and panels in Gamestudio.

Set the fixed values in variables so that you wont go off-screen.

Then use something like if the mouse is at this or that location on the screen, move panel to left or right up down. That would I think be the easy way.

Don't know if you can do some collision with panels or have to fake it!?
Posted By: MDI

how can make screen moving on 2d game? - 11/08/07 20:45

only one problem! In this case to me moves only last created panel of his type!
How can make that when moves all panels with one name!

Sample!

panel* grass
{grass = pan_create("grass.pcx;",2);grass.visible = on;
if(key_d == 1)
{grass.pos_x -=5 * time;}
// and so on.......
}

And how i say heres moves only last panel. How can do that when moves them all in one time?
Posted By: D3D

Re: how can make screen moving on 2d game? - 11/08/07 20:53

Code:
 panel* panel1; panel2; panel* grass
{grass = pan_create("grass.pcx;",2);grass.visible = on;
if(key_d == 1)
{grass.pos_x -=5 * time_step;
panel1.pos_x -=5 * time_step;
panel2.pos_x -=5 * time_step;}
// and so on.......
}



Or did you mean something else? Also why do you want to move the grass or is that the whole map as shown in the image above?
Posted By: MDI

how can make screen moving on 2d game? - 11/08/07 21:03

No all isnt grass!

There is rock panels, mountain panels, forest panels, bridge panels, grass panels, water panels, and some type city panels.
They are created with x.dat document help and dont make big problem in creating.
On one symbol creates one type panel in his own place.

And this style is too horrible - here in this map is 100(10*10) panels.
and im not going to write for all his own name.
Or isnt some way how to merge under one name all one type panels?

This problem is to me with some time ago maded 3d game too. One type enemies named under one ENTITY* - and all functions works only on last one putted model correctly.
Posted By: D3D

Re: how can make screen moving on 2d game? - 11/08/07 21:22

Not really sure if it's the best solution, but perhaps you can use structs for that? Only then you would have to write the whole game in Lite-C. To be honest, for a 2D game I would not use 3D Gamestudio.

You can fake 2D or maybe even write with the help of Lite-C and a plugin a 2D engine, just no real 2D out of the box.
Posted By: Captain_Kiyaku

Re: how can make screen moving on 2d game? - 11/09/07 12:17

you can create an array for your 100 panels, and save the pointers in it and let them move in a while loop when you go with your mouse to the edge of your screen.

would be like this:


panel* ptrPanelTemp;
function fncMoveScreen(iX, iY)
{
while(iCounter < 100)
{
ptrPanelTemp = ptr_for_handle(yourArray[iCounter]);
ptrPanelTemp.pos_x += iX;
ptrPanelTemp.pos_y += iY;
iCounter += 1;
}
}

and call it like fncMoveScreen(5, -7);, depends on how you want to move the screen

this should work when you saved all the pointers in this arrays at the beginning of your game.
Posted By: ISG

Re: how can make screen moving on 2d game? - 11/09/07 16:25

Or just use one image with all the stuff on it from the map? Unless you specifically need everything in it's own seperate form.
Posted By: MDI

how can make screen moving on 2d game? - 11/11/07 20:03

Sorry but i somehow dont understand that in
ptr_for_handle(yourArray[iCounter]);

I need create panel and then store it with handle under yourarray, but what is that icounter?
Posted By: MDI

Thanks for help - 11/12/07 23:45

With your ideas i done some fixes and now game works really nice.
Posted By: Captain_Kiyaku

Re: Thanks for help - 11/13/07 14:10

Sorry for the late answer.
iCounter is the position in the array. it goes from 0 to 99 so all panel-pointers inside will get moved.
Posted By: MDI

Re: Thanks for help - 11/13/07 18:02

Aha! I there dont find way how put in that array without errors. And then i transform panels in sprites and move camera in 3d world. With all of this now is easy to make events and other stuffs.

Only sprites strangly reacts on event_touch and event_release - dont wait till release but already after frame make event-rel.. and then again event_tou.. and continue so long till i move mouse off from sprite.
That is normal or engine bug with sprites?

P.S. my fault!! HEHE! That happens when on model creates new sprite(checkbox)
Now need do something to ignore him.
© 2024 lite-C Forums