The best way is to learn C++. I should mention Terraria was programmed in C# using XNA and Minecraft I believe was programmed in Java. Programming the engine for Terraria would not be all that hard sans the water and how it behaves. The hardest part would be acquiring the graphical assets, music and sound to create that type of game. It is relatively simple to program a brute force 2D tile engine but making it blazing fast so you can update the game world, animations and the like is not so simple. However with processors as they are today and the speed of graphics cards you might actually be able to get away with pure brute force rendering.
A tile engine is a simple paint by number scheme. You need a grid on the screen that is exactly 1 row and column larger than the screen on all sides respectively. Paint the grid from top left to bottom right either going top to bottom left to right or left to right top to bottom. Use the texture that has the same ID as the tile currently being rendered. For scrolling simply translate the entire grid left/right and when the left/right scroll value modulus the tile width or height is zero then you decrement /increment the starting row / column of the render and snap the 'grid' or the starting point of the tile render back to where it was before the scrolling occurred.
The rest of the calculations become a simple computer science exercise of how to cache in data from a larger array to a smaller array and/or how to link the arrays into zones for the entire world. The parallax scrolling that Terraria implements is dirt simple. Use two tile layers and scroll each layer by (speed / z) or (speed / layer). The back layers will scroll slower than the front layers and thus...parallax scrolling.
The rest of Terraria is simple mouse in grid cell tests or mouse in sprite bounding box tests. A very simple mouse position to cell position is:
Note that this code does not account for the fact that grid.scrollX and grid.scrollY will be floats and you cannot do an integer modulus (%) on a float. You will need to use a floating point modulus in order to compile and to get a valid result.
// Clamp to grid
mousePos.x -= mousePos.x % grid.cellSizeX;
mousePos.y -= mousePos.y % grid.cellSizeY;
// Convert to row / column
int col = mousePos.x / grid.cellSizeX;
int row = mousePos.y / grid.cellSizeY;
// Adjust for starting scroll position
// Adjust starting scroll cell
// This will not compile if the operands on either side of the modulus operator are floats
int startScrollWorldPosY = grid.scrollX - (grid.scrollX % grid.cellSizeX);
int startScrollWorldPosX = grid.scrollY - (grid.scrollY % grid.cellSizeX);
int startScrollCol = startWorldScrollPosX / grid.cellSizeX;
int startScrollRow = startWorldScrollPosY / grid.cellSizeY;
// Translate local row, col mouse click to world row, col
col += startScrollCol;
row += startScrollRow;
int cellvalue = map.GetCellValueAtRowCol(row,col)
...Handle different cell values here and react according to mouse input and state of game
After you get the map working the rest is pure old school sprite animation and hit testing code and whatever else you want to implement.
This will likely result in more questions but it should get you started. I recommend purchasing some books on C++ as well as 2D and 3D graphics.