Major scale
The major scale is a seven-note pattern of whole and half steps, not a promise that a song sounds cheerful.
Build it from distances
Starting on C, the major scale gives C–D–E–F–G–A–B. The step pattern is whole, whole, half, whole, whole, whole, half. Start elsewhere and keep the pattern to make another major scale; D major needs F-sharp and C-sharp. The sequence matters more than the white-key picture.
Find a small melody inside it
Play only degrees 1, 2, 3 and 5, then write a four-note phrase. Repeat it but end on degree 2 rather than 1. The first ending may settle more strongly; the second can invite an answer. Add a single chord underneath each version and listen to how harmony changes that feeling.
Do not equate scale with key
A melody using major-scale notes can be heard against several tonal centers. Rhythm, harmony, register and timbre also shape mood. If you need a darker passage, try changing the bass or using fewer notes before assuming the scale itself must change.
Related entries
Further reading
These source links provide technical background; the exercises above are Eidolon's own editorial guidance.