Let \(m \ge 3\) be an integer, and let \(\mathbb {F}_q\) be the finite field of order q. Let \(\mathbb {F}_q^m\) denote the set of all m-tuples over \(\mathbb {F}_q.\) For an integer t satisfying \(0 \le t \le m,\) let \(\mathcal {D}_t\) be the set of all vectors in \(\mathbb {F}_q^m\) with Hamming weight at most t. In this paper, we study linear codes over \(\mathbb {F}_q\) with defining sets \(\begin{aligned} \mathcal {D}_{t_2} \setminus \mathcal {D}_{t_1-1},~~(\mathbb {F}_q^m\setminus \mathcal {D}_{t_2}) \cup (\mathcal {D}_{t_1-1}\setminus \{{\textbf {0}}\}),~~(\mathcal {D}_{t_2}\setminus \mathcal {D}_{t_1-1}) \cup (\mathbb {F}_q^m\setminus \mathcal {D}_{m-1})\text { and }(\mathcal {D}_{t_2} \setminus \mathcal {D}_{t_1-1}) \cup \{{\textbf {1}}\}, \end{aligned}\) where \(t_1,t_2\) are positive integers with \(t_1 \le t_2 \le m - 1,\) and \({\textbf {1}} = (1,1,\ldots ,1)\) is the all-one vector in \(\mathbb {F}_q^m.\) We also study projective codes over \(\mathbb {F}_q\) whose defining sets are maximal subsets of these sets, where each maximal subset consists of vectors generating distinct one-dimensional subspaces of \(\mathbb {F}_q^m\) over \(\mathbb {F}_q.\) We explicitly determine the parameters and Hamming weight enumerators of these codes, as well as the parameters of their dual codes. Furthermore, we study the hulls of linear codes over \(\mathbb {F}_q\) with defining sets \(\mathcal {D}_{t_2} {\setminus } \mathcal {D}_{t_1-1},\) \((\mathbb {F}_q^m{\setminus }\mathcal {D}_{t_2}) \cup (\mathcal {D}_{t_1-1}{\setminus }\{{\textbf {0}}\}),\) \((\mathcal {D}_{t_2}{\setminus } \mathcal {D}_{t_1-1}) \cup (\mathbb {F}_q^m{\setminus }\mathcal {D}_{m-1})\) and \((\mathcal {D}_{t_2} {\setminus } \mathcal {D}_{t_1-1}) \cup \{{\textbf {1}}\},\) and explicitly determine their dimensions. In doing so, we enumerate certain sets arising in the study of hulls of linear codes associated with simplicial complexes. Motivated by this, we also study the hulls of linear codes over \(\mathbb {F}_q\) with defining sets \(\mathbb {F}_q^m{\setminus }\Delta \) and \(\Delta {\setminus }\{{\textbf {0}}\},\) where \(\Delta \) is a simplicial complex of \(\mathbb {F}_q^m.\) As applications, we construct an infinite family of q-ary distance-optimal entanglement-assisted quantum error-correcting codes (EAQECCs) and an infinite family of q-ary almost dimension-optimal EAQECCs, both valid for all \(q > 3.\) Moreover, we obtain several infinite families of projective codes with few weights, distance-optimal codes, dimension-optimal codes, self-orthogonal codes, and linear codes with complementary duals (or LCD codes), all with new parameters. Besides this, as an additional application of our newly constructed projective codes, we construct two infinite families of q-ary alphabet-optimal locally repairable codes with locality 2 for all \(q\ge 3.\)