Gamification has been widely used in training and enhancing cognitive ability, such as working memory and attention. For example, 3D games can enhance participants' working memory, thereby improving their learning efficiency, and the powerful immersion of VR games can improve the attention of patients with ADHD. However, previous works have not elaborated to what extent the two different game modes can affect cognitive ability respectively, nor have they determined which game mode has a greater effect on the cognitive level. Exploring the impact of different game modes on cognitive ability can help better apply gamification to the training and improvement of cognitive ability, and quantifying cognitive ability through human physiological signals such as brain electrical activity level (EEG) can help evaluate the changes of cognitive ability in different game modes more accurately. Therefore, different from previous studies, we used EEG signals and game performance data (such as game scores and time to complete the game) to calculate participants' cognitive level quantitatively, and did comparative experiments to study cognitive abilities in different game modes and the temporal characteristics of cognitive ability changes. We also explored whether gender would affect cognitive ability. Our research has the following findings. First, compared with the 3D mode, participants get better game scores and higher EEG scores in the VR mode, the time to complete the game task is shorter, and the time to reach the best state of working memory is shorter. Second, participants' gender has no significant effect on working memory, but there is a significant difference in attention in the VR game mode, it takes less time for males to reach the peak of attention than for females. Our conclusion indicates that VR games have greater potential in the field of training and enhancing cognitive ability than 3D games.