G
GewoonNiels
Guest
Hello and ty for trying to help me already,
Making a certain (side scrolling) room in my 2d game, was according to me not very difficult.
It would be a room which simply continued at the beginning when you reached the end of a room (x = room_width).
It should also work vise versa, when you go through the starting wall of the room (x = 0), the player should end up at the end of the room.
Well i haven't yet programmed the actual teleportation of the player, but the problem is to line up the views:
I made use of 2 views:
view[0] = the main view which doesn't change in width or position unless you get to one of the borders.
view[1] = the added view which is the added view from the other side of the room, you are not already in.
My game contains a space ship which can move, with players input, left and right. So when he arrives at the beginning of the room it should look something like this:
I know this doesn't tell you much: but "RESI" is a sprite which i put on the end of the room.
unfortunately it doesn't look like this, i edited the above picture in paint.
At the moment it looks like this:
Again: "FARM" is a sprite which shouldn't be in the view, because it isn't at the end of het room.
So basically, my view overlay system does not work:
The total_wview is the total width of the views combined which is 1920, the player should Always be in the middle of the screen so at 960.
Additionally i made a debugging message every step, so i could excatly see where my views are and what their width is, if that information is needed or if something is unclear, feel free to ask.
Again thank you for helping me,
GewoonNiels
Making a certain (side scrolling) room in my 2d game, was according to me not very difficult.
It would be a room which simply continued at the beginning when you reached the end of a room (x = room_width).
It should also work vise versa, when you go through the starting wall of the room (x = 0), the player should end up at the end of the room.
Well i haven't yet programmed the actual teleportation of the player, but the problem is to line up the views:
I made use of 2 views:
view[0] = the main view which doesn't change in width or position unless you get to one of the borders.
view[1] = the added view which is the added view from the other side of the room, you are not already in.
My game contains a space ship which can move, with players input, left and right. So when he arrives at the beginning of the room it should look something like this:
I know this doesn't tell you much: but "RESI" is a sprite which i put on the end of the room.
unfortunately it doesn't look like this, i edited the above picture in paint.
At the moment it looks like this:
Again: "FARM" is a sprite which shouldn't be in the view, because it isn't at the end of het room.
So basically, my view overlay system does not work:
Code:
total_wview = room_height*aspect_ratio;
if x-.5*total_wview < 0{
//main wview
view_wview[0] = x+.5*total_wview;
view_xview[0] = 0;
view_wport[0] = view_wview[0];
view_xport[0] = .5*total_wview-x;
//added wview
view_wview[1] = .5*total_wview-x;
view_xview[1] = room_width-(.5*total_wview-x);
view_wport[1] = view_wview[1];
view_xport[1] = 0;
//all hview
view_hview[0] = room_height;
view_yport[0] = 0;
view_hport[0] = view_hview[0];
view_hview[1] = room_height;
view_yview[1] = 0;
view_hport[1] = view_hview[1];
view_yport[1] = 0;
//visibility
view_visible[0] = 1;
view_visible[1] = 1;
}
Additionally i made a debugging message every step, so i could excatly see where my views are and what their width is, if that information is needed or if something is unclear, feel free to ask.
Again thank you for helping me,
GewoonNiels