On any car if you get a check engine light or other fault light this typically means one or more of the sensors has failed or has a faulty connection.
The ECU senses this and may put the car into 'limp home' mode which typically limits the revs and the amount of power available. Usually the car is safe to drive for a short distance as the mode is intended is intended to get you home without incurring any engine damage
The quickest route to repair is to have the car plugged into a diagnostic machine which will read off the fault code stored in the ECU (providing the light is still on at this point) and indicate which sensor has failed or whether the fault is more serious.
You can do a very rough and ready check yourself by unplugging sensors one at a time and seeing if any of them change the driving condition which would indicate the most recently unplugged sensor is the faulty one. This method is not foolproof though and reading a fault code off is the better method.
from your description
This could be a wiring issue as things tend to expand when hot and its possible a poor or partial electrical connection is being pushed apart on one of the major sensors so check the connection plug and wiring to the following;
Crank position sensor
Cam position sensor
Throttle position sensor
Also worth checking the connections to the fuel pump for the same reason - unplug each in turn and give them a good squirt of switch / contact cleaner - Not WD40
and also unplug and inspect the main power relays and fuses for signs of overheating or corroded terminals - so the ones for the ECU and the fuel pump
And also unplug the wiring loom connections in the engine bay one at time and inspect for corroded or recessed pins.
- Also replace the spark plugs if any of them fail this checklist:
Also its worth checking that the electric pump that feeds the injectors is working correctly, it should run for a few seconds then switch off when you first turn the ignition on. If the connections to this are corroded or damaged then the pump could stop at any time. Check that its relay switches in and out and the relay contacts are clean and bright – replace the relay if in any doubt and do the same for the fuse, ideally measure the voltage at the pump and check its getting 12V