PureBASIC and scrolling

Advanced game related topics
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: 2D Scrolling (Tiles) Eingine examples

Post by Rings »

splitted ;)
SPAMINATOR NR.1
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: 2D Scrolling (Tiles) Eingine examples

Post by Olliv »

Thank you Rings!
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: Where can I get the <Programming 2D scrolling games>?

Post by Olliv »

Demivec wrote:@Olliv: Here is a small adjustment needed for the example posted for large view screens. I present it merely to keep your example working and hopefully it is not considered an irritant. :wink:

It is presented in two parts to avoid posting all the intervening code

Code: Select all

Wi = 32
He = 32
OpenScreen(Dw, Dh, Dd, "")
;Add the following lines to test if screen is larger vertically than needed and set maxheight 'Dh2' appropriately
If Dh > ((He - 1) * 32)
  Dh2 = ((He - 1) * 32)
Else
  Dh2 = Dh
EndIf 
This portion modifies only the line at the start of the inner display loop with YS3 (changing 'Dh' to 'Dh2').

Code: Select all

For XS3 = 0 - 32 To Dw - 1 Step 32
      For YS3 = 0 To Dh2 - 1 Step 32 ; <== use maxheight based on screen and map size
        ;Debug Str(XS3 / 32 + OffsetTileX) + "; " + Str(YS3 / 32)
        XX = XS3 / 32 + OffsetTileX
        If XX => 0
          Tile = Tile(XX, YS3 / 32)
          If Tile
            DisplaySprite3D(Tile, XS3 + OffsetX, YS3)
          EndIf
        EndIf
      Next
    Next
The difference is shown in two thumbnails, the left one is before the change.

Image Image
@Demivec

Well... Excuse me if come back again to you, but I understand nothing about your last observation.

I have two questions I hope you have time to answer:

1) What are the conditions of your last observation?
> Only for unidirectionnal scrolling (just vertical or just horizontal)? Or for multi-directionnal scrolling?

2) Is the left picture really what you see on your computer? Or is it a representative (symbolic) picture which announces a possible bug depending the specific dimensions on different computers?

Thank you.

Ollivier
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Where can I get the <Programming 2D scrolling games>?

Post by Demivec »

Olliv wrote:Image Image
@Demivec

Well... Excuse me if come back again to you, but I understand nothing about your last observation.

I have two questions I hope you have time to answer:

1) What are the conditions of your last observation?
> Only for unidirectionnal scrolling (just vertical or just horizontal)? Or for multi-directionnal scrolling?

2) Is the left picture really what you see on your computer? Or is it a representative (symbolic) picture which announces a possible bug depending the specific dimensions on different computers?
1: It is for your horizontal scrolling example only. The simple fix I posted could be improved further by possibly centering the map vertically on the visible screen.
2: Yes. I have a larger screen view than you did and thus I see the map repeating (with an offset column) to fill the larger screen view. The same would happen if the map being used had been narrower than the screen.
Post Reply