Hi mates, how are you?

I'm having a little of a trouble trying to write songs.

I just barely started trying to do that so I know that it will take time to get better and better, but when I was writting I have a big doubt about the bass guitar.

The easiest way to create the bass after you have the guitar chords is by using the tonic roots of those chords and thats it....but...BUT...what if you want to do something else? Try that the bass sounds a little different than the guitar and make the things a little more interesting?

Do you make some fifhts, thirds, etc?

What genre are you trying to compos in?

But to tackle the chords thing.
You, as a bass player have a lot of freedom here. So you can i.) pedal the root (lame >.> ii.) you can create a walking bass-line using the scale of the chord that the guitar is doing or by using the scale that makes up the key of the song, iii) you can pedal various notes within the scales mentioned in [ii], iv) you can go fully chromatic and use notes that are disonent with what the guitars are doing. etc.
I usually stick pretty much to the notes in the chord. Not only the root, but every note you can find in that chord. Then the next step is adding notes from the scale, that are not in the chord.
Quote by Anthropocentric
Your balls. You lost the right to them. Hand them over.

Quote by T00DEEPBLUE
What kind of person needs to have a Flying V shoved up their vagina?

Join The 7-String Legion! Now!
Aye use the notes in the chord as a guide and then play other notes if it needs it.
Nothing is set in stone. I usually just try to think of a separate melody somewhere along the root notes.
I try to do something like grunge/punk/stoner rock, a mix of those stuff for sort of speak.

Ok, so to sum up.

1) walking line bass
2) Other notes of the chord (thirds, fifths, etc)
3) Other notes of the scale of the song.

You could go chromatic, but that may be a bit out there for punk etc.
Those techniques will give you a pretty flavourfull pallet to choose from so go wild. Just a side note, generally in these genres the bassist just does what the guitarist does for much of the song, and only deviates during the chorus or in breaks/interludes (if at all).

As a primer, listen to the chorus (?) of Give it All - Rise Against. The bassist does some pretty interesting things there, turn up the bass n listen. I think Alice in Chain plays around with the bass a lil, but I hardly listen to them.
For better examples you can dabble in a bit of metal, mostly Death and Tech Death, but it's all over the genre.
When you hit a wall, Tool (Justin Chancellor rocks\,,/).