2D

2D games are the general focus of PlayBasic.

2D Position

A 2D game is has in two dimensions : up and down | left and right.

Up and Down is known as the x position.

Left and Right is known as the y position.

; This code shows the 2D position of the mouse in the game window
SetFPS 60

Do
    Cls 0
        Line 0, MouseY(), GetScreenWidth(), MouseY()
        Line MouseX(), 0, MouseX(), GetScreenHeight()
        Text MouseX()+10,MouseY()-40, "X : " + Str$( MouseX() )
        Text MouseX()+10,MouseY()-20, "Y : " + Str$( MouseY() )
   Sync
Loop

2D Position Functions

  • GetAngle2D - get the direction between one point and another
  • GetDistance2D - get the distance between one point and another

2D Arrays

Arrays that have two indexes are said to be 2D Arrays. This is because the elements of the array are conceptually like a 2D grid.

The below array would be written as my2dArray(5,3).

my2dArray
1 2 3 4 5
1
2
3

Related Pages

Tutorials

Categories: Graphics
page tags: 2d graphics