Can I still use time machine if I encrypt my drive with file vault?

Yes, you can still use Time Machine backups even if you encrypt the boot drive with FileVault.

Note that when setting up Time Machine backups, you'll have to select that the backup should be encrypted as well, otherwise your data will be stored unencrypted in the Time Machine backup.