The construction of the microenvironment is of great importance for the study of cell behaviors such as motility and viability. The morphology and mechanical properties of cells can be affected by the microenvironment and interactions between cells. There have been numerous studies on cell-cell and cell-microenvironment interactions. However, these studies are generally time-consuming and complicated for the following reasons: firstly, constructing the microenvironment is complex, as the microenvironment itself is complicated; secondly, the internal characteristics of different components of the microenvironment are highly variable and difficult to simulate. Using a digital micromirror device (DMD)-based optical projection lithography system, we have developed a new method for cell studies: by employing a digital dynamic mask, poly(ethylene glycol) dimethacrylate (PEGDMA)-based hydrogels could be easily designed with a wide variety of patterns. Those structures can be rationally designed to be functional, as different modules can mimic the microenvironment and restrict the migration of cells. Furthermore, 4% paraformaldehyde can be mixed into the PEGDMA and cured using UV exposure. Paraformaldehyde in hydrogels had a moderate impact on the viability of cells.